This commit is contained in:
@@ -849,7 +849,153 @@ same as the server does but in a central location here for all tests to use.
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
}
|
||||
|
||||
/*
|
||||
RELATIVE TOKEN EXAMPLE:
|
||||
|
||||
public const string TokenYesterday = "{[yesterday]}";
|
||||
public const string TokenToday = "{[today]}";
|
||||
public const string TokenTomorrow = "{[tomorrow]}";
|
||||
public const string TokenLastWeek = "{[lastweek]}";
|
||||
public const string TokenThisWeek = "{[thisweek]}";
|
||||
public const string TokenNextWeek = "{[nextweek]}";
|
||||
public const string TokenLastMonth = "{[lastmonth]}";
|
||||
public const string TokenThisMonth = "{[thismonth]}";
|
||||
public const string TokenNextMonth = "{[nextmonth]}";
|
||||
public const string TokenFourteenDayWindow = "{[14daywindow]}";
|
||||
public const string TokenPast = "{[past]}";
|
||||
public const string TokenFuture = "{[future]}";
|
||||
public const string TokenLastYear = "{[lastyear]}";
|
||||
public const string TokenThisYear = "{[thisyear]}";
|
||||
public const string TokenInTheLast3Months = "{[last3months]}";
|
||||
public const string TokenInTheLast6Months = "{[last6months]}";
|
||||
public const string TokenInTheLastYear = "{[lastcalendaryear]}";
|
||||
|
||||
//More business time frames
|
||||
|
||||
public const string TokenYearToDate = "{[yeartodate]}";
|
||||
|
||||
public const string TokenPast90Days = "{[past90days]}";
|
||||
public const string TokenPast30Days = "{[past30days]}";
|
||||
public const string TokenPast24Hours = "{[past24hours]}";
|
||||
|
||||
//Months THIS year
|
||||
public const string TokenJanuary = "{[january]}";
|
||||
public const string TokenFebruary = "{[february]}";
|
||||
public const string TokenMarch = "{[march]}";
|
||||
public const string TokenApril = "{[april]}";
|
||||
public const string TokenMay = "{[may]}";
|
||||
public const string TokenJune = "{[june]}";
|
||||
public const string TokenJuly = "{[july]}";
|
||||
public const string TokenAugust = "{[august]}";
|
||||
public const string TokenSeptember = "{[september]}";
|
||||
public const string TokenOctober = "{[october]}";
|
||||
public const string TokenNovember = "{[november]}";
|
||||
public const string TokenDecember = "{[december]}";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void DateTokenYesterdayFilterWorks()
|
||||
{
|
||||
|
||||
var WidgetNameStart = "DateTokenYesterdayFilterWorks";
|
||||
|
||||
long IncludedWidgetId = 0;
|
||||
long ExcludedWidgetId = 0;
|
||||
|
||||
//CREATE TEST WIDGETS
|
||||
|
||||
//included widget
|
||||
dynamic w = new JObject();
|
||||
w.name = Util.Uniquify(WidgetNameStart);
|
||||
w.notes = "blah";
|
||||
w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
||||
w.startDate = DateTime.UtcNow.AddDays(-1);
|
||||
w.endDate = DateTime.UtcNow.AddHours(1).AddDays(-1);
|
||||
|
||||
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.startDate = DateTime.UtcNow;
|
||||
w.endDate = DateTime.UtcNow.AddHours(1);
|
||||
|
||||
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(WidgetNameStart);
|
||||
|
||||
d["public"] = true;
|
||||
d.listKey = "TestWidgetDataList";
|
||||
|
||||
dynamic dfilter = new JArray();
|
||||
|
||||
//name starts with filter to constrict to widgets that this test block created only
|
||||
dynamic DataFilterNameStart = new JObject();
|
||||
DataFilterNameStart.fld = "widgetname";
|
||||
DataFilterNameStart.op = Util.OpStartsWith;
|
||||
DataFilterNameStart.value = WidgetNameStart;
|
||||
dfilter.Add(DataFilterNameStart);
|
||||
|
||||
//## INCLUSIVE FILTER
|
||||
dynamic FilterItem = new JObject();
|
||||
FilterItem.fld = "widgetstartdate";
|
||||
FilterItem.op = Util.OpEquality;
|
||||
FilterItem.value = TokenYesterday;
|
||||
dfilter.Add(FilterItem);
|
||||
|
||||
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||
|
||||
a = await Util.PostAsync("DataListFilter", 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($"DataList/list?DataListKey=TestWidgetDataList&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 (JArray ja in v)
|
||||
{
|
||||
JObject o = ja[0] as JObject;
|
||||
if (IncludedWidgetId == o["v"].Value<long>())
|
||||
InclusiveMatchCount++;
|
||||
if (ExcludedWidgetId == o["v"].Value<long>())
|
||||
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("DataListFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(a, 204);
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#endregion DATE REGULAR FILTERS
|
||||
//========
|
||||
|
||||
Reference in New Issue
Block a user