This commit is contained in:
@@ -56,7 +56,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.workOrderId = WorkOrderId;
|
d.workOrderItemId = WorkOrderItemId;
|
||||||
|
|
||||||
//Tags
|
//Tags
|
||||||
dTagsArray = new JArray();
|
dTagsArray = new JArray();
|
||||||
@@ -73,40 +73,31 @@ namespace raven_integration
|
|||||||
//RETRIEVE
|
//RETRIEVE
|
||||||
|
|
||||||
//Get one
|
//Get one
|
||||||
a = await Util.GetAsync("WorkOrder/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
a = await Util.GetAsync("workorders/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
a.ObjectResponse["data"]["name"].Value<string>().Should().Be(d.name.ToString());
|
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(d.notes.ToString());
|
|
||||||
var returnedTags = ((JArray)a.ObjectResponse["data"]["tags"]);
|
|
||||||
returnedTags.Count.Should().Be(7);
|
|
||||||
returnedTags[0].Value<string>().Should().Be("red-tag");
|
|
||||||
returnedTags[1].Value<string>().Should().Be("orange-is-the-new-black");
|
|
||||||
returnedTags[2].Value<string>().Should().Be("yellow");
|
|
||||||
returnedTags[3].Value<string>().Should().Be("green");
|
|
||||||
returnedTags[4].Value<string>().Should().Be("blue");
|
|
||||||
returnedTags[5].Value<string>().Should().Be("indigo");
|
|
||||||
returnedTags[6].Value<string>().Should().Be("violet-tag");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//UPDATE
|
|
||||||
|
|
||||||
d.name = Util.Uniquify("UPDATED VIA PUT TEST WorkOrder");
|
// //UPDATE
|
||||||
|
|
||||||
d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
// d.name = Util.Uniquify("UPDATED VIA PUT TEST WorkOrder");
|
||||||
a = await Util.PutAsync("WorkOrder/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
|
||||||
Util.ValidateHTTPStatusCode(a, 200);
|
|
||||||
|
|
||||||
//check PUT worked
|
// d.concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||||
a = await Util.GetAsync("WorkOrder/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
// a = await Util.PutAsync("WorkOrder/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||||
Util.ValidateNoErrorInResponse(a);
|
// Util.ValidateHTTPStatusCode(a, 200);
|
||||||
a.ObjectResponse["data"]["name"].Value<string>().Should().Be(d.name.ToString());
|
|
||||||
uint concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
// //check PUT worked
|
||||||
|
// a = await Util.GetAsync("WorkOrder/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
|
// Util.ValidateNoErrorInResponse(a);
|
||||||
|
// a.ObjectResponse["data"]["name"].Value<string>().Should().Be(d.name.ToString());
|
||||||
|
// uint concurrencyToken = a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||||
|
|
||||||
|
|
||||||
//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"));
|
||||||
Util.ValidateHTTPStatusCode(a, 204);
|
// Util.ValidateHTTPStatusCode(a, 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -114,131 +105,131 @@ namespace raven_integration
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// Test not found
|
// /// Test not found
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async void GetNonExistentItemShouldError()
|
// public async void GetNonExistentItemShouldError()
|
||||||
{
|
// {
|
||||||
//Get non existant
|
// //Get non existant
|
||||||
//Should return status code 404, api error code 2010
|
// //Should return status code 404, api error code 2010
|
||||||
ApiResponse a = await Util.GetAsync("WorkOrder/999999", await Util.GetTokenAsync("manager", "l3tm3in"));
|
// ApiResponse a = await Util.GetAsync("WorkOrder/999999", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
Util.ValidateResponseNotFound(a);
|
// Util.ValidateResponseNotFound(a);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// Test bad modelstate
|
// /// Test bad modelstate
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async void GetBadModelStateShouldError()
|
// public async void GetBadModelStateShouldError()
|
||||||
{
|
// {
|
||||||
//Get non existant
|
// //Get non existant
|
||||||
//Should return status code 400, api error code 2200 and a first target in details of "id"
|
// //Should return status code 400, api error code 2200 and a first target in details of "id"
|
||||||
ApiResponse a = await Util.GetAsync("WorkOrder/2q2", await Util.GetTokenAsync("manager", "l3tm3in"));
|
// ApiResponse a = await Util.GetAsync("WorkOrder/2q2", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
Util.ValidateBadModelStateResponse(a, "id");
|
// Util.ValidateBadModelStateResponse(a, "id");
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// Test server exception
|
// /// Test server exception
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async void ServerExceptionShouldErrorPropertly()
|
// public async void ServerExceptionShouldErrorPropertly()
|
||||||
{
|
// {
|
||||||
//Get non existant
|
// //Get non existant
|
||||||
//Should return status code 400, api error code 2200 and a first target in details of "id"
|
// //Should return status code 400, api error code 2200 and a first target in details of "id"
|
||||||
ApiResponse a = await Util.GetAsync("WorkOrder/exception", await Util.GetTokenAsync("manager", "l3tm3in"));
|
// ApiResponse a = await Util.GetAsync("WorkOrder/exception", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
Util.ValidateServerExceptionResponse(a);
|
// Util.ValidateServerExceptionResponse(a);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// Test server alt exception
|
// /// Test server alt exception
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async void ServerAltExceptionShouldErrorPropertly()
|
// public async void ServerAltExceptionShouldErrorPropertly()
|
||||||
{
|
// {
|
||||||
//Get non existant
|
// //Get non existant
|
||||||
//Should return status code 400, api error code 2200 and a first target in details of "id"
|
// //Should return status code 400, api error code 2200 and a first target in details of "id"
|
||||||
ApiResponse a = await Util.GetAsync("WorkOrder/altexception", await Util.GetTokenAsync("manager", "l3tm3in"));
|
// ApiResponse a = await Util.GetAsync("WorkOrder/altexception", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
Util.ValidateServerExceptionResponse(a);
|
// Util.ValidateServerExceptionResponse(a);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
///
|
// ///
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async void PutConcurrencyViolationShouldFail()
|
// public async void PutConcurrencyViolationShouldFail()
|
||||||
{
|
// {
|
||||||
|
|
||||||
//CREATE
|
// //CREATE
|
||||||
|
|
||||||
dynamic w2 = new JObject();
|
// dynamic w2 = new JObject();
|
||||||
w2.name = Util.Uniquify("PutConcurrencyViolationShouldFail");
|
// w2.name = Util.Uniquify("PutConcurrencyViolationShouldFail");
|
||||||
w2.dollarAmount = 2.22m;
|
// w2.dollarAmount = 2.22m;
|
||||||
w2.active = true;
|
// w2.active = true;
|
||||||
w2.usertype = 1;
|
// w2.usertype = 1;
|
||||||
|
|
||||||
w2.notes = "blah";
|
// w2.notes = "blah";
|
||||||
w2.customFields = Util.WorkOrderRequiredCustomFieldsJsonString();
|
// w2.customFields = Util.WorkOrderRequiredCustomFieldsJsonString();
|
||||||
|
|
||||||
|
|
||||||
ApiResponse r2 = await Util.PostAsync("WorkOrder", await Util.GetTokenAsync("manager", "l3tm3in"), w2.ToString());
|
// ApiResponse r2 = await Util.PostAsync("WorkOrder", await Util.GetTokenAsync("manager", "l3tm3in"), w2.ToString());
|
||||||
Util.ValidateDataReturnResponseOk(r2);
|
// Util.ValidateDataReturnResponseOk(r2);
|
||||||
long w2Id = r2.ObjectResponse["data"]["id"].Value<long>();
|
// long w2Id = r2.ObjectResponse["data"]["id"].Value<long>();
|
||||||
uint OriginalConcurrencyToken = r2.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
// uint OriginalConcurrencyToken = r2.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//UPDATE
|
// //UPDATE
|
||||||
//PUT
|
// //PUT
|
||||||
|
|
||||||
w2.name = Util.Uniquify("PutConcurrencyViolationShouldFail UPDATE VIA PUT ");
|
// w2.name = Util.Uniquify("PutConcurrencyViolationShouldFail UPDATE VIA PUT ");
|
||||||
|
|
||||||
w2.concurrencyToken = OriginalConcurrencyToken - 1;//bad token
|
// w2.concurrencyToken = OriginalConcurrencyToken - 1;//bad token
|
||||||
ApiResponse PUTTestResponse = await Util.PutAsync("WorkOrder/" + w2Id.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), w2.ToString());
|
// ApiResponse PUTTestResponse = await Util.PutAsync("WorkOrder/" + w2Id.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), w2.ToString());
|
||||||
Util.ValidateConcurrencyError(PUTTestResponse);
|
// Util.ValidateConcurrencyError(PUTTestResponse);
|
||||||
|
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
///
|
// ///
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async void PatchConcurrencyViolationShouldFail()
|
// public async void PatchConcurrencyViolationShouldFail()
|
||||||
{
|
// {
|
||||||
|
|
||||||
//CREATE
|
// //CREATE
|
||||||
|
|
||||||
dynamic w2 = new JObject();
|
// dynamic w2 = new JObject();
|
||||||
w2.name = Util.Uniquify("PatchConcurrencyViolationShouldFail");
|
// w2.name = Util.Uniquify("PatchConcurrencyViolationShouldFail");
|
||||||
w2.notes = "blah";
|
// w2.notes = "blah";
|
||||||
w2.customFields = Util.WorkOrderRequiredCustomFieldsJsonString();
|
// w2.customFields = Util.WorkOrderRequiredCustomFieldsJsonString();
|
||||||
w2.dollarAmount = 2.22m;
|
// w2.dollarAmount = 2.22m;
|
||||||
w2.active = true;
|
// w2.active = true;
|
||||||
w2.usertype = 1;
|
// w2.usertype = 1;
|
||||||
w2.customFields = Util.WorkOrderRequiredCustomFieldsJsonString();
|
// w2.customFields = Util.WorkOrderRequiredCustomFieldsJsonString();
|
||||||
|
|
||||||
ApiResponse r2 = await Util.PostAsync("WorkOrder", await Util.GetTokenAsync("manager", "l3tm3in"), w2.ToString());
|
// ApiResponse r2 = await Util.PostAsync("WorkOrder", await Util.GetTokenAsync("manager", "l3tm3in"), w2.ToString());
|
||||||
Util.ValidateDataReturnResponseOk(r2);
|
// Util.ValidateDataReturnResponseOk(r2);
|
||||||
long w2Id = r2.ObjectResponse["data"]["id"].Value<long>();
|
// long w2Id = r2.ObjectResponse["data"]["id"].Value<long>();
|
||||||
uint OriginalConcurrencyToken = r2.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
// uint OriginalConcurrencyToken = r2.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||||
|
|
||||||
|
|
||||||
//PATCH
|
// //PATCH
|
||||||
var newName = Util.Uniquify("PutConcurrencyViolationShouldFail UPDATED VIA PATCH");
|
// var newName = Util.Uniquify("PutConcurrencyViolationShouldFail UPDATED VIA PATCH");
|
||||||
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
|
// string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
|
||||||
ApiResponse PATCHTestResponse = await Util.PatchAsync("WorkOrder/" + w2Id.ToString() + "/" + (OriginalConcurrencyToken - 1).ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), patchJson);
|
// ApiResponse PATCHTestResponse = await Util.PatchAsync("WorkOrder/" + w2Id.ToString() + "/" + (OriginalConcurrencyToken - 1).ToString(), await Util.GetTokenAsync("manager", "l3tm3in"), patchJson);
|
||||||
Util.ValidateConcurrencyError(PATCHTestResponse);
|
// Util.ValidateConcurrencyError(PATCHTestResponse);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user