This commit is contained in:
2026-02-26 11:42:55 -08:00
parent e71584ec63
commit b7adb7dae9
2 changed files with 24 additions and 60 deletions

View File

@@ -1,9 +1,5 @@
using System;
using Xunit;
using Newtonsoft.Json.Linq;
using FluentAssertions;
using System.Collections.Generic;
using System.Collections.Concurrent;
namespace raven_integration
{
@@ -19,14 +15,14 @@ namespace raven_integration
// {
// //CREATE attempt with broken rules
// dynamic d = new JObject();
// d.name = Util.Uniquify("ServerShouldDisAllowOwnerOnlyRightsUserToDeleteNonOwned TEST WIDGET");
// d.name = Util.Uniquify("ServerShouldDisAllowOwnerOnlyRightsUserToDeleteNonOwned TEST PROJECT");
// d.created = DateTime.Now.ToString();
// d.dollarAmount = 1.11m;
// d.active = false;//<--- BROKEN RULE new widget must be active = true!!
// d.active = false;//<--- BROKEN RULE new project must be active = true!!
// d.usertype = 1;
// //create via inventory full test user
// ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("Inventory"), d.ToString());
//
// ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("Inventory"), d.ToString());
// Util.ValidateErrorCodeResponse(a, 2200, 400);
// Util.ShouldContainValidationError(a, "Active", "2203");
@@ -44,20 +40,19 @@ namespace raven_integration
{
//CREATE attempt with broken rules
dynamic d = new JObject();
d.name = Util.Uniquify("BusinessRuleNameMustBeUnique TEST WIDGET");
d.name = Util.Uniquify("BusinessRuleNameMustBeUnique TEST PROJECT");
d.notes = "blah";
d.customFields = Util.WidgetRequiredCustomFieldsJsonString();
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.usertype = 1;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("Inventory"), d.ToString());
ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("BizAdmin"), d.ToString());
Util.ValidateDataReturnResponseOk(a);
//Now try to create again with same name
a = await Util.PostAsync("widget", await Util.GetTokenAsync("Inventory"), d.ToString());
a = await Util.PostAsync("project", await Util.GetTokenAsync("BizAdmin"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
@@ -81,8 +76,8 @@ namespace raven_integration
d.active = true;
d.usertype = 1;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("Inventory"), d.ToString());
ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("BizAdmin"), d.ToString());
//2002 in-valid expected
@@ -93,37 +88,12 @@ namespace raven_integration
}
/// <summary>
///
/// </summary>
[Fact]
public async Task BusinessRuleNameLengthExceeded()
{
dynamic d = new JObject();
d.name = new string('A', 256); ;
d.created = DateTime.Now.ToString();
d.dollarAmount = 1.11m;
d.active = true;
d.usertype = 1;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("Inventory"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "Name", "2202", "255 max");
}
/// <summary>
///
/// </summary>
[Fact]
[Fact(Skip = "TODO: Implement after workorder tests working needs dated object to test")]
public async Task BusinessRuleStartDateWithoutEndDateShouldError()
{
@@ -136,8 +106,8 @@ namespace raven_integration
d.active = true;
d.usertype = 1;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("Inventory"), d.ToString());
ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("BizAdmin"), d.ToString());
//2002 in-valid expected
@@ -151,7 +121,7 @@ namespace raven_integration
/// <summary>
///
/// </summary>
[Fact]
[Fact(Skip = "TODO: Implement after workorder tests working needs dated object to test")]
public async Task BusinessRuleEndDateWithoutStartDateShouldError()
{
@@ -164,8 +134,8 @@ namespace raven_integration
d.active = true;
d.usertype = 1;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("Inventory"), d.ToString());
ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("BizAdmin"), d.ToString());
//2002 in-valid expected
@@ -178,7 +148,7 @@ namespace raven_integration
/// <summary>
///
/// </summary>
[Fact]
[Fact(Skip = "TODO: Implement after workorder tests working needs dated object to test")]
public async Task BusinessRuleEndDateBeforeStartDateShouldError()
{
@@ -192,8 +162,8 @@ namespace raven_integration
d.active = true;
d.usertype = 1;
//create via inventory full test user
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("Inventory"), d.ToString());
ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("BizAdmin"), d.ToString());
//2002 in-valid expected
@@ -214,19 +184,9 @@ namespace raven_integration
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.usertype = -1;//<---BAD VALUE
d.Notes = "blah";
d.customFields = Util.WidgetRequiredCustomFieldsJsonString();
//create via inventory full test user
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("Inventory"), d.ToString());
ApiResponse a = await Util.PostAsync("user", await Util.GetTokenAsync("BizAdmin"), d.ToString());
//2002 in-valid expected
Util.ValidateErrorCodeResponse(a, 2200, 400);
Util.ShouldContainValidationError(a, "UserType", "2203");