This commit is contained in:
2019-12-10 01:13:01 +00:00
parent c8993cdb68
commit eb3dc7d9c7
2 changed files with 27 additions and 26 deletions

View File

@@ -15,11 +15,11 @@ namespace raven_integration
/// Test create or update
/// </summary>
[Fact]
public async void FormCustomCreateUpdate()
public async void FormCustomUpdate()
{
//This is a special case, you can create or PUT a formcustom, but you can't delete one and you can't create one if one already exists
//so this test will either create or update depending upon if it's already created one or not
//This is a special case, you can PUT a formcustom, but you can't delete one and you can't create one
dynamic d = new JObject();
d.formkey = "user";
@@ -37,10 +37,16 @@ As sending from client now with fail:
}
//As it appears in this unit test to string
{{
"formkey": "user",
"template": "[\r\n {\r\n \"fld\": \"UserCustom1\",\r\n \"hide\": false,\r\n \"required\": true,\r\n \"type\": \"text\"\r\n },\r\n {\r\n \"fld\": \"UserNotes\",\r\n \"required\": true\r\n },\r\n {\r\n \"fld\": \"UserCustom2\",\r\n \"hide\": true,\r\n \"required\": false,\r\n \"type\": \"bool\"\r\n }\r\n]"
}}
"{\r\n \"formkey\": \"user\",\r\n \"template\": \"[\\r\\n {\\r\\n \\\"fld\\\": \\\"UserCustom1\\\",\\r\\n \\\"hide\\\": false,\\r\\n \\\"required\\\": true,\\r\\n \\\"type\\\": \\\"text\\\"\\r\\n },
\\r\\n {\\r\\n \\\"fld\\\": \\\"UserNotes\\\",\\r\\n \\\"required\\\": true\\r\\n },\\r\\n
{\\r\\n \\\"fld\\\": \\\"UserCustom2\\\",\\r\\n \\\"hide\\\": true,\\r\\n \\\"required\\\": false,\\r\\n \\\"type\\\": \\\"bool\\\"\\r\\n }\\r\\n]\",
\r\n \"concurrencyToken\": 3802346\r\n}"
//cleaned up unit test string from immediately above here
"{"formkey":"user","template":"[{"fld":"UserCustom1","hide":false,"required":true,"type":"text"},
{"fld":"UserNotes","required":true},
{"fld":"UserCustom2","hide":true,"required":false,"type":"bool"}]",
"concurrencyToken":3802346}"
//As it fetches off the server now
@@ -55,6 +61,11 @@ As sending from client now with fail:
}
}
OK, it appears the quotes need to be escaped for some reason?, this works:
{"concurrencyToken": 3802346,
"formKey": "user",
"template": "[{\"fld\":\"UserCustom1\",\"hide\":false,\"required\":true,\"type\":\"text\"},{\"fld\":\"UserNotes\",\"required\":true},{\"fld\":\"UserCustom2\",\"hide\":true,\"required\":false,\"type\":\"bool\"}]"}
@@ -86,24 +97,14 @@ As sending from client now with fail:
d.template = dtemplate.ToString();//it expects it to be a json string, not actual json
//Is there one already?
//RETRIEVE
//Get one
//Get the current one (server will create if non-existent)
ApiResponse a = await Util.GetAsync("FormCustom/user", await Util.GetTokenAsync("BizAdminFull"));
bool Exists = ((int)a.HttpResponse.StatusCode) == 200;
if (Exists)
{
//Update
d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
a = await Util.PutAsync("FormCustom/user", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
Util.ValidateHTTPStatusCode(a, 200);
}
else
{
//Create it
a = await Util.PostAsync("FormCustom", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
}
//Update
d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
a = await Util.PutAsync("FormCustom/user", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
Util.ValidateHTTPStatusCode(a, 200);
//check the concurrency token cache scheme
uint token = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();

View File

@@ -24,8 +24,8 @@ namespace raven_integration
private static HttpClient client { get; } = new HttpClient();
//public static string API_BASE_URL = "http://localhost:7575/api/v8/";
public static string API_BASE_URL = "https://test.helloayanova.com/api/v8.0/";
public static string API_BASE_URL = "http://localhost:7575/api/v8/";
//public static string API_BASE_URL = "https://test.helloayanova.com/api/v8.0/";
public static string TEST_DATA_FOLDER = @"..\..\..\testdata\";