This commit is contained in:
2018-06-28 23:41:48 +00:00
commit 515bd37952
256 changed files with 29890 additions and 0 deletions

View File

@@ -0,0 +1,227 @@
using System;
using Xunit;
using Newtonsoft.Json.Linq;
using FluentAssertions;
namespace raven_integration
{
public class WidgetCrud
{
/// <summary>
/// Test all CRUD routes for a widget
/// </summary>
[Fact]
public async void CRUD()
{
/*
{
"id": 0,
"name": "string",
"created": "2018-02-09T16:45:56.057Z",
"dollarAmount": 0,
"active": true,
"roles": 0
}
*/
//CREATE
dynamic w1 = new JObject();
w1.name = Util.Uniquify("First Test WIDGET");
w1.created = DateTime.Now.ToString();
w1.dollarAmount = 1.11m;
w1.active = true;
w1.roles = 0;
ApiResponse r1 = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w1.ToString());
Util.ValidateDataReturnResponseOk(r1);
long w1Id = r1.ObjectResponse["result"]["id"].Value<long>();
dynamic w2 = new JObject();
w2.name = Util.Uniquify("Second Test WIDGET");
w2.created = DateTime.Now.ToString();
w2.dollarAmount = 2.22m;
w2.active = true;
w2.roles = 0;
ApiResponse r2 = await Util.PostAsync("Widget", await Util.GetTokenAsync( "manager", "l3tm3in"), w2.ToString());
Util.ValidateDataReturnResponseOk(r2);
long w2Id = r2.ObjectResponse["result"]["id"].Value<long>();
//RETRIEVE
//Get one
ApiResponse r3 = await Util.GetAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync( "manager", "l3tm3in"));
Util.ValidateDataReturnResponseOk(r3);
r3.ObjectResponse["result"]["name"].Value<string>().Should().Be(w2.name.ToString());
//UPDATE
//PUT
//update w2id
w2.name = Util.Uniquify("UPDATED VIA PUT SECOND TEST WIDGET");
w2.OwnerId = 1;
w2.concurrencyToken = r2.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
ApiResponse PUTTestResponse = await Util.PutAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync( "manager", "l3tm3in"), w2.ToString());
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
//check PUT worked
ApiResponse checkPUTWorked = await Util.GetAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync( "manager", "l3tm3in"));
Util.ValidateNoErrorInResponse(checkPUTWorked);
checkPUTWorked.ObjectResponse["result"]["name"].Value<string>().Should().Be(w2.name.ToString());
uint concurrencyToken = PUTTestResponse.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
//PATCH
var newName = Util.Uniquify("UPDATED VIA PATCH SECOND TEST WIDGET");
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
ApiResponse PATCHTestResponse = await Util.PatchAsync("Widget/" + w2Id.ToString() + "/" + concurrencyToken.ToString(), await Util.GetTokenAsync( "manager", "l3tm3in"), patchJson);
Util.ValidateHTTPStatusCode(PATCHTestResponse, 200);
//check PATCH worked
ApiResponse checkPATCHWorked = await Util.GetAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync( "manager", "l3tm3in"));
Util.ValidateNoErrorInResponse(checkPATCHWorked);
checkPATCHWorked.ObjectResponse["result"]["name"].Value<string>().Should().Be(newName);
//DELETE
ApiResponse DELETETestResponse = await Util.DeleteAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync( "manager", "l3tm3in"));
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
}
/// <summary>
/// Test not found
/// </summary>
[Fact]
public async void GetNonExistentItemShouldError()
{
//Get non existant
//Should return status code 404, api error code 2010
ApiResponse a = await Util.GetAsync("Widget/999999", await Util.GetTokenAsync( "manager", "l3tm3in"));
Util.ValidateResponseNotFound(a);
}
/// <summary>
/// Test bad modelstate
/// </summary>
[Fact]
public async void GetBadModelStateShouldError()
{
//Get non existant
//Should return status code 400, api error code 2200 and a first target in details of "id"
ApiResponse a = await Util.GetAsync("Widget/2q2", await Util.GetTokenAsync( "manager", "l3tm3in"));
Util.ValidateBadModelStateResponse(a, "id");
}
/// <summary>
/// Test server exception
/// </summary>
[Fact]
public async void ServerExceptionShouldErrorPropertly()
{
//Get non existant
//Should return status code 400, api error code 2200 and a first target in details of "id"
ApiResponse a = await Util.GetAsync("Widget/exception", await Util.GetTokenAsync( "manager", "l3tm3in"));
Util.ValidateServerExceptionResponse(a);
}
/// <summary>
/// Test server alt exception
/// </summary>
[Fact]
public async void ServerAltExceptionShouldErrorPropertly()
{
//Get non existant
//Should return status code 400, api error code 2200 and a first target in details of "id"
ApiResponse a = await Util.GetAsync("Widget/altexception", await Util.GetTokenAsync( "manager", "l3tm3in"));
Util.ValidateServerExceptionResponse(a);
}
/// <summary>
///
/// </summary>
[Fact]
public async void PutConcurrencyViolationShouldFail()
{
//CREATE
dynamic w2 = new JObject();
w2.name = Util.Uniquify("PutConcurrencyViolationShouldFail");
w2.created = DateTime.Now.ToString();
w2.dollarAmount = 2.22m;
w2.active = true;
w2.roles = 0;
ApiResponse r2 = await Util.PostAsync("Widget", await Util.GetTokenAsync( "manager", "l3tm3in"), w2.ToString());
Util.ValidateDataReturnResponseOk(r2);
long w2Id = r2.ObjectResponse["result"]["id"].Value<long>();
uint OriginalConcurrencyToken = r2.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
//UPDATE
//PUT
w2.name = Util.Uniquify("PutConcurrencyViolationShouldFail UPDATE VIA PUT ");
w2.OwnerId = 1;
w2.concurrencyToken = OriginalConcurrencyToken - 1;//bad token
ApiResponse PUTTestResponse = await Util.PutAsync("Widget/" + w2Id.ToString(), await Util.GetTokenAsync( "manager", "l3tm3in"), w2.ToString());
Util.ValidateConcurrencyError(PUTTestResponse);
}
/// <summary>
///
/// </summary>
[Fact]
public async void PatchConcurrencyViolationShouldFail()
{
//CREATE
dynamic w2 = new JObject();
w2.name = Util.Uniquify("PatchConcurrencyViolationShouldFail");
w2.created = DateTime.Now.ToString();
w2.dollarAmount = 2.22m;
w2.active = true;
w2.roles = 0;
ApiResponse r2 = await Util.PostAsync("Widget", await Util.GetTokenAsync( "manager", "l3tm3in"), w2.ToString());
Util.ValidateDataReturnResponseOk(r2);
long w2Id = r2.ObjectResponse["result"]["id"].Value<long>();
uint OriginalConcurrencyToken = r2.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
//PATCH
var newName = Util.Uniquify("PutConcurrencyViolationShouldFail UPDATED VIA PATCH");
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
ApiResponse PATCHTestResponse = await Util.PatchAsync("Widget/" + w2Id.ToString() + "/" + (OriginalConcurrencyToken - 1).ToString(), await Util.GetTokenAsync( "manager", "l3tm3in"), patchJson);
Util.ValidateConcurrencyError(PATCHTestResponse);
}
//==================================================
}//eoc
}//eons

View File

@@ -0,0 +1,74 @@
using System;
using Xunit;
using Newtonsoft.Json.Linq;
using FluentAssertions;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Collections.Concurrent;
namespace raven_integration
{
public class WidgetLists
{
/// <summary>
///
/// </summary>
[Fact]
public async void PickListSearchRouteShouldWorkAsExpected()
{
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("Soft PickListSearchRouteShouldWorkAsExpected");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
ApiResponse r1 = await Util.PostAsync("Widget", await Util.GetTokenAsync( "manager", "l3tm3in"), d.ToString());
Util.ValidateDataReturnResponseOk(r1);
//Get all
ApiResponse a = await Util.GetAsync("Widget/picklist?Offset=2&Limit=3&q=%25of%25", await Util.GetTokenAsync( "InventoryLimited"));
Util.ValidateDataReturnResponseOk(a);
Util.ValidateHTTPStatusCode(a, 200);
((JArray)a.ObjectResponse["result"]).Count.Should().BeGreaterThan(0);
}
/// <summary>
/// Paging test
/// </summary>
[Fact]
public async void PagingShouldWorkAsExpected()
{
//Get all
ApiResponse a = await Util.GetAsync("Widget/list?Offset=2&Limit=3", await Util.GetTokenAsync( "manager", "l3tm3in"));
Util.ValidateDataReturnResponseOk(a);
Util.ValidateHTTPStatusCode(a, 200);
//assert aAll contains at least two records
((JArray)a.ObjectResponse["result"]).Count.Should().Be(3);
JObject jp = (JObject)a.ObjectResponse["paging"];
jp["count"].Value<long>().Should().BeGreaterThan(5);
jp["offset"].Value<int>().Should().Be(2);
jp["limit"].Value<int>().Should().Be(3);
jp["first"].Value<string>().Should().EndWith("&pageSize=3");
jp["previous"].Value<string>().Should().EndWith("&pageSize=3");
jp["next"].Value<string>().Should().EndWith("&pageSize=3");
jp["last"].Value<string>().Should().EndWith("&pageSize=3");
}
//==================================================
}//eoc
}//eons

View File

@@ -0,0 +1,261 @@
using System;
using Xunit;
using Newtonsoft.Json.Linq;
using FluentAssertions;
using System.Collections.Generic;
using System.Collections.Concurrent;
namespace raven_integration
{
// [Collection("APICOLLECTION")]
public class WidgetRights
{
/// <summary>
/// Test not authorized error return
/// </summary>
[Fact]
public async void ServerShouldNotAllowUnauthenticatedAccess()
{
ApiResponse a = await Util.GetAsync("Widget/list");
Util.ValidateHTTPStatusCode(a, 401);
}
/// <summary>
/// Test insufficient read rights error return
/// </summary>
[Fact]
public async void ServerShouldNotAllowReadUnauthorizedAccess()
{
ApiResponse a = await Util.GetAsync("Widget/list", await Util.GetTokenAsync( "OpsAdminFull"));
//2004 unauthorized
Util.ValidateErrorCodeResponse(a, 2004, 401);
}
/// <summary>
/// Test insufficient create rights error return
/// </summary>
[Fact]
public async void ServerShouldNotAllowCreateUnauthorizedAccess()
{
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("ServerShouldNotAllowCreateUnauthorizedAccess TEST WIDGET");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//BizAdminLimited user should not be able to create a widget, only read them
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "BizAdminLimited"), d.ToString());
//2004 unauthorized
Util.ValidateErrorCodeResponse(a, 2004, 401);
}
/// <summary>
/// Test owner rights to modify
/// </summary>
[Fact]
public async void ServerShouldAllowOwnerOnlyRightsUserToPatchOwn()
{
// TECH FULL has owner only rights to widget
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("ServerShouldAllowOwnerOnlyRightsUserToPatchOwn TEST WIDGET");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "TechFull"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
long Id = a.ObjectResponse["result"]["id"].Value<long>();
uint OriginalConcurrencyToken = a.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
//Now attempt to modify it via patch
var newName = Util.Uniquify("ServerShouldAllowOwnerOnlyRightsUserToPatchOwn - UPDATED TEST WIDGET");
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
a = await Util.PatchAsync("Widget/" + Id.ToString() + "/" + OriginalConcurrencyToken.ToString(), await Util.GetTokenAsync( "TechFull"), patchJson);
Util.ValidateHTTPStatusCode(a, 200);
}
/// <summary>
/// Test owner rights fails to modify other creator object
/// </summary>
[Fact]
public async void ServerShouldDisAllowOwnerOnlyRightsUserToPatchNonOwned()
{
// TECH FULL has owner only rights to widget
//INVENTORY FULL has full rights to widget
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("ServerShouldDisAllowOwnerOnlyRightsUserToPatchNonOwned TEST WIDGET");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
long Id = a.ObjectResponse["result"]["id"].Value<long>();
uint OriginalConcurrencyToken = a.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
//Now TechFullAuthToken attempt to modify it via patch
var newName = Util.Uniquify("ServerShouldDisAllowOwnerOnlyRightsUserToPatchNonOwned - UPDATED TEST WIDGET");
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
a = await Util.PatchAsync("Widget/" + Id.ToString() + "/" + OriginalConcurrencyToken.ToString(), await Util.GetTokenAsync( "TechFull"), patchJson);
//2004 unauthorized expected
Util.ValidateErrorCodeResponse(a, 2004, 401);
}
/// <summary>
/// Test owner rights to modify
/// </summary>
[Fact]
public async void ServerShouldAllowOwnerOnlyRightsUserToPutOwn()
{
// TECH FULL has owner only rights to widget
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("ServerShouldAllowOwnerOnlyRightsUserToPutOwn TEST WIDGET");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "TechFull"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
long Id = a.ObjectResponse["result"]["id"].Value<long>();
uint OriginalConcurrencyToken = a.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
//Now attempt to modify it via patch
var newName = Util.Uniquify("ServerShouldAllowOwnerOnlyRightsUserToPutOwn - UPDATED TEST WIDGET");
d.OwnerId = 1;
d.name = newName;
d.concurrencyToken = OriginalConcurrencyToken;
a = await Util.PutAsync("Widget/" + Id.ToString(), await Util.GetTokenAsync( "TechFull"), d.ToString());
Util.ValidateHTTPStatusCode(a, 200);
}
/// <summary>
/// Test owner rights fails to modify other creator object
/// </summary>
[Fact]
public async void ServerShouldDisAllowOwnerOnlyRightsUserToPutNonOwned()
{
// TECH FULL has owner only rights to widget
//INVENTORY FULL has full rights to widget
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("ServerShouldDisAllowOwnerOnlyRightsUserToPutNonOwned TEST WIDGET");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
long Id = a.ObjectResponse["result"]["id"].Value<long>();
//Now TechFullAuthToken attempt to modify it via patch
var newName = Util.Uniquify("ServerShouldDisAllowOwnerOnlyRightsUserToPutNonOwned - UPDATED TEST WIDGET");
d.name = newName;
a = await Util.PutAsync("Widget/" + Id.ToString(), await Util.GetTokenAsync( "TechFull"), d.ToString());
//2004 unauthorized expected
Util.ValidateErrorCodeResponse(a, 2004, 401);
}
/// <summary>
/// Test owner rights to delete
/// </summary>
[Fact]
public async void ServerShouldAllowOwnerOnlyRightsUserToDelete()
{
// TECH FULL has owner only rights to widget
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("ServerShouldAllowOwnerOnlyRightsUserToDelete TEST WIDGET");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "TechFull"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
long Id = a.ObjectResponse["result"]["id"].Value<long>();
//Now attempt to delete it
a = await Util.DeleteAsync("Widget/" + Id.ToString(), await Util.GetTokenAsync( "TechFull"));
Util.ValidateHTTPStatusCode(a, 204);
}
/// <summary>
/// Test owner rights fails to delete other creator object
/// </summary>
[Fact]
public async void ServerShouldDisAllowOwnerOnlyRightsUserToDeleteNonOwned()
{
// TECH FULL has owner only rights to widget
//INVENTORY FULL has full rights to widget
//CREATE
dynamic d = new JObject();
d.name = Util.Uniquify("ServerShouldDisAllowOwnerOnlyRightsUserToDeleteNonOwned TEST WIDGET");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
long Id = a.ObjectResponse["result"]["id"].Value<long>();
//Now attempt delete
a = await Util.DeleteAsync("Widget/" + Id.ToString(), await Util.GetTokenAsync( "TechFull"));
//2004 unauthorized expected
Util.ValidateErrorCodeResponse(a, 2004, 401);
}
//==================================================
}//eoc
}//eons

View File

@@ -0,0 +1,260 @@
using System;
using Xunit;
using Newtonsoft.Json.Linq;
using FluentAssertions;
using System.Collections.Generic;
using System.Collections.Concurrent;
namespace raven_integration
{
public class WidgetValidationTest
{
/// <summary>
/// Test business rule should be active on new
/// </summary>
[Fact]
public async void BusinessRuleNewShouldBeActiveShouldWork()
{
//CREATE attempt with broken rules
dynamic d = new JObject();
d.name = Util.Uniquify("ServerShouldDisAllowOwnerOnlyRightsUserToDeleteNonOwned TEST WIDGET");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = false;//<--- BROKEN RULE new widget must be active = true!!
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "Active", "InvalidValue");
}
/// <summary>
/// Test business rule name should be unique
/// </summary>
[Fact]
public async void BusinessRuleNameMustBeUnique()
{
//CREATE attempt with broken rules
dynamic d = new JObject();
d.name = Util.Uniquify("BusinessRuleNameMustBeUnique TEST WIDGET");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
//Now try to create again with same name
a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "Name", "NotUnique");
}
/// <summary>
///
/// </summary>
[Fact]
public async void BusinessRuleNameRequired()
{
dynamic d = new JObject();
d.name = "";
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "Name", "RequiredPropertyEmpty");
}
/// <summary>
///
/// </summary>
[Fact]
public async void BusinessRuleNameLengthExceeded()
{
dynamic d = new JObject();
d.name = new string('A', 256); ;
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "Name", "LengthExceeded", "255 max");
}
/// <summary>
///
/// </summary>
[Fact]
public async void BusinessRuleOwnerIdMustExistOnUpdate()
{
//CREATE attempt with broken rules
dynamic d = new JObject();
d.name = Util.Uniquify("BusinessRuleOwnerIdMustExistOnUpdate TEST WIDGET");
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
long Id = a.ObjectResponse["result"]["id"].Value<long>();
//Now put a change with no ownerId set
d.active = false;
a = await Util.PutAsync("Widget/" + Id.ToString(), await Util.GetTokenAsync( "InventoryFull"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "OwnerId", "RequiredPropertyEmpty");
}
/// <summary>
///
/// </summary>
[Fact]
public async void BusinessRuleStartDateWithoutEndDateShouldError()
{
dynamic d = new JObject();
d.name = Util.Uniquify("BusinessRuleStartDateWithoutEndDateShouldError TEST");
d.created = DateTime.Now.ToString();
d.startDate = d.created;
//NO END DATE ERRROR
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "EndDate", "RequiredPropertyEmpty");
}
/// <summary>
///
/// </summary>
[Fact]
public async void BusinessRuleEndDateWithoutStartDateShouldError()
{
dynamic d = new JObject();
d.name = Util.Uniquify("BusinessRuleEndDateWithoutStartDateShouldError TEST");
d.created = DateTime.Now.ToString();
d.endDate = d.created;
//NO START DATE ERRROR
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "StartDate", "RequiredPropertyEmpty");
}
/// <summary>
///
/// </summary>
[Fact]
public async void BusinessRuleEndDateBeforeStartDateShouldError()
{
dynamic d = new JObject();
d.name = Util.Uniquify("BusinessRuleEndDateBeforeStartDateShouldError TEST");
d.created = DateTime.Now.ToString();
d.startDate = DateTime.Now.ToString();
d.endDate = DateTime.Now.AddHours(-1).ToString();
//NO START DATE ERRROR
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 0;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "StartDate", "StartDateMustComeBeforeEndDate");
}
/// <summary>
///
/// </summary>
[Fact]
public async void BusinessRuleEnumInvalidShouldError()
{
dynamic d = new JObject();
d.name = Util.Uniquify("BusinessRuleEnumInvalidShouldError TEST");
d.created = DateTime.Now.ToString();
//NO END DATE ERRROR
d.dollarAmount = 1.11m;
d.active = true;
d.roles = 99999;//<---BAD ROLE VALUE
//create via inventory full test user
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "Roles", "InvalidValue");
}
//==================================================
}//eoc
}//eons