This commit is contained in:
@@ -362,7 +362,7 @@ namespace raven_integration
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
|
||||
var w = a.ObjectResponse["data"];
|
||||
w["items"].Count().Should().Be(2);
|
||||
w["items"].Count().Should().Be(2);
|
||||
|
||||
var woitem1 = w["items"].FirstOrDefault(z => (long)z["id"] == WorkOrderItem1Id);
|
||||
woitem1["labors"].Count().Should().Be(2);
|
||||
@@ -377,6 +377,169 @@ namespace raven_integration
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Test all CRUD routes for a WorkOrder
|
||||
/// Build up graph, update graph, remove graph bit by bit
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void DuplicateWorks()
|
||||
{
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// CREATE
|
||||
//
|
||||
dynamic d = new JObject();
|
||||
d.active = true;
|
||||
d.notes = "WOHEADER DuplicateWorks";
|
||||
d.wiki = "DuplicateWorks integration test";
|
||||
|
||||
ApiResponse a = await Util.PostAsync("workorders", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
dynamic WorkorderToUpdate = a.ObjectResponse["data"];
|
||||
long WorkOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
#region CREATE first woitem
|
||||
|
||||
//CREATE WOITEM 1
|
||||
d = new JObject();
|
||||
d.active = true;
|
||||
d.notes = "woitem DuplicateWorks";
|
||||
d.wiki = "# woitem test wiki";
|
||||
d.workOrderId = WorkOrderId;
|
||||
|
||||
a = await Util.PostAsync("workorders/items", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
dynamic WorkOrderItemToUpdate = a.ObjectResponse["data"];
|
||||
long WorkOrderItem1Id = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
//CREATE WOITEMPART
|
||||
d = new JObject();
|
||||
d.active = true;
|
||||
d.notes = "woitempart DuplicateWorks";
|
||||
d.wiki = "# woitempart test wiki";
|
||||
d.workOrderItemId = WorkOrderItem1Id;
|
||||
|
||||
a = await Util.PostAsync("workorders/items/parts", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
dynamic dPartToUpdate = a.ObjectResponse["data"];
|
||||
long PartId = (long)a.ObjectResponse["data"]["id"];
|
||||
|
||||
//CREATE TWO WOITEMLABORS
|
||||
//ONE
|
||||
d = new JObject();
|
||||
d.active = true;
|
||||
d.notes = "woitemlabor DuplicateWorks";
|
||||
d.wiki = "# woitemlabor test wiki";
|
||||
d.workOrderItemId = WorkOrderItem1Id;
|
||||
|
||||
|
||||
a = await Util.PostAsync("workorders/items/labors", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
dynamic dLaborOne = a.ObjectResponse["data"];
|
||||
long Labor1Id = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
//TWO
|
||||
d = new JObject();
|
||||
d.active = true;
|
||||
d.notes = "woitemlabor2 DuplicateWorks";
|
||||
d.wiki = "# woitemlabor2 test wiki";
|
||||
d.workOrderItemId = WorkOrderItem1Id;
|
||||
|
||||
|
||||
a = await Util.PostAsync("workorders/items/labors", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
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-2 DuplicateWorks";
|
||||
d.wiki = "# woitem test wiki";
|
||||
d.workOrderId = WorkOrderId;
|
||||
|
||||
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 = "woitem-2-partDuplicateWorks";
|
||||
d.wiki = "# woitempart test wiki";
|
||||
d.workOrderItemId = WorkOrderItem2Id;
|
||||
|
||||
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 = "woitem-2-laborDuplicateWorks";
|
||||
d.wiki = "# woitemlabor test wiki";
|
||||
d.workOrderItemId = WorkOrderItem2Id;
|
||||
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 = "woitem-2-labor2DuplicateWorks";
|
||||
d.wiki = "# woitemlabor2 test wiki";
|
||||
d.workOrderItemId = WorkOrderItem2Id;
|
||||
a = await Util.PostAsync("workorders/items/labors", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
|
||||
#endregion create second woitem
|
||||
|
||||
|
||||
|
||||
#region Duplicate and Validate
|
||||
|
||||
//DUPLICATE - should make a copy of above, save and return entire object graph just like a get operation
|
||||
a = await Util.PostAsync("workorders/duplicate/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
long DuplicateWorkOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
DuplicateWorkOrderId.Should().NotBe(WorkOrderId);
|
||||
|
||||
// //RETRIEVE WORKORDER AND VALIDATE ENTIRE
|
||||
// a = await Util.GetAsync("workorders/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||
// Util.ValidateDataReturnResponseOk(a);
|
||||
|
||||
var w = a.ObjectResponse["data"];
|
||||
w["items"].Count().Should().Be(2);
|
||||
((string)w["notes"]).Should().Be("WOHEADER DuplicateWorks");
|
||||
|
||||
|
||||
var woitem1 = w["items"].FirstOrDefault(z => (long)z["id"] == WorkOrderItem1Id);
|
||||
woitem1["labors"].Count().Should().Be(2);
|
||||
woitem1["parts"].Count().Should().Be(1);
|
||||
((string)woitem1["notes"]).Should().Be("woitem DuplicateWorks");
|
||||
((string)woitem1["labors"].FirstOrDefault(z => (long)z["id"] == Labor1Id)["notes"]).Should().Be("woitemlabor DuplicateWorks");
|
||||
((string)woitem1["parts"].FirstOrDefault(z => (long)z["id"] == PartId)["notes"]).Should().Be("woitempart DuplicateWorks");
|
||||
|
||||
var woitem2 = w["items"].FirstOrDefault(z => (long)z["id"] == WorkOrderItem2Id);
|
||||
woitem2["labors"].Count().Should().Be(2);
|
||||
woitem2["parts"].Count().Should().Be(1);
|
||||
((string)woitem2["notes"]).Should().Be("woitem-2 DuplicateWorks");
|
||||
woitem2["labors"].FirstOrDefault(z => (string)z["notes"] == "woitem-2-labor2DuplicateWorks").Should().NotBeNull();
|
||||
woitem2["parts"].FirstOrDefault(z => (string)z["notes"] == "woitem-2-partDuplicateWorks").Should().NotBeNull();
|
||||
|
||||
#endregion validate entire
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
|
||||
Reference in New Issue
Block a user