This commit is contained in:
2020-05-10 14:41:20 +00:00
parent 9740961090
commit d5c511a84d

View File

@@ -16,7 +16,9 @@ namespace raven_integration
[Fact] [Fact]
public async void CRUD() public async void CRUD()
{ {
//CREATE HEADER /////////////////////////////////////////////////////////////////////////
// CREATE
//
dynamic d = new JObject(); dynamic d = new JObject();
d.active = true; d.active = true;
d.notes = "WOHEADER The quick brown fox jumped over the six lazy dogs!"; d.notes = "WOHEADER The quick brown fox jumped over the six lazy dogs!";
@@ -33,8 +35,8 @@ namespace raven_integration
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long WorkOrderId = a.ObjectResponse["data"]["id"].Value<long>(); long WorkOrderId = a.ObjectResponse["data"]["id"].Value<long>();
#region CREATE first woitem
//CREATE WOITEM //CREATE WOITEM 1
d = new JObject(); d = new JObject();
d.active = true; d.active = true;
d.notes = "woitem The quick brown fox jumped over the six lazy dogs!"; d.notes = "woitem The quick brown fox jumped over the six lazy dogs!";
@@ -50,7 +52,7 @@ namespace raven_integration
a = await Util.PostAsync("workorders/items", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); a = await Util.PostAsync("workorders/items", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long WorkOrderItemId = a.ObjectResponse["data"]["id"].Value<long>(); long WorkOrderItem1Id = a.ObjectResponse["data"]["id"].Value<long>();
@@ -59,7 +61,7 @@ namespace raven_integration
d.active = true; d.active = true;
d.notes = "woitempart The quick brown fox jumped over the six lazy dogs!"; d.notes = "woitempart The quick brown fox jumped over the six lazy dogs!";
d.wiki = "# woitempart test wiki"; d.wiki = "# woitempart test wiki";
d.workOrderItemId = WorkOrderItemId; d.workOrderItemId = WorkOrderItem1Id;
//Tags //Tags
dTagsArray = new JArray(); dTagsArray = new JArray();
@@ -73,15 +75,13 @@ namespace raven_integration
long WorkOrderItemPartId = a.ObjectResponse["data"]["id"].Value<long>(); long WorkOrderItemPartId = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE WOITEMLABOR(S) //CREATE WOITEMLABOR(S)
//ONE //ONE
d = new JObject(); d = new JObject();
d.active = true; d.active = true;
d.notes = "woitemlabor The quick brown fox jumped over the six lazy dogs!"; d.notes = "woitemlabor The quick brown fox jumped over the six lazy dogs!";
d.wiki = "# woitemlabor test wiki"; d.wiki = "# woitemlabor test wiki";
d.workOrderItemId = WorkOrderItemId; d.workOrderItemId = WorkOrderItem1Id;
//Tags //Tags
dTagsArray = new JArray(); dTagsArray = new JArray();
@@ -92,14 +92,14 @@ namespace raven_integration
a = await Util.PostAsync("workorders/items/labors", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); a = await Util.PostAsync("workorders/items/labors", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long WorkOrderItemLaborId1 = a.ObjectResponse["data"]["id"].Value<long>(); dynamic dLaborOne = a.ObjectResponse["data"];
//TWO //TWO
d = new JObject(); d = new JObject();
d.active = true; d.active = true;
d.notes = "woitemlabor2 The quick brown fox jumped over the six lazy dogs!"; d.notes = "woitemlabor2 The quick brown fox jumped over the six lazy dogs!";
d.wiki = "# woitemlabor2 test wiki"; d.wiki = "# woitemlabor2 test wiki";
d.workOrderItemId = WorkOrderItemId; d.workOrderItemId = WorkOrderItem1Id;
//Tags //Tags
dTagsArray = new JArray(); dTagsArray = new JArray();
@@ -112,7 +112,106 @@ namespace raven_integration
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long WorkOrderItemLaborId2 = a.ObjectResponse["data"]["id"].Value<long>(); long WorkOrderItemLaborId2 = a.ObjectResponse["data"]["id"].Value<long>();
#endregion create first woitem
#region CREATE Second woitem
/////////////////////////////////////////
// Second woitem
//
//CREATE WOITEM-2
d = new JObject();
d.active = true;
d.notes = "woitem The quick brown fox jumped over the six lazy dogs!";
d.wiki = "# woitem test wiki";
d.workOrderId = WorkOrderId;
//Tags
dTagsArray = new JArray();
dTagsArray.Add("woitem-Red");
dTagsArray.Add("woitem-green");
dTagsArray.Add("woitem-blue");
d.tags = dTagsArray;
a = await Util.PostAsync("workorders/items", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
long WorkOrderItem2Id = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE WOITEMPART-2
d = new JObject();
d.active = true;
d.notes = "woitempart The quick brown fox jumped over the six lazy dogs!";
d.wiki = "# woitempart test wiki";
d.workOrderItemId = WorkOrderItem2Id;
//Tags
dTagsArray = new JArray();
dTagsArray.Add("woitempart-Red");
dTagsArray.Add("woitempart-green");
dTagsArray.Add("woitempart-blue");
d.tags = dTagsArray;
a = await Util.PostAsync("workorders/items/parts", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
//CREATE WOITEMLABOR(S)-2
//ONE-2
d = new JObject();
d.active = true;
d.notes = "woitemlabor The quick brown fox jumped over the six lazy dogs!";
d.wiki = "# woitemlabor test wiki";
d.workOrderItemId = WorkOrderItem2Id;
//Tags
dTagsArray = new JArray();
dTagsArray.Add("woitemlabor-Red");
dTagsArray.Add("woitemlabor-green");
dTagsArray.Add("woitemlabor-blue");
d.tags = dTagsArray;
a = await Util.PostAsync("workorders/items/labors", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
//TWO-2
d = new JObject();
d.active = true;
d.notes = "woitemlabor2 The quick brown fox jumped over the six lazy dogs!";
d.wiki = "# woitemlabor2 test wiki";
d.workOrderItemId = WorkOrderItem2Id;
//Tags
dTagsArray = new JArray();
dTagsArray.Add("woitemlabor-Red");
dTagsArray.Add("woitemlabor-green");
dTagsArray.Add("woitemlabor-blue");
d.tags = dTagsArray;
a = await Util.PostAsync("workorders/items/labors", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
#endregion create second woitem
/////////////////////////////////////////////////////////////////////////
//UPDATES
//
dLaborOne.notes = "TestUpdateNotes";
a = await Util.PutAsync("workorders/items/labors", await Util.GetTokenAsync("manager", "l3tm3in"), dLaborOne.ToString());
Util.ValidateDataReturnResponseOk(a);
//todo: update labor1
//todo: update part1
//todo: update woitem1
//todo: update workorder
@@ -124,82 +223,84 @@ namespace raven_integration
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
a.ObjectResponse["data"]["notes"].Value<string>().Should().Be("WOHEADER The quick brown fox jumped over the six lazy dogs!"); a.ObjectResponse["data"]["notes"].Value<string>().Should().Be("WOHEADER The quick brown fox jumped over the six lazy dogs!");
/* //todo: confirm entire graph exists by checking each level
{
"data": { /*
"id": 1, {
"concurrencyToken": 8722459, "data": {
"serial": 1, "id": 1,
"active": true, "concurrencyToken": 8722459,
"notes": "WOHEADER The quick brown fox jumped over the six lazy dogs!", "serial": 1,
"wiki": "# WOHEADER test wiki", "active": true,
"customFields": null, "notes": "WOHEADER The quick brown fox jumped over the six lazy dogs!",
"tags": [ "wiki": "# WOHEADER test wiki",
"wo-red", "customFields": null,
"wo-green", "tags": [
"wo-blue" "wo-red",
], "wo-green",
"items": [ "wo-blue"
{ ],
"id": 1, "items": [
"concurrencyToken": 8722472, {
"notes": "woitem The quick brown fox jumped over the six lazy dogs!", "id": 1,
"wiki": "# woitem test wiki", "concurrencyToken": 8722472,
"customFields": null, "notes": "woitem The quick brown fox jumped over the six lazy dogs!",
"tags": [ "wiki": "# woitem test wiki",
"woitem-red", "customFields": null,
"woitem-green", "tags": [
"woitem-blue" "woitem-red",
], "woitem-green",
"workOrderId": 1, "woitem-blue"
"labors": [ ],
{ "workOrderId": 1,
"id": 1, "labors": [
"concurrencyToken": 8722486, {
"notes": "woitemlabor The quick brown fox jumped over the six lazy dogs!", "id": 1,
"wiki": "# woitemlabor test wiki", "concurrencyToken": 8722486,
"customFields": null, "notes": "woitemlabor The quick brown fox jumped over the six lazy dogs!",
"tags": [ "wiki": "# woitemlabor test wiki",
"woitemlabor-red", "customFields": null,
"woitemlabor-green", "tags": [
"woitemlabor-blue" "woitemlabor-red",
], "woitemlabor-green",
"workOrderItemId": 1 "woitemlabor-blue"
}, ],
{ "workOrderItemId": 1
"id": 2, },
"concurrencyToken": 8722493, {
"notes": "woitemlabor2 The quick brown fox jumped over the six lazy dogs!", "id": 2,
"wiki": "# woitemlabor2 test wiki", "concurrencyToken": 8722493,
"customFields": null, "notes": "woitemlabor2 The quick brown fox jumped over the six lazy dogs!",
"tags": [ "wiki": "# woitemlabor2 test wiki",
"woitemlabor-red", "customFields": null,
"woitemlabor-green", "tags": [
"woitemlabor-blue" "woitemlabor-red",
], "woitemlabor-green",
"workOrderItemId": 1 "woitemlabor-blue"
} ],
], "workOrderItemId": 1
"parts": [ }
{ ],
"id": 1, "parts": [
"concurrencyToken": 8722479, {
"notes": "woitempart The quick brown fox jumped over the six lazy dogs!", "id": 1,
"wiki": "# woitempart test wiki", "concurrencyToken": 8722479,
"customFields": null, "notes": "woitempart The quick brown fox jumped over the six lazy dogs!",
"tags": [ "wiki": "# woitempart test wiki",
"woitempart-red", "customFields": null,
"woitempart-green", "tags": [
"woitempart-blue" "woitempart-red",
], "woitempart-green",
"workOrderItemId": 1 "woitempart-blue"
} ],
] "workOrderItemId": 1
} }
] ]
} }
} ]
*/ }
}
*/
// //UPDATE // //UPDATE
@@ -216,6 +317,9 @@ namespace raven_integration
// a.ObjectResponse["data"]["name"].Value<string>().Should().Be(d.name.ToString()); // a.ObjectResponse["data"]["name"].Value<string>().Should().Be(d.name.ToString());
// uint concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>(); // uint concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
//todo: delete extra labor
//todo: delete woitem
//todo: delete wo outright
// //DELETE // //DELETE
// a = await Util.DeleteAsync("WorkOrder/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in")); // a = await Util.DeleteAsync("WorkOrder/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));