This commit is contained in:
2019-01-10 23:47:00 +00:00
parent 3c0d845ff6
commit 5a289da6df

View File

@@ -11,12 +11,84 @@ namespace raven_integration
public class FormCustom
{
// /// <summary>
// /// Test all CRUD routes
// /// </summary>
// [Fact]
// public async void CRUD()
// {
/// <summary>
/// Test create or update
/// </summary>
[Fact]
public async void FormCustomCreateUpdate()
{
//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
dynamic d = new JObject();
d.formkey = "widget";
/*
Example:
{template:[{fld:"ltkeyfieldname",hide:"true/false",required:"true/false", type:"bool"},{fld:"ltkeyfieldname",hide:"true/false",required:"true/false", type:"text"]}
*/
dynamic dtemplate = new JArray();
dynamic dt = new JObject();
dt.fld = "WidgetCustom1";
dt.hide = false;
dt.required = true;
dt.type = "date";
dtemplate.Add(dt);
dt = new JObject();
dt.fld = "WidgetCustom2";
dt.hide = true;
dt.required = false;
dt.type = "bool";
dtemplate.Add(dt);
d.template = dtemplate.ToString();//it expects it to be a json string, not actual json
//Is there one already?
//RETRIEVE
//Get one
ApiResponse a = await Util.GetAsync("FormCustom/widget", await Util.GetTokenAsync("BizAdminFull"));
bool Exists = ((int)a.HttpResponse.StatusCode) == 200;
if (Exists)
{
//Update
//update it
d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
a = await Util.PutAsync("FormCustom/widget", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
Util.ValidateHTTPStatusCode(a, 200);
// //check PUT worked
// a = await Util.GetAsync("DataFilter/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"));
// Util.ValidateNoErrorInResponse(a);
// a.ObjectResponse["data"]["name"].Value<string>().Should().Be(d.name.ToString());
}
else
{
//Create it
// a = await Util.PostAsync("FormCustom", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
// Util.ValidateDataReturnResponseOk(a);
}
// a.ObjectResponse["data"]["name"].Value<string>().Should().StartWith("Test DataFilter");
// //CREATE
// dynamic d = new JObject();
// d.name = Util.Uniquify("Test DataFilter");
@@ -34,7 +106,7 @@ namespace raven_integration
// d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
// ApiResponse a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
// a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
// Util.ValidateDataReturnResponseOk(a);
// long Id = a.ObjectResponse["data"]["id"].Value<long>();
@@ -76,7 +148,7 @@ namespace raven_integration
// ApiResponse DELETETestResponse = await Util.DeleteAsync("DataFilter/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull"));
// Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
// }
}
/// <summary>
///