From ef01470d13eb6345adf4902ec05e59c1dd067001 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 17 Mar 2020 23:29:21 +0000 Subject: [PATCH] --- PickList/PickListAllTests.cs | 48 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/PickList/PickListAllTests.cs b/PickList/PickListAllTests.cs index 473e987..bc0d9d0 100644 --- a/PickList/PickListAllTests.cs +++ b/PickList/PickListAllTests.cs @@ -73,7 +73,6 @@ namespace raven_integration df.fld = "DOES_NOT_EXIST";//<-- ERROR BAD FIELD NAME dTemplateArray.Add(df); d.Template = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None); - //replace the User template at the server a = await Util.PostAsync("PickList/Template", await Util.GetTokenAsync("BizAdminFull"), d.ToString(Newtonsoft.Json.Formatting.None)); //"{\"error\":{\"code\":\"2200\",\"details\":[{\"message\":\"Template array item 0, fld property value \\\"DOES_NOT_EXIST\\\" is not a valid value for AyaType specified\",\"target\":\"Template\",\"error\":\"2203\"}],\"message\":\"Object did not pass validation\"}}" Util.ValidateErrorCodeResponse(a, 2200, 400); @@ -104,7 +103,6 @@ namespace raven_integration df.fld = "useremployeenumber"; dTemplateArray.Add(df); d.Template = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None); - //replace the User template at the server //ERROR NO RIGHTS USER a = await Util.PostAsync("PickList/Template", await Util.GetTokenAsync("CustomerLimited"), d.ToString(Newtonsoft.Json.Formatting.None)); //"{\"error\":{\"code\":\"2004\",\"message\":\"User not authorized for this resource operation (insufficient rights)\"}}" @@ -126,42 +124,28 @@ namespace raven_integration df = new JObject(); df.fld = "useremployeenumber"; dTemplateArray.Add(df); - string sTemplate=dTemplateArray.ToString(Newtonsoft.Json.Formatting.None); - d.Template = sTemplate.Substring(2);//<-- ERROR missing first two characters of json template array - //replace the User template at the server + string sTemplate = dTemplateArray.ToString(Newtonsoft.Json.Formatting.None); + d.Template = sTemplate.Substring(2);//<-- ERROR missing first two characters of json template array a = await Util.PostAsync("PickList/Template", await Util.GetTokenAsync("BizAdminFull"), d.ToString(Newtonsoft.Json.Formatting.None)); //"{\"error\":{\"code\":\"2200\",\"details\":[{\"message\":\"Template is not valid JSON string: Error reading JArray from JsonReader. Current JsonReader item is not an array: String. Path '', line 1, position 5.\",\"target\":\"Template\",\"error\":\"2203\"}],\"message\":\"Object did not pass validation\"}}" Util.ValidateErrorCodeResponse(a, 2200, 400); Util.ShouldContainValidationError(a, "Template", "2203"); + } - //malformed template bad json? - - - // //UPDATE - - // //PUT, make private - // d["public"] = false; - // d.name = Util.Uniquify("Put - Test DataListView (privatized)"); - // d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value(); - // a = await Util.PutAsync("DataListView/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"), d.ToString()); - // Util.ValidateHTTPStatusCode(a, 200); - - // //check PUT worked - // a = await Util.GetAsync("DataListView/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull")); - // Util.ValidateNoErrorInResponse(a); - // a.ObjectResponse["data"]["name"].Value().Should().Be(d.name.ToString()); - - - // //FETCH DISALLOWED - // //Get as alternate user should fail for private filter - // a = await Util.GetAsync("DataListView/" + Id.ToString(), await Util.GetTokenAsync("SubContractorLimited")); - // Util.ValidateResponseNotFound(a); - - // // //DELETE - // ApiResponse DELETETestResponse = await Util.DeleteAsync("DataListView/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull")); - // Util.ValidateHTTPStatusCode(DELETETestResponse, 204); - + /// + /// test get templates list + /// + [Fact] + public async void UserPickListTemplateList() + { + //RETRIEVE + ApiResponse a = await Util.GetAsync("PickList/TemplateList", await Util.GetTokenAsync("BizAdminFull")); + Util.ValidateDataReturnResponseOk(a); + //assert contains at least two records (as we only have two at time of writing this test) + var templateList = ((JArray)a.ObjectResponse["data"]); + templateList.Count.Should().BeGreaterThan(1); + templateList[0]["id"].Value().Should().Be(2);//first one should be a widget } // ///