This commit is contained in:
@@ -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\"}]"}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +81,7 @@ As sending from client now with fail:
|
||||
dt.type = "text";
|
||||
dtemplate.Add(dt);
|
||||
|
||||
|
||||
|
||||
dt = new JObject();
|
||||
dt.fld = "UserNotes";
|
||||
dt.required = true;
|
||||
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user