From 5582b085c3cba75028aeea49a86694a69f16e636 Mon Sep 17 00:00:00 2001 From: David Lebee Date: Mon, 22 Oct 2018 22:47:39 -0500 Subject: [PATCH] testing more advancing filtering. --- PoweredSoft.DynamicQuery.Test/FilterTests.cs | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/PoweredSoft.DynamicQuery.Test/FilterTests.cs b/PoweredSoft.DynamicQuery.Test/FilterTests.cs index d865dbf..e085baa 100644 --- a/PoweredSoft.DynamicQuery.Test/FilterTests.cs +++ b/PoweredSoft.DynamicQuery.Test/FilterTests.cs @@ -93,5 +93,41 @@ namespace PoweredSoft.DynamicQuery.Test Assert.Equal(resultShouldMatch, result.Data); }); } + + [Fact] + public void MoreComplexCompositeFilter() + { + MockContextFactory.SeedAndTestContextFor("FilterTests_MoreComplexCompositeFilter", TestSeeders.SimpleSeedScenario, ctx => + { + var resultShouldMatch = ctx.Customers.Where(t => (t.FirstName == "John" || t.LastName == "Norris") && t.FirstName.Contains("o")).ToList(); + + var criteria = new QueryCriteria() + { + Filters = new List + { + new CompositeFilter() + { + Type = FilterType.Composite, + Filters = new List + { + new SimpleFilter() { Path = "FirstName", Type = FilterType.Equal, Value = "John" }, + new SimpleFilter() { Path = "LastName", Type = FilterType.Equal, Value = "Norris"} + } + }, + new SimpleFilter() + { + And = true, + Path = "FirstName", + Type = FilterType.Contains, + Value = "o" + } + } + }; + + var queryHandler = new QueryHandler(); + var result = queryHandler.Execute(ctx.Customers, criteria); + Assert.Equal(resultShouldMatch, result.Data); + }); + } } }