From 8937aa0e9a4c98bbdb264a5736843210cbf90418 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 14 Feb 2020 22:56:56 +0000 Subject: [PATCH] --- DataList/DataListFiltering.cs | 68 ++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/DataList/DataListFiltering.cs b/DataList/DataListFiltering.cs index 66a9626..acefcca 100644 --- a/DataList/DataListFiltering.cs +++ b/DataList/DataListFiltering.cs @@ -659,7 +659,7 @@ same as the server does but in a central location here for all tests to use. dynamic filter = new JObject(); dynamic items = new JArray(); - + dynamic fitem = new JObject(); fitem.op = Util.OpGreaterThanOrEqualTo; fitem.value = new DateTime(2019, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime(); @@ -675,10 +675,10 @@ same as the server does but in a central location here for all tests to use. d.filter = filter; dListView.Add(d); -/* -"SELECT awidget.id AS df, awidget.name, awidget.id, awidget.startdate from awidget left outer join auser on (awidget.userid=auser.id) where (awidget.name Like 'DateOpBetweenFilterWorks%') AND ((awidget.startdate >='2019-03-12T18:00:00.0000000') AND awidget.startdate Is Null OR awidget.startdate <='2019-03-12T19:00:00.9990000Z')) ORDER BY awidget.id DESC LIMIT 999 OFFSET 0" -" where (awidget.name Like 'DateOpBetweenFilterWorks%') AND ((awidget.startdate >='2019-03-12T18:00:00.0000000') AND awidget.startdate Is Null OR awidget.startdate <='2019-03-12T19:00:00.9990000Z'))" -*/ + /* + "SELECT awidget.id AS df, awidget.name, awidget.id, awidget.startdate from awidget left outer join auser on (awidget.userid=auser.id) where (awidget.name Like 'DateOpBetweenFilterWorks%') AND ((awidget.startdate >='2019-03-12T18:00:00.0000000') AND awidget.startdate Is Null OR awidget.startdate <='2019-03-12T19:00:00.9990000Z')) ORDER BY awidget.id DESC LIMIT 999 OFFSET 0" + " where (awidget.name Like 'DateOpBetweenFilterWorks%') AND ((awidget.startdate >='2019-03-12T18:00:00.0000000') AND awidget.startdate Is Null OR awidget.startdate <='2019-03-12T19:00:00.9990000Z'))" + */ //FETCH DATALIST @@ -3705,5 +3705,63 @@ same as the server does but in a central location here for all tests to use. #endregion tag tests //================================================== + /////////////////////////////////////////////////////////////////////////////// + //FILTER BY ID VALUE + // + #region ID FILTER TESTS + + /// + /// + /// + [Fact] + public async void IdFilterWorks() + { + + var TestName = "IdFilterWorks"; + var WidgetNameStart = Util.Uniquify(TestName); + + //CREATE WIDGET + dynamic w = new JObject(); + w.name = Util.Uniquify(WidgetNameStart); + w.customFields = Util.WidgetRequiredCustomFieldsJsonString(); + w.notes = "ID FILTER NOTES"; + w.usertype = 1; + + ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString()); + Util.ValidateDataReturnResponseOk(a); + long Id = a.ObjectResponse["data"]["id"].Value(); + + + //CREATE LISTVIEW + dynamic dListView = new JArray(); + //FILTER + dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetname", Util.OpEquality, Id)); + //FETCH DATALIST + a = await Util.PostAsync($"DataList", await Util.GetTokenAsync("manager", "l3tm3in"), Util.BuildDataListRequestEx(dListView)); + + Util.ValidateDataReturnResponseOk(a); + Util.ValidateHTTPStatusCode(a, 200); + + //assert contains ONE record ONLY + ((JArray)a.ObjectResponse["data"]).Count.Should().Be(1); + //assert it's ours + ((JArray)a.ObjectResponse["data"])[0][0]["v"].Value().Should().Be(Id); + // v[0]["v"].Value() + + //DELETE WIDGET + a = await Util.DeleteAsync("Widget/" + Id.ToString(), await Util.GetTokenAsync("BizAdminFull")); + Util.ValidateHTTPStatusCode(a, 204); + + + + } + + + + + + #endregion ID filter tests + //================================================== + }//eoc }//eons