This commit is contained in:
@@ -35,19 +35,13 @@ namespace raven_integration
|
|||||||
public const string OpContains = "-%-";
|
public const string OpContains = "-%-";
|
||||||
public const string OpNotContains = "!-%-";
|
public const string OpNotContains = "!-%-";
|
||||||
|
|
||||||
// public const string AyDataTypeDate = "date";
|
|
||||||
// public const string AyDataTypeText = "text";
|
|
||||||
// public const string AyDataTypeInteger = "int";
|
|
||||||
// public const string AyDataTypeBool = "bool";
|
|
||||||
// public const string AyDataTypeDecimal = "decimal";
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
///////////////////////
|
|
||||||
//DATE
|
//DATE
|
||||||
//
|
//
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//TEXT
|
//TEXT
|
||||||
//
|
//
|
||||||
|
|
||||||
@@ -55,7 +49,7 @@ namespace raven_integration
|
|||||||
//TODO: specifically test a string with an ampersand character in it for inclusive (finding it)
|
//TODO: specifically test a string with an ampersand character in it for inclusive (finding it)
|
||||||
|
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//INT
|
//INT
|
||||||
//
|
//
|
||||||
#region INTEGER TESTS
|
#region INTEGER TESTS
|
||||||
@@ -667,13 +661,11 @@ namespace raven_integration
|
|||||||
#endregion integer tests
|
#endregion integer tests
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
///////////////////////
|
|
||||||
//BOOL
|
//BOOL
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#region BOOLEAN TESTS
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -925,17 +917,621 @@ namespace raven_integration
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion boolean tests
|
||||||
//TODO: Re-run search and compare active v inactive opposite of above
|
|
||||||
//TODO: //UPDATE FILTER TO LIMIT TO INACTIVE BY FLIPPING THE OP TO NOTEQUAL
|
|
||||||
//SAVE AS ANOTHER FILTER (or possibly modify the original one) AND RETEST
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//DECIMAL
|
//DECIMAL
|
||||||
//
|
//
|
||||||
|
#region DECIMAL TESTS
|
||||||
|
|
||||||
///////////////////////
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public async void DecimalOpEqualityFilterWorks()
|
||||||
|
{
|
||||||
|
|
||||||
|
var WidgetNameStart = "DecimalOpEqualityFilterWorks";
|
||||||
|
|
||||||
|
long IncludedWidgetId = 0;
|
||||||
|
long ExcludedWidgetId = 0;
|
||||||
|
|
||||||
|
//CREATE TEST WIDGETS
|
||||||
|
|
||||||
|
|
||||||
|
//included widget
|
||||||
|
dynamic w = new JObject();
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.active = true;
|
||||||
|
w.roles = 0;
|
||||||
|
w.dollarAmount = 5.55;
|
||||||
|
|
||||||
|
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//Excluded widget
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.dollarAmount = 3.33;
|
||||||
|
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//CREATE FILTER
|
||||||
|
dynamic d = new JObject();
|
||||||
|
d.name = Util.Uniquify("DecimalOpEqualityFilterWorks");
|
||||||
|
// d.ownerId = 1L;
|
||||||
|
d["public"] = true;
|
||||||
|
d.listKey = "widget";
|
||||||
|
|
||||||
|
dynamic dfilter = new JArray();
|
||||||
|
|
||||||
|
//name starts with filter to constrict to widgets that this test block created only
|
||||||
|
dynamic DataFilterNameStart = new JObject();
|
||||||
|
DataFilterNameStart.fld = "name";
|
||||||
|
DataFilterNameStart.op = OpStartsWith;
|
||||||
|
DataFilterNameStart.value = WidgetNameStart;
|
||||||
|
dfilter.Add(DataFilterNameStart);
|
||||||
|
|
||||||
|
//inclusive test filter
|
||||||
|
|
||||||
|
dynamic FilterItem = new JObject();
|
||||||
|
FilterItem.fld = "dollaramount";
|
||||||
|
FilterItem.op = OpEquality;
|
||||||
|
FilterItem.value = 5.55;
|
||||||
|
dfilter.Add(FilterItem);
|
||||||
|
|
||||||
|
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||||
|
|
||||||
|
a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
|
||||||
|
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//NOW FETCH WIDGET LIST WITH FILTER
|
||||||
|
a = await Util.GetAsync($"Widget/listwidgets?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
Util.ValidateHTTPStatusCode(a, 200);
|
||||||
|
|
||||||
|
//assert contains at least this test record
|
||||||
|
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
|
||||||
|
var v = ((JArray)a.ObjectResponse["data"]);
|
||||||
|
List<long> IDInResultList = new List<long>();
|
||||||
|
int InclusiveMatchCount = 0;
|
||||||
|
int ExclusiveMatchCount = 0;
|
||||||
|
foreach (JObject o in v)
|
||||||
|
{
|
||||||
|
if (IncludedWidgetId == o["id"].Value<long>())
|
||||||
|
InclusiveMatchCount++;
|
||||||
|
if (ExcludedWidgetId == o["id"].Value<long>())//whups
|
||||||
|
ExclusiveMatchCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
|
||||||
|
ExclusiveMatchCount.Should().Be(0);
|
||||||
|
|
||||||
|
//DELETE WIDGETS
|
||||||
|
a = await Util.DeleteAsync("Widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
a = await Util.DeleteAsync("Widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
|
||||||
|
//DELETE DATAFILTER
|
||||||
|
a = await Util.DeleteAsync("DataFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public async void DecimalOpGreaterThanFilterWorks()
|
||||||
|
{
|
||||||
|
|
||||||
|
var WidgetNameStart = "DecimalOpGreaterThanFilterWorks";
|
||||||
|
|
||||||
|
long IncludedWidgetId = 0;
|
||||||
|
long ExcludedWidgetId = 0;
|
||||||
|
|
||||||
|
//CREATE TEST WIDGETS
|
||||||
|
|
||||||
|
//included widget
|
||||||
|
dynamic w = new JObject();
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.active = true;
|
||||||
|
w.roles = 0;
|
||||||
|
w.dollarAmount = 55.55;
|
||||||
|
|
||||||
|
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//Excluded widget
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.dollarAmount = -55.55;
|
||||||
|
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
|
||||||
|
//CREATE FILTER
|
||||||
|
dynamic d = new JObject();
|
||||||
|
d.name = Util.Uniquify("DecimalOpGreaterThanFilterWorks");
|
||||||
|
// d.ownerId = 1L;
|
||||||
|
d["public"] = true;
|
||||||
|
d.listKey = "widget";
|
||||||
|
|
||||||
|
dynamic dfilter = new JArray();
|
||||||
|
|
||||||
|
//name starts with filter to constrict to widgets that this test block created only
|
||||||
|
dynamic DataFilterNameStart = new JObject();
|
||||||
|
DataFilterNameStart.fld = "name";
|
||||||
|
DataFilterNameStart.op = OpStartsWith;
|
||||||
|
DataFilterNameStart.value = WidgetNameStart;
|
||||||
|
dfilter.Add(DataFilterNameStart);
|
||||||
|
|
||||||
|
//inclusive test filter
|
||||||
|
|
||||||
|
dynamic FilterItem = new JObject();
|
||||||
|
FilterItem.fld = "dollaramount";
|
||||||
|
FilterItem.op = OpGreaterThan;
|
||||||
|
FilterItem.value = 54.44;
|
||||||
|
dfilter.Add(FilterItem);
|
||||||
|
|
||||||
|
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||||
|
|
||||||
|
a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
|
||||||
|
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//NOW FETCH WIDGET LIST WITH FILTER
|
||||||
|
a = await Util.GetAsync($"Widget/listwidgets?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
Util.ValidateHTTPStatusCode(a, 200);
|
||||||
|
|
||||||
|
//assert contains at least this test record
|
||||||
|
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
|
||||||
|
var v = ((JArray)a.ObjectResponse["data"]);
|
||||||
|
List<long> IDInResultList = new List<long>();
|
||||||
|
int InclusiveMatchCount = 0;
|
||||||
|
int ExclusiveMatchCount = 0;
|
||||||
|
foreach (JObject o in v)
|
||||||
|
{
|
||||||
|
if (IncludedWidgetId == o["id"].Value<long>())
|
||||||
|
InclusiveMatchCount++;
|
||||||
|
if (ExcludedWidgetId == o["id"].Value<long>())//whups
|
||||||
|
ExclusiveMatchCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
|
||||||
|
ExclusiveMatchCount.Should().Be(0);
|
||||||
|
|
||||||
|
//DELETE WIDGETS
|
||||||
|
a = await Util.DeleteAsync("Widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
a = await Util.DeleteAsync("Widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
|
||||||
|
//DELETE DATAFILTER
|
||||||
|
a = await Util.DeleteAsync("DataFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public async void DecimalOpGreaterThanOrEqualToFilterWorks()
|
||||||
|
{
|
||||||
|
|
||||||
|
var WidgetNameStart = "DecimalOpGreaterThanOrEqualToFilterWorks";
|
||||||
|
|
||||||
|
long IncludedWidgetId = 0;
|
||||||
|
long ExcludedWidgetId = 0;
|
||||||
|
|
||||||
|
//CREATE TEST WIDGETS
|
||||||
|
|
||||||
|
//included widget
|
||||||
|
dynamic w = new JObject();
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.active = true;
|
||||||
|
w.roles = 0;
|
||||||
|
w.dollarAmount = 555.55;
|
||||||
|
|
||||||
|
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//Excluded widget
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.dollarAmount = 554.54;
|
||||||
|
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
|
||||||
|
//CREATE FILTER
|
||||||
|
dynamic d = new JObject();
|
||||||
|
d.name = Util.Uniquify("DecimalOpGreaterThanOrEqualToFilterWorks");
|
||||||
|
// d.ownerId = 1L;
|
||||||
|
d["public"] = true;
|
||||||
|
d.listKey = "widget";
|
||||||
|
|
||||||
|
dynamic dfilter = new JArray();
|
||||||
|
|
||||||
|
//name starts with filter to constrict to widgets that this test block created only
|
||||||
|
dynamic DataFilterNameStart = new JObject();
|
||||||
|
DataFilterNameStart.fld = "name";
|
||||||
|
DataFilterNameStart.op = OpStartsWith;
|
||||||
|
DataFilterNameStart.value = WidgetNameStart;
|
||||||
|
dfilter.Add(DataFilterNameStart);
|
||||||
|
|
||||||
|
//inclusive test filter
|
||||||
|
|
||||||
|
dynamic FilterItem = new JObject();
|
||||||
|
FilterItem.fld = "dollaramount";
|
||||||
|
FilterItem.op = OpGreaterThanOrEqualTo;
|
||||||
|
FilterItem.value = 555.55;
|
||||||
|
dfilter.Add(FilterItem);
|
||||||
|
|
||||||
|
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||||
|
|
||||||
|
a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
|
||||||
|
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//NOW FETCH WIDGET LIST WITH FILTER
|
||||||
|
a = await Util.GetAsync($"Widget/listwidgets?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
Util.ValidateHTTPStatusCode(a, 200);
|
||||||
|
|
||||||
|
//assert contains at least this test record
|
||||||
|
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
|
||||||
|
var v = ((JArray)a.ObjectResponse["data"]);
|
||||||
|
List<long> IDInResultList = new List<long>();
|
||||||
|
int InclusiveMatchCount = 0;
|
||||||
|
int ExclusiveMatchCount = 0;
|
||||||
|
foreach (JObject o in v)
|
||||||
|
{
|
||||||
|
if (IncludedWidgetId == o["id"].Value<long>())
|
||||||
|
InclusiveMatchCount++;
|
||||||
|
if (ExcludedWidgetId == o["id"].Value<long>())//whups
|
||||||
|
ExclusiveMatchCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
|
||||||
|
ExclusiveMatchCount.Should().Be(0);
|
||||||
|
|
||||||
|
//DELETE WIDGETS
|
||||||
|
a = await Util.DeleteAsync("Widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
a = await Util.DeleteAsync("Widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
|
||||||
|
//DELETE DATAFILTER
|
||||||
|
a = await Util.DeleteAsync("DataFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public async void DecimalOpLessThanFilterWorks()
|
||||||
|
{
|
||||||
|
|
||||||
|
var WidgetNameStart = "DecimalOpLessThanFilterWorks";
|
||||||
|
|
||||||
|
long IncludedWidgetId = 0;
|
||||||
|
long ExcludedWidgetId = 0;
|
||||||
|
|
||||||
|
//CREATE TEST WIDGETS
|
||||||
|
|
||||||
|
//included widget
|
||||||
|
dynamic w = new JObject();
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.active = true;
|
||||||
|
w.roles = 0;
|
||||||
|
w.dollarAmount = -5555.55;
|
||||||
|
|
||||||
|
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//Excluded widget
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.dollarAmount = 5555.55;
|
||||||
|
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
|
||||||
|
//CREATE FILTER
|
||||||
|
dynamic d = new JObject();
|
||||||
|
d.name = Util.Uniquify("DecimalOpLessThanFilterWorks");
|
||||||
|
// d.ownerId = 1L;
|
||||||
|
d["public"] = true;
|
||||||
|
d.listKey = "widget";
|
||||||
|
|
||||||
|
dynamic dfilter = new JArray();
|
||||||
|
|
||||||
|
//name starts with filter to constrict to widgets that this test block created only
|
||||||
|
dynamic DataFilterNameStart = new JObject();
|
||||||
|
DataFilterNameStart.fld = "name";
|
||||||
|
DataFilterNameStart.op = OpStartsWith;
|
||||||
|
DataFilterNameStart.value = WidgetNameStart;
|
||||||
|
dfilter.Add(DataFilterNameStart);
|
||||||
|
|
||||||
|
//inclusive test filter
|
||||||
|
|
||||||
|
dynamic FilterItem = new JObject();
|
||||||
|
FilterItem.fld = "dollaramount";
|
||||||
|
FilterItem.op = OpLessThan;
|
||||||
|
FilterItem.value = 5555.55;
|
||||||
|
dfilter.Add(FilterItem);
|
||||||
|
|
||||||
|
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||||
|
|
||||||
|
a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
|
||||||
|
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//NOW FETCH WIDGET LIST WITH FILTER
|
||||||
|
a = await Util.GetAsync($"Widget/listwidgets?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
Util.ValidateHTTPStatusCode(a, 200);
|
||||||
|
|
||||||
|
//assert contains at least this test record
|
||||||
|
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
|
||||||
|
var v = ((JArray)a.ObjectResponse["data"]);
|
||||||
|
List<long> IDInResultList = new List<long>();
|
||||||
|
int InclusiveMatchCount = 0;
|
||||||
|
int ExclusiveMatchCount = 0;
|
||||||
|
foreach (JObject o in v)
|
||||||
|
{
|
||||||
|
if (IncludedWidgetId == o["id"].Value<long>())
|
||||||
|
InclusiveMatchCount++;
|
||||||
|
if (ExcludedWidgetId == o["id"].Value<long>())//whups
|
||||||
|
ExclusiveMatchCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
|
||||||
|
ExclusiveMatchCount.Should().Be(0);
|
||||||
|
|
||||||
|
//DELETE WIDGETS
|
||||||
|
a = await Util.DeleteAsync("Widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
a = await Util.DeleteAsync("Widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
|
||||||
|
//DELETE DATAFILTER
|
||||||
|
a = await Util.DeleteAsync("DataFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public async void DecimalOpLessThanOrEqualToFilterWorks()
|
||||||
|
{
|
||||||
|
|
||||||
|
var WidgetNameStart = "DecimalOpLessThanOrEqualToFilterWorks";
|
||||||
|
|
||||||
|
long IncludedWidgetId = 0;
|
||||||
|
long ExcludedWidgetId = 0;
|
||||||
|
|
||||||
|
//CREATE TEST WIDGETS
|
||||||
|
|
||||||
|
//included widget
|
||||||
|
dynamic w = new JObject();
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.active = true;
|
||||||
|
w.roles = 0;
|
||||||
|
w.dollarAmount = -444.44;
|
||||||
|
|
||||||
|
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//Excluded widget
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.dollarAmount = -443.43;
|
||||||
|
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
|
||||||
|
//CREATE FILTER
|
||||||
|
dynamic d = new JObject();
|
||||||
|
d.name = Util.Uniquify("DecimalOpLessThanOrEqualToFilterWorks");
|
||||||
|
// d.ownerId = 1L;
|
||||||
|
d["public"] = true;
|
||||||
|
d.listKey = "widget";
|
||||||
|
|
||||||
|
dynamic dfilter = new JArray();
|
||||||
|
|
||||||
|
//name starts with filter to constrict to widgets that this test block created only
|
||||||
|
dynamic DataFilterNameStart = new JObject();
|
||||||
|
DataFilterNameStart.fld = "name";
|
||||||
|
DataFilterNameStart.op = OpStartsWith;
|
||||||
|
DataFilterNameStart.value = WidgetNameStart;
|
||||||
|
dfilter.Add(DataFilterNameStart);
|
||||||
|
|
||||||
|
//inclusive test filter
|
||||||
|
|
||||||
|
dynamic FilterItem = new JObject();
|
||||||
|
FilterItem.fld = "dollaramount";
|
||||||
|
FilterItem.op = OpLessThanOrEqualTo;
|
||||||
|
FilterItem.value = -444.44;
|
||||||
|
dfilter.Add(FilterItem);
|
||||||
|
|
||||||
|
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||||
|
|
||||||
|
a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
|
||||||
|
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//NOW FETCH WIDGET LIST WITH FILTER
|
||||||
|
a = await Util.GetAsync($"Widget/listwidgets?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
Util.ValidateHTTPStatusCode(a, 200);
|
||||||
|
|
||||||
|
//assert contains at least this test record
|
||||||
|
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
|
||||||
|
var v = ((JArray)a.ObjectResponse["data"]);
|
||||||
|
List<long> IDInResultList = new List<long>();
|
||||||
|
int InclusiveMatchCount = 0;
|
||||||
|
int ExclusiveMatchCount = 0;
|
||||||
|
foreach (JObject o in v)
|
||||||
|
{
|
||||||
|
if (IncludedWidgetId == o["id"].Value<long>())
|
||||||
|
InclusiveMatchCount++;
|
||||||
|
if (ExcludedWidgetId == o["id"].Value<long>())//whups
|
||||||
|
ExclusiveMatchCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
|
||||||
|
ExclusiveMatchCount.Should().Be(0);
|
||||||
|
|
||||||
|
//DELETE WIDGETS
|
||||||
|
a = await Util.DeleteAsync("Widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
a = await Util.DeleteAsync("Widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
|
||||||
|
//DELETE DATAFILTER
|
||||||
|
a = await Util.DeleteAsync("DataFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public async void DecimalNotEqualToFilterWorks()
|
||||||
|
{
|
||||||
|
|
||||||
|
var WidgetNameStart = "DecimalNotEqualToFilterWorks";
|
||||||
|
|
||||||
|
long IncludedWidgetId = 0;
|
||||||
|
long ExcludedWidgetId = 0;
|
||||||
|
|
||||||
|
//CREATE TEST WIDGETS
|
||||||
|
|
||||||
|
//included widget
|
||||||
|
dynamic w = new JObject();
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.active = true;
|
||||||
|
w.roles = 0;
|
||||||
|
w.dollarAmount = 222.22;
|
||||||
|
|
||||||
|
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
IncludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//Excluded widget
|
||||||
|
w.name = Util.Uniquify(WidgetNameStart);
|
||||||
|
w.dollarAmount = 223.23;
|
||||||
|
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
|
||||||
|
//CREATE FILTER
|
||||||
|
dynamic d = new JObject();
|
||||||
|
d.name = Util.Uniquify("DecimalNotEqualToFilterWorks");
|
||||||
|
// d.ownerId = 1L;
|
||||||
|
d["public"] = true;
|
||||||
|
d.listKey = "widget";
|
||||||
|
|
||||||
|
dynamic dfilter = new JArray();
|
||||||
|
|
||||||
|
//name starts with filter to constrict to widgets that this test block created only
|
||||||
|
dynamic DataFilterNameStart = new JObject();
|
||||||
|
DataFilterNameStart.fld = "name";
|
||||||
|
DataFilterNameStart.op = OpStartsWith;
|
||||||
|
DataFilterNameStart.value = WidgetNameStart;
|
||||||
|
dfilter.Add(DataFilterNameStart);
|
||||||
|
|
||||||
|
//inclusive test filter
|
||||||
|
|
||||||
|
dynamic FilterItem = new JObject();
|
||||||
|
FilterItem.fld = "dollaramount";
|
||||||
|
FilterItem.op = OpNotEqual;
|
||||||
|
FilterItem.value = 223.23;
|
||||||
|
dfilter.Add(FilterItem);
|
||||||
|
|
||||||
|
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||||
|
|
||||||
|
a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
|
||||||
|
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//NOW FETCH WIDGET LIST WITH FILTER
|
||||||
|
a = await Util.GetAsync($"Widget/listwidgets?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
Util.ValidateHTTPStatusCode(a, 200);
|
||||||
|
|
||||||
|
//assert contains at least this test record
|
||||||
|
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
|
||||||
|
var v = ((JArray)a.ObjectResponse["data"]);
|
||||||
|
List<long> IDInResultList = new List<long>();
|
||||||
|
int InclusiveMatchCount = 0;
|
||||||
|
int ExclusiveMatchCount = 0;
|
||||||
|
foreach (JObject o in v)
|
||||||
|
{
|
||||||
|
if (IncludedWidgetId == o["id"].Value<long>())
|
||||||
|
InclusiveMatchCount++;
|
||||||
|
if (ExcludedWidgetId == o["id"].Value<long>())//whups
|
||||||
|
ExclusiveMatchCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
|
||||||
|
ExclusiveMatchCount.Should().Be(0);
|
||||||
|
|
||||||
|
//DELETE WIDGETS
|
||||||
|
a = await Util.DeleteAsync("Widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
a = await Util.DeleteAsync("Widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
|
||||||
|
//DELETE DATAFILTER
|
||||||
|
a = await Util.DeleteAsync("DataFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion decimal tests
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//TAGS
|
//TAGS
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user