This commit is contained in:
@@ -78,10 +78,96 @@ namespace raven_integration
|
||||
|
||||
}
|
||||
|
||||
//TEST: invalid options test for failure
|
||||
//- invalid list key
|
||||
//- invalid field name
|
||||
//- invalid operator
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void InvalidListKeyShouldFail()
|
||||
{
|
||||
//CREATE
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test DataFilter");
|
||||
// d.ownerId = 1L;
|
||||
d["public"] = true;
|
||||
d.listKey = "nonexistant";
|
||||
|
||||
//"[{fld:"name",op:"!=",value:"Notequaltothis"},{fld:"tags",op:"Eq",value:"[23,456,54]"}]
|
||||
dynamic dfilter = new JArray();
|
||||
dynamic df = new JObject();
|
||||
df.fld = "name";
|
||||
df.op = "%-";
|
||||
df.value = "Generic";//lots of seed widgets start with Generic
|
||||
dfilter.Add(df);
|
||||
|
||||
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||
|
||||
ApiResponse a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
Util.ValidateErrorCodeResponse(a, 2200, 400);
|
||||
Util.ShouldContainValidationError(a, "ListKey", "InvalidValue");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void InvalidFieldNameShouldFail()
|
||||
{
|
||||
//CREATE
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test DataFilter");
|
||||
// d.ownerId = 1L;
|
||||
d["public"] = true;
|
||||
d.listKey = "widget";
|
||||
|
||||
//"[{fld:"name",op:"!=",value:"Notequaltothis"},{fld:"tags",op:"Eq",value:"[23,456,54]"}]
|
||||
dynamic dfilter = new JArray();
|
||||
dynamic df = new JObject();
|
||||
df.fld = "doesntexist";
|
||||
df.op = "%-";
|
||||
df.value = "Generic";//lots of seed widgets start with Generic
|
||||
dfilter.Add(df);
|
||||
|
||||
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||
|
||||
ApiResponse a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
Util.ValidateErrorCodeResponse(a, 2200, 400);
|
||||
Util.ShouldContainValidationError(a, "Filter", "InvalidValue");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void InvalidOperatorShouldFail()
|
||||
{
|
||||
//CREATE
|
||||
dynamic d = new JObject();
|
||||
d.name = Util.Uniquify("Test DataFilter");
|
||||
// d.ownerId = 1L;
|
||||
d["public"] = true;
|
||||
d.listKey = "widget";
|
||||
|
||||
//"[{fld:"name",op:"!=",value:"Notequaltothis"},{fld:"tags",op:"Eq",value:"[23,456,54]"}]
|
||||
dynamic dfilter = new JArray();
|
||||
dynamic df = new JObject();
|
||||
df.fld = "name";
|
||||
df.op = "wtf";
|
||||
df.value = "Generic";//lots of seed widgets start with Generic
|
||||
dfilter.Add(df);
|
||||
|
||||
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||
|
||||
ApiResponse a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||
Util.ValidateErrorCodeResponse(a, 2200, 400);
|
||||
Util.ShouldContainValidationError(a, "Filter", "InvalidValue");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace raven_integration
|
||||
SearchParameters.phrase = TEST_SEARCH_PHRASE;
|
||||
SearchParameters.nameOnly = true;
|
||||
SearchParameters.typeOnly = 0;//no type
|
||||
SearchParameters.maxResults=0;
|
||||
SearchParameters.maxResults = 0;
|
||||
a = await Util.PostAsync("Search", await Util.GetTokenAsync("SubContractorLimited"), SearchParameters.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
((JArray)a.ObjectResponse["data"]["searchResults"]).Count.Should().BeGreaterOrEqualTo(2);
|
||||
@@ -200,7 +200,7 @@ namespace raven_integration
|
||||
SearchParameters.phrase = TEST_SEARCH_PHRASE;
|
||||
SearchParameters.nameOnly = false;
|
||||
SearchParameters.typeOnly = 0;//no type
|
||||
SearchParameters.maxResults=0;
|
||||
SearchParameters.maxResults = 0;
|
||||
a = await Util.PostAsync("Search", await Util.GetTokenAsync("manager", "l3tm3in"), SearchParameters.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
|
||||
@@ -530,10 +530,10 @@ namespace raven_integration
|
||||
|
||||
|
||||
|
||||
[Fact]
|
||||
[Fact]
|
||||
public async void SearchForSerialFieldShouldWork()
|
||||
{
|
||||
//CREATE A WIDGET
|
||||
//CREATE A WIDGET
|
||||
dynamic D = new JObject();
|
||||
D.name = Util.Uniquify("Serial search test WIDGET");
|
||||
D.dollarAmount = 1.11m;
|
||||
@@ -545,11 +545,11 @@ namespace raven_integration
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
long MatchWidgetInSerialId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
var MatchWidgetSerial = a.ObjectResponse["data"]["serial"].Value<uint>();
|
||||
|
||||
//TODO: get this from the return object
|
||||
string SerialSearch=MatchWidgetInSerialId.ToString();;
|
||||
|
||||
|
||||
//TODO: get this from the return object
|
||||
string SerialSearch = MatchWidgetSerial.ToString(); ;
|
||||
|
||||
|
||||
//Now see if can find those objects with a phrase search
|
||||
dynamic SearchParameters = new JObject();
|
||||
SearchParameters.phrase = SerialSearch;
|
||||
@@ -572,7 +572,7 @@ namespace raven_integration
|
||||
|
||||
//Ensure the expected items are returned
|
||||
MatchingIdList.Should().Contain(MatchWidgetInSerialId, "ShouldContainMatchWidgetInSerialId");
|
||||
|
||||
|
||||
|
||||
}//eot
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace raven_integration
|
||||
ApiResponse a = await Util.GetAsync("Widget/FilterOptions", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
Util.ValidateHTTPStatusCode(a, 200);
|
||||
a.ObjectResponse["data"]["key"].Value<string>().Should().Be("Widget");
|
||||
a.ObjectResponse["data"]["key"].Value<string>().Should().Be("widget");
|
||||
((JArray)a.ObjectResponse["data"]["flds"]).Count.Should().Be(6);
|
||||
a.ObjectResponse["data"]["flds"][2]["lt"].Value<string>().Should().Be("Price");
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace raven_integration
|
||||
public class WidgetValidationTest
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Test business rule should be active on new
|
||||
/// </summary>
|
||||
@@ -26,7 +26,7 @@ namespace raven_integration
|
||||
d.roles = 0;
|
||||
|
||||
//create via inventory full test user
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("InventoryFull"), d.ToString());
|
||||
|
||||
Util.ValidateErrorCodeResponse(a, 2200, 400);
|
||||
Util.ShouldContainValidationError(a, "Active", "InvalidValue");
|
||||
@@ -51,11 +51,11 @@ namespace raven_integration
|
||||
d.roles = 0;
|
||||
|
||||
//create via inventory full test user
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
|
||||
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());
|
||||
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("InventoryFull"), d.ToString());
|
||||
|
||||
//2002 in-valid expected
|
||||
Util.ValidateErrorCodeResponse(a, 2200, 400);
|
||||
@@ -80,7 +80,7 @@ namespace raven_integration
|
||||
d.roles = 0;
|
||||
|
||||
//create via inventory full test user
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("InventoryFull"), d.ToString());
|
||||
|
||||
|
||||
//2002 in-valid expected
|
||||
@@ -104,7 +104,7 @@ namespace raven_integration
|
||||
d.roles = 0;
|
||||
|
||||
//create via inventory full test user
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("InventoryFull"), d.ToString());
|
||||
|
||||
|
||||
//2002 in-valid expected
|
||||
@@ -113,34 +113,6 @@ namespace raven_integration
|
||||
|
||||
}
|
||||
|
||||
/// <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["data"]["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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -161,7 +133,7 @@ namespace raven_integration
|
||||
d.roles = 0;
|
||||
|
||||
//create via inventory full test user
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("InventoryFull"), d.ToString());
|
||||
|
||||
|
||||
//2002 in-valid expected
|
||||
@@ -189,7 +161,7 @@ namespace raven_integration
|
||||
d.roles = 0;
|
||||
|
||||
//create via inventory full test user
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("InventoryFull"), d.ToString());
|
||||
|
||||
|
||||
//2002 in-valid expected
|
||||
@@ -217,7 +189,7 @@ namespace raven_integration
|
||||
d.roles = 0;
|
||||
|
||||
//create via inventory full test user
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("InventoryFull"), d.ToString());
|
||||
|
||||
|
||||
//2002 in-valid expected
|
||||
@@ -245,7 +217,7 @@ namespace raven_integration
|
||||
d.roles = 99999;//<---BAD ROLE VALUE
|
||||
|
||||
//create via inventory full test user
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync( "InventoryFull"), d.ToString());
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("InventoryFull"), d.ToString());
|
||||
|
||||
|
||||
//2002 in-valid expected
|
||||
|
||||
Reference in New Issue
Block a user