This commit is contained in:
2019-06-25 00:01:07 +00:00
parent 49702e2d7c
commit cc059dbd5e

View File

@@ -22,7 +22,7 @@ namespace raven_integration
//so this test will either create or update depending upon if it's already created one or not //so this test will either create or update depending upon if it's already created one or not
dynamic d = new JObject(); dynamic d = new JObject();
d.formkey = "widget"; d.formkey = "user";
/* /*
Example: Example:
@@ -32,24 +32,20 @@ namespace raven_integration
dynamic dtemplate = new JArray(); dynamic dtemplate = new JArray();
dynamic dt = new JObject(); dynamic dt = new JObject();
dt.fld = "WidgetCustom1"; dt.fld = "UserCustom1";
dt.hide = false; dt.hide = false;
dt.required = true; dt.required = true;
dt.type = "text"; dt.type = "text";
dtemplate.Add(dt); dtemplate.Add(dt);
dt = new JObject(); dt = new JObject();
dt.fld = "WidgetSerial"; dt.fld = "UserNotes";
dt.required = true; dt.required = true;
dtemplate.Add(dt); dtemplate.Add(dt);
dt = new JObject(); dt = new JObject();
dt.fld = "WidgetNotes"; dt.fld = "UserCustom2";
dt.required = true;
dtemplate.Add(dt);
dt = new JObject();
dt.fld = "WidgetCustom2";
dt.hide = true; dt.hide = true;
dt.required = false; dt.required = false;
dt.type = "bool"; dt.type = "bool";
@@ -61,13 +57,13 @@ namespace raven_integration
//Is there one already? //Is there one already?
//RETRIEVE //RETRIEVE
//Get one //Get one
ApiResponse a = await Util.GetAsync("FormCustom/widget", await Util.GetTokenAsync("BizAdminFull")); ApiResponse a = await Util.GetAsync("FormCustom/user", await Util.GetTokenAsync("BizAdminFull"));
bool Exists = ((int)a.HttpResponse.StatusCode) == 200; bool Exists = ((int)a.HttpResponse.StatusCode) == 200;
if (Exists) if (Exists)
{ {
//Update //Update
d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>(); d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
a = await Util.PutAsync("FormCustom/widget", await Util.GetTokenAsync("BizAdminFull"), d.ToString()); a = await Util.PutAsync("FormCustom/user", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
Util.ValidateHTTPStatusCode(a, 200); Util.ValidateHTTPStatusCode(a, 200);
} }
else else
@@ -80,13 +76,13 @@ namespace raven_integration
//check the concurrency token cache scheme //check the concurrency token cache scheme
uint token = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>(); uint token = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
//This should return a 304 not modified //This should return a 304 not modified
a = await Util.GetAsync($"FormCustom/widget?concurrencyToken={token}", await Util.GetTokenAsync("BizAdminFull")); a = await Util.GetAsync($"FormCustom/user?concurrencyToken={token}", await Util.GetTokenAsync("BizAdminFull"));
Util.ValidateHTTPStatusCode(a, 304); Util.ValidateHTTPStatusCode(a, 304);
//and this should return the whole object //and this should return the whole object
token--;//make the token not match token--;//make the token not match
//This should return a 200 and the whole object //This should return a 200 and the whole object
a = await Util.GetAsync($"FormCustom/widget?concurrencyToken={token}", await Util.GetTokenAsync("BizAdminFull")); a = await Util.GetAsync($"FormCustom/user?concurrencyToken={token}", await Util.GetTokenAsync("BizAdminFull"));
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
} }
@@ -124,7 +120,7 @@ namespace raven_integration
{ {
ApiResponse a = await Util.GetAsync("FormCustom/AvailableCustomizableFormKeys", await Util.GetTokenAsync("BizAdminFull")); ApiResponse a = await Util.GetAsync("FormCustom/AvailableCustomizableFormKeys", await Util.GetTokenAsync("BizAdminFull"));
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0); ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(2);//is 2 as of writing (widget,user)
} }