using System;
using Xunit;
using Newtonsoft.Json.Linq;
using FluentAssertions;
using System.Collections.Generic;
using System.Collections.Concurrent;

namespace raven_integration
{


    /*

    EVERY TYPE, EVERY OP

    Using the widget object test all filtering options 
    for all data types, all operation types

    This is the supertest to always confirm the filtering code is working as expected.


     */

    public class DataFilterFilteringLists
    {
       





        ///////////////////////////////////////////////////////////////////////////////
        //DATE
        //

        #region DATE FILTER TESTS

        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]}";

       


        #region DATE REGULAR FILTERS

        /// <summary>
        /// 
        /// </summary>
        [Fact]
        public async void DateOpEqualityFilterWorks()
        {

            var WidgetNameStart = "DateOpEqualityFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = new DateTime(1968, 3, 12, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1968, 3, 12, 11, 0, 0).ToUniversalTime();

            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 = new DateTime(1968, 3, 10, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1968, 3, 10, 11, 0, 0).ToUniversalTime();

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = new DateTime(1968, 3, 12, 10, 0, 0).ToUniversalTime();
            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 DateOpGreaterThanFilterWorks()
        {

            var WidgetNameStart = "DateOpGreaterThanFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = new DateTime(1970, 3, 12, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1970, 3, 12, 11, 0, 0).ToUniversalTime();

            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 = new DateTime(1968, 3, 10, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1968, 3, 10, 11, 0, 0).ToUniversalTime();

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpGreaterThan;
            FilterItem.value = new DateTime(1970, 3, 12, 9, 0, 0).ToUniversalTime();
            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 DateOpGreaterThanOrEqualToFilterWorks()
        {

            var WidgetNameStart = "DateOpGreaterThanOrEqualToFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = new DateTime(1970, 3, 12, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1970, 3, 12, 11, 0, 0).ToUniversalTime();

            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 = new DateTime(1968, 3, 10, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1968, 3, 10, 11, 0, 0).ToUniversalTime();

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpGreaterThanOrEqualTo;
            FilterItem.value = new DateTime(1970, 3, 12, 10, 0, 0).ToUniversalTime();
            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 DateOpLessThanFilterWorks()
        {

            var WidgetNameStart = "DateOpLessThanFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = new DateTime(1970, 3, 12, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1970, 3, 12, 11, 0, 0).ToUniversalTime();

            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 = new DateTime(1970, 4, 10, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1970, 4, 10, 11, 0, 0).ToUniversalTime();

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpLessThan;
            FilterItem.value = new DateTime(1970, 3, 12, 11, 0, 0).ToUniversalTime();
            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 DateOpLessThanOrEqualToFilterWorks()
        {

            var WidgetNameStart = "DateOpLessThanOrEqualToFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = new DateTime(1970, 3, 12, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1970, 3, 12, 11, 0, 0).ToUniversalTime();

            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 = new DateTime(1970, 4, 10, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1970, 4, 10, 11, 0, 0).ToUniversalTime();

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpLessThanOrEqualTo;
            FilterItem.value = new DateTime(1970, 3, 12, 10, 0, 0).ToUniversalTime();
            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 DateOpNotEqualToFilterWorks()
        {

            var WidgetNameStart = "DateOpNotEqualToFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = new DateTime(1970, 3, 12, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1970, 3, 12, 11, 0, 0).ToUniversalTime();

            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 = new DateTime(1970, 4, 10, 10, 0, 0).ToUniversalTime();
            w.endDate = new DateTime(1970, 4, 10, 11, 0, 0).ToUniversalTime();

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpNotEqual;
            FilterItem.value = new DateTime(1970, 4, 10, 10, 0, 0).ToUniversalTime();
            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 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.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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            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("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 DateTokenTodayFilterWorks()
        {

            var WidgetNameStart = "DateTokenTodayFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = DateTime.UtcNow;
            w.endDate = DateTime.UtcNow.AddHours(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.AddDays(-1);
            w.endDate = DateTime.UtcNow.AddHours(1).AddDays(-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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenToday;
            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 DateTokenTomorrowFilterWorks()
        {

            var WidgetNameStart = "DateTokenTomorrowFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = DateTime.UtcNow.AddDays(1);
            w.endDate = DateTime.UtcNow.AddDays(1).AddHours(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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenTomorrow;
            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 DateTokenLastWeekFilterWorks()
        {

            var WidgetNameStart = "DateTokenLastWeekFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //My theory is any date - 7 days is last week if you go sunday to sunday
            w.startDate = DateTime.UtcNow.AddDays(-7);
            w.endDate = DateTime.UtcNow.AddHours(1).AddDays(-7);

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenLastWeek;
            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 DateTokenThisWeekFilterWorks()
        {

            var WidgetNameStart = "DateTokenThisWeekFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = DateTime.UtcNow;
            w.endDate = DateTime.UtcNow.AddHours(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);
            //My theory is any date - 7 days is last week if you go sunday to sunday
            w.startDate = DateTime.UtcNow.AddDays(-7);
            w.endDate = DateTime.UtcNow.AddHours(1).AddDays(-7);


            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenThisWeek;
            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 DateTokenNextWeekFilterWorks()
        {

            var WidgetNameStart = "DateTokenNextWeekFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //My theory is any date + 7 days is next week if you go sunday to sunday
            w.startDate = DateTime.UtcNow.AddDays(7);
            w.endDate = DateTime.UtcNow.AddHours(1).AddDays(7);


            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenNextWeek;
            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 DateTokenLastMonthFilterWorks()
        {

            var WidgetNameStart = "DateTokenLastMonthFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //First day of this month minus 2 days equals second to last day of last month
            w.startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddDays(-2).ToUniversalTime();
            w.endDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddDays(-2).AddHours(1).ToUniversalTime();

            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);
            //Put it right at midnight this month to ensure boundaries are respected
            w.startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).ToUniversalTime();
            w.endDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddHours(1).ToUniversalTime();

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenLastMonth;
            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 DateTokenThisMonthFilterWorks()
        {

            var WidgetNameStart = "DateTokenThisMonthFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //Put it right at midnight this month to ensure boundaries are respected
            w.startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).ToUniversalTime();
            w.endDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddHours(1).ToUniversalTime();

            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);
            //First day of this month minus 2 days equals second to last day of last month
            w.startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddDays(-2).ToUniversalTime();
            w.endDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddDays(-2).AddHours(1).ToUniversalTime();


            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenThisMonth;
            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 DateTokenNextMonthFilterWorks()
        {

            var WidgetNameStart = "DateTokenNextMonthFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //Put it right at midnight next month to ensure boundaries are respected
            w.startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddMonths(1).ToUniversalTime();
            w.endDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddMonths(1).AddHours(1).ToUniversalTime();

            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);
            //First day of next month minus 1 second
            w.startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddMonths(1).AddSeconds(-1).ToUniversalTime();
            w.endDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1, 00, 00, 00).AddMonths(1).AddSeconds(-1).AddHours(1).ToUniversalTime();


            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenNextMonth;
            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
            //SELECT *, xmin FROM AWIDGET  where name Like 'DateTokenNextMonthFilterWorks%' AND startdate >'2019-01-01T15:59:59.0000000Z' AND startdate <'2019-02-01T16:00:00.0000000Z'
            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 DateToken14DayWindowFilterWorks()
        {

            var WidgetNameStart = "DateToken14DayWindowFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);

            w.startDate = DateTime.UtcNow;
            w.endDate = DateTime.UtcNow.AddHours(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);
            //9 days ago will be outside the 14 day window
            w.startDate = DateTime.UtcNow.AddDays(-9);
            w.endDate = DateTime.UtcNow.AddDays(-9).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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenFourteenDayWindow;
            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 DateTokenPastFilterWorks()
        {

            var WidgetNameStart = "DateTokenPastFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //Test if for the past, definitely going to be in the past when the list is fetched after saving, but will it work with the server on another machine??
            //Best to pad in 5 minutes to be on the safe side, these days no two computers on earth should be out by more than 5 minutes to UTC from each other      
            w.startDate = DateTime.UtcNow.AddMinutes(-5);
            w.endDate = DateTime.UtcNow.AddMinutes(-5).AddHours(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);
            //8 days ago will be outside the 14 day window
            w.startDate = DateTime.UtcNow.AddMonths(1);
            w.endDate = DateTime.UtcNow.AddMonths(1).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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenPast;
            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 DateTokenFutureFilterWorks()
        {

            var WidgetNameStart = "DateTokenFutureFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //####
            w.startDate = DateTime.UtcNow.AddMinutes(5);
            w.endDate = DateTime.UtcNow.AddMinutes(5).AddHours(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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenFuture;
            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 DateTokenLastYearFilterWorks()
        {

            var WidgetNameStart = "DateTokenLastYearFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //####
            w.startDate = DateTime.UtcNow.AddYears(-1).AddMinutes(-5);
            w.endDate = DateTime.UtcNow.AddYears(-1).AddMinutes(-5).AddHours(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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenLastYear;
            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 DateTokenThisYearFilterWorks()
        {

            var WidgetNameStart = "DateTokenThisYearFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //####
            w.startDate = DateTime.UtcNow;
            w.endDate = DateTime.UtcNow.AddHours(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.AddYears(-1).AddMinutes(-5);
            w.endDate = DateTime.UtcNow.AddYears(-1).AddMinutes(-5).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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenThisYear;
            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 DateTokenInTheLast3MonthsFilterWorks()
        {

            var WidgetNameStart = "DateTokenInTheLast3MonthsFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //####
            w.startDate = DateTime.UtcNow.AddMonths(-3).AddMinutes(5);
            w.endDate = DateTime.UtcNow.AddMonths(-3).AddMinutes(5).AddHours(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.AddMonths(-3).AddMinutes(-5);
            w.endDate = DateTime.UtcNow.AddMonths(-3).AddMinutes(-5).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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenInTheLast3Months;
            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 DateTokenInTheLast6MonthsFilterWorks()
        {

            var WidgetNameStart = "DateTokenInTheLast6MonthsFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //####
            w.startDate = DateTime.UtcNow.AddMonths(-6).AddMinutes(5);
            w.endDate = DateTime.UtcNow.AddMonths(-6).AddMinutes(5).AddHours(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.AddMonths(-6).AddMinutes(-5);
            w.endDate = DateTime.UtcNow.AddMonths(-6).AddMinutes(-5).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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenInTheLast6Months;
            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 DateTokenInTheLastYearFilterWorks()
        {

            var WidgetNameStart = "DateTokenInTheLastYearFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //CREATE TEST WIDGETS 

            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            //####
            w.startDate = DateTime.UtcNow.AddDays(-365).AddMinutes(5);
            w.endDate = DateTime.UtcNow.AddDays(-365).AddMinutes(5).AddHours(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.AddDays(-365).AddMinutes(-5);
            w.endDate = DateTime.UtcNow.AddDays(-365).AddMinutes(-5).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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = TokenInTheLastYear;
            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 DATE REGULAR FILTERS

        #region DATE TOKEN FILTERS

     


        /// <summary>
        /// 
        /// </summary>
        [Fact]
        public async void DateTokenYearToDateFilterWorks()
        {

            var WidgetNameStart = "DateTokenYearToDateFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //BUILD DATES FOR THIS TEST

            DateTime InclusiveStartDate;
            DateTime ExclusiveStartDate;

            //################################################################################## 
            var FilterToken = TokenYearToDate;
            InclusiveStartDate = new DateTime(DateTime.Now.Year, 1, 1, 00, 5, 00).ToUniversalTime();
            ExclusiveStartDate = new DateTime(DateTime.Now.Year - 1, 4, 1, 00, 5, 00).ToUniversalTime();
            //##################################################################################


            DateTime InclusiveEndDate = InclusiveStartDate.AddHours(1);
            DateTime ExclusiveEndDate = ExclusiveStartDate.AddHours(1);

            //CREATE TEST WIDGETS 
            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = InclusiveStartDate;
            w.endDate = InclusiveEndDate;


            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 = ExclusiveStartDate;
            w.endDate = ExclusiveEndDate;

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = FilterToken;
            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 DateTokenPast90DaysFilterWorks()
        {

            var WidgetNameStart = "DateTokenPast90DaysFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //BUILD DATES FOR THIS TEST

            DateTime InclusiveStartDate;
            DateTime ExclusiveStartDate;

            //################################################################################## 
            var FilterToken = TokenPast90Days;
            InclusiveStartDate = DateTime.UtcNow.AddDays(-90).AddMinutes(5).ToUniversalTime();
            ExclusiveStartDate = DateTime.UtcNow.AddDays(-90).AddMinutes(-5).ToUniversalTime();
            //##################################################################################


            DateTime InclusiveEndDate = InclusiveStartDate.AddHours(1);
            DateTime ExclusiveEndDate = ExclusiveStartDate.AddHours(1);

            //CREATE TEST WIDGETS 
            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = InclusiveStartDate;
            w.endDate = InclusiveEndDate;


            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 = ExclusiveStartDate;
            w.endDate = ExclusiveEndDate;

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = FilterToken;
            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 DateTokenPast30DaysFilterWorks()
        {

            var WidgetNameStart = "DateTokenPast30DaysFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //BUILD DATES FOR THIS TEST

            DateTime InclusiveStartDate;
            DateTime ExclusiveStartDate;

            //################################################################################## 
            var FilterToken = TokenPast30Days;
            InclusiveStartDate = DateTime.UtcNow.AddDays(-30).AddMinutes(5).ToUniversalTime();
            ExclusiveStartDate = DateTime.UtcNow.AddDays(-30).AddMinutes(-5).ToUniversalTime();
            //##################################################################################


            DateTime InclusiveEndDate = InclusiveStartDate.AddHours(1);
            DateTime ExclusiveEndDate = ExclusiveStartDate.AddHours(1);

            //CREATE TEST WIDGETS 
            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = InclusiveStartDate;
            w.endDate = InclusiveEndDate;


            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 = ExclusiveStartDate;
            w.endDate = ExclusiveEndDate;

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = FilterToken;
            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 DateTokenPast24HoursFilterWorks()
        {

            var WidgetNameStart = "DateTokenPast24HoursFilterWorks";

            long IncludedWidgetId = 0;
            long ExcludedWidgetId = 0;

            //BUILD DATES FOR THIS TEST

            DateTime InclusiveStartDate;
            DateTime ExclusiveStartDate;

            //################################################################################## 
            var FilterToken = TokenPast24Hours;
            InclusiveStartDate = DateTime.UtcNow.AddHours(-24).AddMinutes(5).ToUniversalTime();
            ExclusiveStartDate = DateTime.UtcNow.AddHours(-24).AddMinutes(-5).ToUniversalTime();
            //##################################################################################


            DateTime InclusiveEndDate = InclusiveStartDate.AddHours(1);
            DateTime ExclusiveEndDate = ExclusiveStartDate.AddHours(1);

            //CREATE TEST WIDGETS 
            //included widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.startDate = InclusiveStartDate;
            w.endDate = InclusiveEndDate;


            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 = ExclusiveStartDate;
            w.endDate = ExclusiveEndDate;

            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.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //## INCLUSIVE FILTER
            dynamic FilterItem = new JObject();
            FilterItem.fld = "startdate";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = FilterToken;
            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 date token filters
        //========

        #endregion date filter tests



        ///////////////////////////////////////////////////////////////////////////////
        //TEXT
        //

        #region STRING FILTER TESTS

        /// <summary>
        /// 
        /// </summary>
        [Fact]
        public async void TextOpEqualityFilterWorks()
        {

            var TestName = "TextOpEqualityFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "aardvark";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "zebra";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpEquality;
            DataFilterActive.value = "aardvark";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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>
        /// Specifically test a string with an apostrophe in it (for inclusive)
        /// </summary>
        [Fact]
        public async void TextApostropheOpEqualityFilterWorks()
        {

            var TestName = "TextApostropheOpEqualityFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "O'Flaherty's pub";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Outback steak house";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpEquality;
            DataFilterActive.value = "O'Flaherty's pub";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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>
        /// specifically test a string with an ampersand character in it for inclusive (finding it)
        /// </summary>
        [Fact]
        public async void TextAmpersandOpEqualityFilterWorks()
        {

            var TestName = "TextAmpersandOpEqualityFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Bill & Ted's excellent adventure";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Strange things are afoot at the Circle-K";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpEquality;
            DataFilterActive.value = "Bill & Ted's excellent adventure";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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>
        /// specifically test a non english unicode string
        /// </summary>
        [Fact]
        public async void TextUnicodeOpEqualityFilterWorks()
        {

            var TestName = "TextUnicodeOpEqualityFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget 
            var InclusiveTestString = "Ādam Iñtërnâtiônàližætiøn";
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = InclusiveTestString;
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Adam Internationalization";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpEquality;
            DataFilterActive.value = InclusiveTestString;
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 TextOpGreaterThanFilterWorks()
        {

            var TestName = "TextOpGreaterThanFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget             
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Alabama";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Aardvark";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpGreaterThan;
            DataFilterActive.value = "Aardvark";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 TextOpGreaterThanOrEqualToFilterWorks()
        {

            var TestName = "TextOpGreaterThanOrEqualToFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget             
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Bjorn";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Bing";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpGreaterThanOrEqualTo;
            DataFilterActive.value = "Bjarn";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 TextOpLessThanFilterWorks()
        {

            var TestName = "TextOpLessThanFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget             
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "California";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Cthulu";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpLessThan;
            DataFilterActive.value = "Celery";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 TextOpLessThanOrEqualToFilterWorks()
        {

            var TestName = "TextOpLessThanOrEqualToFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget             
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Donut";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Duvet";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpLessThanOrEqualTo;
            DataFilterActive.value = "Dusseldorf";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 TextOpNotEqualFilterWorks()
        {

            var TestName = "TextOpNotEqualFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget             
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Egg Salad Sandwich";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Elephant";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpNotEqual;
            DataFilterActive.value = "Elephant";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 TextOpNotContainsFilterWorks()
        {
            var TestName = "TextOpNotContainsFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget             
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Gray poupon";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Get shorty";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpNotContains;
            DataFilterActive.value = "short";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 TextOpContainsFilterWorks()
        {
            var TestName = "TextOpContainsFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget             
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Fast Freddy Freak";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Phineas Freak";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpContains;
            DataFilterActive.value = "red";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 TextOpStartsWithFilterWorks()
        {
            var TestName = "TextOpStartsWithFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget             
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Granular";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Gus Grifferson";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpStartsWith;
            DataFilterActive.value = "Gra";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 TextOpEndsWithFilterWorks()
        {
            var TestName = "TextOpEndsWithFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget             
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Bo Horvat";
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.notes = "Bo Duke";
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "notes";
            DataFilterActive.op = Util.OpEndsWith;
            DataFilterActive.value = "vat";
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 string filter tests

        ///////////////////////////////////////////////////////////////////////////////
        //INT
        //
        #region INTEGER TESTS

        /// <summary>
        /// 
        /// </summary>
        [Fact]
        public async void IntegerOpEqualityFilterWorks()
        {

            var WidgetNameStart = "IntegerDataFilterTest";

            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.count = 5;

            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.count = 3;
            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("Test INT DataFilter");
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "count";
            FilterItem.op = Util.OpEquality;
            FilterItem.value = 5;
            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 IntegerOpGreaterThanFilterWorks()
        {

            var WidgetNameStart = "IntegerOpGreaterThanFilterWorks";

            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.count = 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.count = -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("Test INT DataFilter");
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "count";
            FilterItem.op = Util.OpGreaterThan;
            FilterItem.value = 54;
            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 IntegerOpGreaterThanOrEqualToFilterWorks()
        {

            var WidgetNameStart = "IntegerOpGreaterThanOrEqualToFilterWorks";

            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.count = 555;

            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.count = 554;
            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("IntegerOpGreaterThanOrEqualToFilterWorks");
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "count";
            FilterItem.op = Util.OpGreaterThanOrEqualTo;
            FilterItem.value = 555;
            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 IntegerOpLessThanFilterWorks()
        {

            var WidgetNameStart = "IntegerOpLessThanFilterWorks";

            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.count = -5555;

            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.count = 5555;
            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("IntegerOpLessThanFilterWorks");
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "count";
            FilterItem.op = Util.OpLessThan;
            FilterItem.value = 5555;
            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 IntegerOpLessThanOrEqualToFilterWorks()
        {

            var WidgetNameStart = "IntegerOpLessThanOrEqualToFilterWorks";

            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.count = -444;

            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.count = -443;
            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("IntegerOpLessThanOrEqualToFilterWorks");
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "count";
            FilterItem.op = Util.OpLessThanOrEqualTo;
            FilterItem.value = -444;
            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 IntegerNotEqualToFilterWorks()
        {

            var WidgetNameStart = "IntegerNotEqualToFilterWorks";

            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.count = 222;

            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.count = 223;
            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("IntegerNotEqualToFilterWorks");
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "count";
            FilterItem.op = Util.OpNotEqual;
            FilterItem.value = 223;
            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 integer tests


        ///////////////////////////////////////////////////////////////////////////////
        //BOOL
        //

        #region BOOLEAN TESTS

        /// <summary>
        /// 
        /// </summary>
        [Fact]
        public async void BoolOpEqualityFilterWorks()
        {

            //OPS: equal to, not equal to
            //values: true, false

            var WidgetNameStart = "BoolDataFilterTest";

            List<long> ActiveWidgetIdList = new List<long>();
            List<long> NotActiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two active and two non active

            //first active widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.active = true;
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second active widget
            w.name = Util.Uniquify(WidgetNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //first NON active widget
            w.name = Util.Uniquify(WidgetNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            NotActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second NON active widget
            w.name = Util.Uniquify(WidgetNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            NotActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify("Test BOOL DataFilter");
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "active";
            DataFilterActive.op = Util.OpEquality;
            DataFilterActive.value = true;
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int nActiveMatches = 0;
            int nInactiveMatches = 0;
            foreach (JObject o in v)
            {
                if (ActiveWidgetIdList.Contains(o["id"].Value<long>()))
                    nActiveMatches++;
                if (NotActiveWidgetIdList.Contains(o["id"].Value<long>()))
                    nInactiveMatches++;
            }

            nActiveMatches.Should().Be(ActiveWidgetIdList.Count);
            nInactiveMatches.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in ActiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in NotActiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 BoolOpNotEqualFilterWorks()
        {

            //OPS: equal to, not equal to
            //values: true, false

            var WidgetNameStart = "BoolDataFilterTest";

            List<long> ActiveWidgetIdList = new List<long>();
            List<long> NotActiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two active and two non active

            //first active widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetNameStart);
            w.active = true;
            w.roles = 0;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second active widget
            w.name = Util.Uniquify(WidgetNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //first NON active widget
            w.name = Util.Uniquify(WidgetNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            NotActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second NON active widget
            w.name = Util.Uniquify(WidgetNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            NotActiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify("Test BOOL DataFilter");
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //active bool test filter
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "active";
            DataFilterActive.op = Util.OpNotEqual;
            DataFilterActive.value = true;
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int nActiveMatches = 0;
            int nInactiveMatches = 0;
            foreach (JObject o in v)
            {
                if (ActiveWidgetIdList.Contains(o["id"].Value<long>()))
                    nActiveMatches++;
                if (NotActiveWidgetIdList.Contains(o["id"].Value<long>()))
                    nInactiveMatches++;
            }

            nInactiveMatches.Should().Be(NotActiveWidgetIdList.Count);
            nActiveMatches.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in ActiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in NotActiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 boolean tests


        ///////////////////////////////////////////////////////////////////////////////
        //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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "dollaramount";
            FilterItem.op = Util.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "dollaramount";
            FilterItem.op = Util.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "dollaramount";
            FilterItem.op = Util.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "dollaramount";
            FilterItem.op = Util.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "dollaramount";
            FilterItem.op = Util.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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetNameStart;
            dfilter.Add(DataFilterNameStart);

            //inclusive test filter

            dynamic FilterItem = new JObject();
            FilterItem.fld = "dollaramount";
            FilterItem.op = Util.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
        //
        #region TAG TESTS

        /// <summary>
        /// 
        /// </summary>
        [Fact]
        public async void TagFilterWorks()
        {

            var TestName = "TagFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            //Tags 
            dynamic InclusiveTagsArray = new JArray();
            InclusiveTagsArray.Add("red-tag-test");
            InclusiveTagsArray.Add("orange-tag-test");
            InclusiveTagsArray.Add("yellow-tag-test");
            InclusiveTagsArray.Add("green-tag-test");
            InclusiveTagsArray.Add("blue-tag-test");
            InclusiveTagsArray.Add("indigo-tag-test");
            InclusiveTagsArray.Add("violet-tag-test");
            w.tags = InclusiveTagsArray;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            //Tags 
            dynamic ExclusiveTagsArray = new JArray();
            ExclusiveTagsArray.Add("crimson-tag-test");
            ExclusiveTagsArray.Add("amber-tag-test");
            ExclusiveTagsArray.Add("saffron-tag-test");
            ExclusiveTagsArray.Add("emerald-tag-test");
            ExclusiveTagsArray.Add("azure-tag-test");
            ExclusiveTagsArray.Add("red-tag-test");
            ExclusiveTagsArray.Add("blue-tag-test");
            ExclusiveTagsArray.Add("cobalt-tag-test");
            ExclusiveTagsArray.Add("magenta-tag-test");
            w.tags = ExclusiveTagsArray;//Missing green

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active test filter            
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "tags";
            DataFilterActive.op = Util.OpEquality;
            dynamic FilterTagsArray = new JArray();
            FilterTagsArray.Add("red-tag-test");
            FilterTagsArray.Add("green-tag-test");//green is the only one missing from the exclusive widget
            FilterTagsArray.Add("blue-tag-test");
            DataFilterActive.value = FilterTagsArray;
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 UnicodeTagFilterWorks()
        {

            var TestName = "UnicodeTagFilterWorks";
            var WidgetRunNameStart = Util.Uniquify(TestName);

            List<long> InclusiveWidgetIdList = new List<long>();
            List<long> ExclusiveWidgetIdList = new List<long>();

            //CREATE 4 TEST WIDGETS 
            //two inclusive and two not inclusive

            //first inclusive widget          
            dynamic w = new JObject();
            w.name = Util.Uniquify(WidgetRunNameStart);
            //Tags 
            dynamic InclusiveTagsArray = new JArray();
            InclusiveTagsArray.Add("red-tag-test");
            InclusiveTagsArray.Add("orange-tag-test");
            InclusiveTagsArray.Add("Ādam Iñtërnâtiônàližætiøn");
            w.tags = InclusiveTagsArray;

            ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second inclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //first exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            //Tags 
            dynamic ExclusiveTagsArray = new JArray();
            ExclusiveTagsArray.Add("crimson-tag-test");
            ExclusiveTagsArray.Add("amber-tag-test");
            ExclusiveTagsArray.Add("saffron-tag-test");
            ExclusiveTagsArray.Add("emerald-tag-test");
            ExclusiveTagsArray.Add("azure-tag-test");
            ExclusiveTagsArray.Add("red-tag-test");
            ExclusiveTagsArray.Add("blue-tag-test");
            ExclusiveTagsArray.Add("cobalt-tag-test");
            ExclusiveTagsArray.Add("magenta-tag-test");
            w.tags = ExclusiveTagsArray;//Missing green

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());

            //second exclusive widget
            w.name = Util.Uniquify(WidgetRunNameStart);
            w.active = false;

            a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
            Util.ValidateDataReturnResponseOk(a);
            ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());


            //CREATE FILTER
            dynamic d = new JObject();
            d.name = Util.Uniquify(WidgetRunNameStart);
            // 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 = Util.OpStartsWith;
            DataFilterNameStart.value = WidgetRunNameStart;
            dfilter.Add(DataFilterNameStart);

            //active test filter            
            dynamic DataFilterActive = new JObject();
            DataFilterActive.fld = "tags";
            DataFilterActive.op = Util.OpEquality;
            dynamic FilterTagsArray = new JArray();
            FilterTagsArray.Add("red-tag-test");
            FilterTagsArray.Add("Ādam Iñtërnâtiônàližætiøn");
            DataFilterActive.value = FilterTagsArray;
            dfilter.Add(DataFilterActive);

            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 two records
            ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
            var v = ((JArray)a.ObjectResponse["data"]);
            List<long> IDInResultList = new List<long>();
            int InclusiveMatchCount = 0;
            int ExclusiveMatchCount = 0;
            foreach (JObject o in v)
            {
                if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    InclusiveMatchCount++;
                if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
                    ExclusiveMatchCount++;
            }

            InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
            ExclusiveMatchCount.Should().Be(0);

            //DELETE WIDGETS
            foreach (long l in InclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
                Util.ValidateHTTPStatusCode(a, 204);
            }

            foreach (long l in ExclusiveWidgetIdList)
            {
                a = await Util.DeleteAsync("Widget/" + l.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 tag tests
        //==================================================

    }//eoc
}//eons
