This commit is contained in:
@@ -17,97 +17,91 @@ namespace raven_integration
|
||||
[Fact]
|
||||
public async void CRUD()
|
||||
{
|
||||
/*
|
||||
{
|
||||
"id": 0,
|
||||
"concurrencyToken": 0,
|
||||
"ownerId": 0,
|
||||
"name": "string",
|
||||
"public": true,
|
||||
"listKey": "string",
|
||||
"filter": "string"
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//CREATE
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test DataFilter");
|
||||
d.ownerId = 1L;
|
||||
d.listKey="Widget";
|
||||
d.filter="";
|
||||
// d.ownerId = 1L;
|
||||
d["public"] = true;
|
||||
d.listKey = "Widget";
|
||||
|
||||
ApiResponse a = await Util.PostAsync("Tag", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
//"[{fld:"name",op:"!=",value:"Notequaltothis"},{fld:"tags",op:"Eq",value:"[23,456,54]"}]
|
||||
dynamic dfilter = new JArray();
|
||||
dynamic df = new JObject();
|
||||
df.fld = "name";
|
||||
df.op = "%-";
|
||||
df.value = "Generic";//lots of seed widgets start with Generic
|
||||
dfilter.Add(df);
|
||||
|
||||
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());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
long tagId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
string tagName = a.ObjectResponse["data"]["name"].Value<string>();
|
||||
tagName.Should().StartWith("testtag");
|
||||
|
||||
long Id = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
string Name = a.ObjectResponse["data"]["name"].Value<string>();
|
||||
Name.Should().StartWith("Test DataFilter");
|
||||
|
||||
|
||||
//RETRIEVE
|
||||
/*
|
||||
{
|
||||
"data": {
|
||||
"id": 24,
|
||||
"created": "2018-03-28T21:07:41.9703503Z",
|
||||
"concurrencyToken": 9502,
|
||||
"ownerId": 1,
|
||||
"name": "یونیکُد چیست؟"
|
||||
}
|
||||
}
|
||||
*/
|
||||
//Get one
|
||||
a = await Util.GetAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
a.ObjectResponse["data"]["name"].Value<string>().Should().StartWith("testtag");
|
||||
// // //RETRIEVE
|
||||
// // /*
|
||||
// // {
|
||||
// // "data": {
|
||||
// // "id": 24,
|
||||
// // "created": "2018-03-28T21:07:41.9703503Z",
|
||||
// // "concurrencyToken": 9502,
|
||||
// // "ownerId": 1,
|
||||
// // "name": "یونیکُد چیست؟"
|
||||
// // }
|
||||
// // }
|
||||
// // */
|
||||
// // //Get one
|
||||
// // a = await Util.GetAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
// // Util.ValidateDataReturnResponseOk(a);
|
||||
// // a.ObjectResponse["data"]["name"].Value<string>().Should().StartWith("testtag");
|
||||
|
||||
//UPDATE
|
||||
// // //UPDATE
|
||||
|
||||
//PUT
|
||||
d.Id = tagId;
|
||||
d.name = Util.Uniquify("PutTestTag");
|
||||
d.created = DateTime.UtcNow.ToString("s", System.Globalization.CultureInfo.InvariantCulture);
|
||||
d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||
d.OwnerId = 1L;
|
||||
// // //PUT
|
||||
// // d.Id = tagId;
|
||||
// // d.name = Util.Uniquify("PutTestTag");
|
||||
// // d.created = DateTime.UtcNow.ToString("s", System.Globalization.CultureInfo.InvariantCulture);
|
||||
// // d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||
// // d.OwnerId = 1L;
|
||||
|
||||
|
||||
ApiResponse PUTTestResponse = await Util.PutAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
|
||||
// // ApiResponse PUTTestResponse = await Util.PutAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
// // Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
|
||||
|
||||
// // //check PUT worked
|
||||
// // ApiResponse checkPUTWorked = await Util.GetAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
// // Util.ValidateNoErrorInResponse(checkPUTWorked);
|
||||
// // checkPUTWorked.ObjectResponse["data"]["name"].Value<string>().Should().Be(d.name.ToString().ToLowerInvariant().Replace(" ", "-"));
|
||||
// // uint concurrencyToken = PUTTestResponse.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||
|
||||
// // //PATCH
|
||||
// // var newName = Util.Uniquify("PatchUpdate");
|
||||
// // string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
|
||||
// // ApiResponse PATCHTestResponse = await Util.PatchAsync("Tag/" + tagId.ToString() + "/" + concurrencyToken.ToString(), await Util.GetTokenAsync("BizAdminFull"), patchJson);
|
||||
// // Util.ValidateHTTPStatusCode(PATCHTestResponse, 200);
|
||||
|
||||
// // //check PATCH worked
|
||||
// // ApiResponse checkPATCHWorked = await Util.GetAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
// // Util.ValidateNoErrorInResponse(checkPATCHWorked);
|
||||
// // checkPATCHWorked.ObjectResponse["data"]["name"].Value<string>().Should().Be(newName.ToLowerInvariant().Replace(" ", "-"));
|
||||
|
||||
// // // //DELETE
|
||||
// // ApiResponse DELETETestResponse = await Util.DeleteAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
// // Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
|
||||
|
||||
//check PUT worked
|
||||
ApiResponse checkPUTWorked = await Util.GetAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateNoErrorInResponse(checkPUTWorked);
|
||||
checkPUTWorked.ObjectResponse["data"]["name"].Value<string>().Should().Be(d.name.ToString().ToLowerInvariant().Replace(" ", "-"));
|
||||
uint concurrencyToken = PUTTestResponse.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||
|
||||
//PATCH
|
||||
var newName = Util.Uniquify("PatchUpdate");
|
||||
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
|
||||
ApiResponse PATCHTestResponse = await Util.PatchAsync("Tag/" + tagId.ToString() + "/" + concurrencyToken.ToString(), await Util.GetTokenAsync("BizAdminFull"), patchJson);
|
||||
Util.ValidateHTTPStatusCode(PATCHTestResponse, 200);
|
||||
|
||||
//check PATCH worked
|
||||
ApiResponse checkPATCHWorked = await Util.GetAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateNoErrorInResponse(checkPATCHWorked);
|
||||
checkPATCHWorked.ObjectResponse["data"]["name"].Value<string>().Should().Be(newName.ToLowerInvariant().Replace(" ", "-"));
|
||||
|
||||
// //DELETE
|
||||
ApiResponse DELETETestResponse = await Util.DeleteAsync("Tag/" + tagId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
|
||||
Reference in New Issue
Block a user