From 243536e5247dfc67e5d3b7915fc9783bc4b7259f Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 23 Jan 2020 15:25:51 +0000 Subject: [PATCH] --- DataFilter/DataFilterFilteringLists.cs | 128 ++++++++++++++----------- 1 file changed, 71 insertions(+), 57 deletions(-) diff --git a/DataFilter/DataFilterFilteringLists.cs b/DataFilter/DataFilterFilteringLists.cs index 8fff462..f8718c4 100644 --- a/DataFilter/DataFilterFilteringLists.cs +++ b/DataFilter/DataFilterFilteringLists.cs @@ -135,7 +135,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = new DateTime(1968, 3, 12, 10, 0, 0).ToUniversalTime(); dfilter.Add(FilterItem); @@ -158,11 +158,20 @@ same as the server does but in a central location here for all tests to use. List IDInResultList = new List(); int InclusiveMatchCount = 0; int ExclusiveMatchCount = 0; - foreach (JObject o in v) + // foreach (JObject o in v) + // { + // if (IncludedWidgetId == o["id"].Value()) + // InclusiveMatchCount++; + // if (ExcludedWidgetId == o["id"].Value())//whups + // ExclusiveMatchCount++; + // } + foreach (JArray ja in v) { - if (IncludedWidgetId == o["id"].Value()) + JObject o = ja[0] as JObject; + + if (IncludedWidgetId == o["v"].Value()) InclusiveMatchCount++; - if (ExcludedWidgetId == o["id"].Value())//whups + if (ExcludedWidgetId == o["v"].Value()) ExclusiveMatchCount++; } @@ -237,7 +246,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpGreaterThan; FilterItem.value = new DateTime(1970, 3, 12, 9, 0, 0).ToUniversalTime(); dfilter.Add(FilterItem); @@ -339,7 +348,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpGreaterThanOrEqualTo; FilterItem.value = new DateTime(1970, 3, 12, 10, 0, 0).ToUniversalTime(); dfilter.Add(FilterItem); @@ -440,7 +449,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpLessThan; FilterItem.value = new DateTime(1970, 3, 12, 11, 0, 0).ToUniversalTime(); dfilter.Add(FilterItem); @@ -542,7 +551,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpLessThanOrEqualTo; FilterItem.value = new DateTime(1970, 3, 12, 10, 0, 0).ToUniversalTime(); dfilter.Add(FilterItem); @@ -644,7 +653,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpNotEqual; FilterItem.value = new DateTime(1970, 4, 10, 10, 0, 0).ToUniversalTime(); dfilter.Add(FilterItem); @@ -746,7 +755,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenYesterday; dfilter.Add(FilterItem); @@ -849,7 +858,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenToday; dfilter.Add(FilterItem); @@ -951,7 +960,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenTomorrow; dfilter.Add(FilterItem); @@ -1053,7 +1062,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenLastWeek; dfilter.Add(FilterItem); @@ -1156,7 +1165,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenThisWeek; dfilter.Add(FilterItem); @@ -1260,7 +1269,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenNextWeek; dfilter.Add(FilterItem); @@ -1363,7 +1372,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenLastMonth; dfilter.Add(FilterItem); @@ -1469,7 +1478,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenThisMonth; dfilter.Add(FilterItem); @@ -1578,7 +1587,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenNextMonth; dfilter.Add(FilterItem); @@ -1683,7 +1692,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenFourteenDayWindow; dfilter.Add(FilterItem); @@ -1789,7 +1798,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenPast; dfilter.Add(FilterItem); @@ -1892,7 +1901,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenFuture; dfilter.Add(FilterItem); @@ -1996,7 +2005,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenLastYear; dfilter.Add(FilterItem); @@ -2102,7 +2111,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenThisYear; dfilter.Add(FilterItem); @@ -2208,7 +2217,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenInTheLast3Months; dfilter.Add(FilterItem); @@ -2311,7 +2320,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenInTheLast6Months; dfilter.Add(FilterItem); @@ -2414,7 +2423,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = TokenInTheLastYear; dfilter.Add(FilterItem); @@ -2536,7 +2545,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = FilterToken; dfilter.Add(FilterItem); @@ -2653,7 +2662,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = FilterToken; dfilter.Add(FilterItem); @@ -2768,7 +2777,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = FilterToken; dfilter.Add(FilterItem); @@ -2884,7 +2893,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = FilterToken; dfilter.Add(FilterItem); @@ -2990,7 +2999,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -3094,7 +3103,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -3199,7 +3208,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -3304,7 +3313,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -3408,7 +3417,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -3514,7 +3523,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -3618,7 +3627,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -3723,7 +3732,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -3827,7 +3836,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -3931,7 +3940,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -4036,7 +4045,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -4140,7 +4149,7 @@ same as the server does but in a central location here for all tests to use. //## INCLUSIVE FILTER dynamic FilterItem = new JObject(); - FilterItem.fld = "startdate"; + FilterItem.fld = "widgetstartdate"; FilterItem.op = Util.OpEquality; FilterItem.value = DateTokenUnderTest; dfilter.Add(FilterItem); @@ -6445,7 +6454,7 @@ same as the server does but in a central location here for all tests to use. public async void BoolOpEqualityFilterWorks() { -TODO: This test now works, fix the rest, but...Maybe I should find a way to not duplicate so much code so this isn't needed again in future? + //OPS: equal to, not equal to //values: true, false @@ -6538,19 +6547,15 @@ TODO: This test now works, fix the rest, but...Maybe I should find a way to not List IDInResultList = new List(); int nActiveMatches = 0; int nInactiveMatches = 0; - //bugbug: now this is an array (should have been before no?) - //anyway it's not a jobject, the whole list is an array of arrays so the tests are probably all going to need hand tweaking - //blarg! + foreach (JArray ja in v) { - JObject o=ja[0] as JObject; - // foreach (JObject o in ja) - // { - if (ActiveWidgetIdList.Contains(o["v"].Value())) - nActiveMatches++; - if (NotActiveWidgetIdList.Contains(o["v"].Value())) - nInactiveMatches++; - //} + JObject o = ja[0] as JObject; + + if (ActiveWidgetIdList.Contains(o["v"].Value())) + nActiveMatches++; + if (NotActiveWidgetIdList.Contains(o["v"].Value())) + nInactiveMatches++; } nActiveMatches.Should().Be(ActiveWidgetIdList.Count); @@ -6673,11 +6678,20 @@ TODO: This test now works, fix the rest, but...Maybe I should find a way to not List IDInResultList = new List(); int nActiveMatches = 0; int nInactiveMatches = 0; - foreach (JObject o in v) + // foreach (JObject o in v) + // { + // if (ActiveWidgetIdList.Contains(o["id"].Value())) + // nActiveMatches++; + // if (NotActiveWidgetIdList.Contains(o["id"].Value())) + // nInactiveMatches++; + // } + foreach (JArray ja in v) { - if (ActiveWidgetIdList.Contains(o["id"].Value())) + JObject o = ja[0] as JObject; + + if (ActiveWidgetIdList.Contains(o["v"].Value())) nActiveMatches++; - if (NotActiveWidgetIdList.Contains(o["id"].Value())) + if (NotActiveWidgetIdList.Contains(o["v"].Value())) nInactiveMatches++; }