public void TestFilterEqualsSingleNumberResultValidityEquals() { //arange var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { ID = 1 }); domainList.Add(new TestDomain { ID = 2 }); domainList.Add(new TestDomain { ID = 3 }); domainList.Add(new TestDomain { ID = 4 }); domainList.Add(new TestDomain { ID = 5 }); var filter = new FilterDTO(); filter.Id = 1; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(1, rez.FirstOrDefault().ID); }
public void TestFilterDouble() { //arange var domainList = new List <ExoticTestDomain>(); var filter = new ExoticFilterDTO(); IQueryable <ExoticTestDomain> query = domainList.AsQueryable(); //data domainList.Add(new ExoticTestDomain { DOUBLE_PROP = 1.1 }); domainList.Add(new ExoticTestDomain { DOUBLE_PROP = 2.2 }); domainList.Add(new ExoticTestDomain { DOUBLE_PROP = 3.3 }); //filter filter.DOUBLE_PROP = 1.1; //act query = FilterQuery.SetFilters <ExoticTestDomain, ExoticFilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(1, rez.Count); }
public void TestFilterFloatNullable() { //arange var domainList = new List <ExoticTestDomain>(); var filter = new ExoticFilterDTO(); IQueryable <ExoticTestDomain> query = domainList.AsQueryable(); //data domainList.Add(new ExoticTestDomain { FLOAT_PROP_NULLABLE = 1.1F }); domainList.Add(new ExoticTestDomain { FLOAT_PROP_NULLABLE = 2.2f }); domainList.Add(new ExoticTestDomain { FLOAT_PROP_NULLABLE = 3.3F }); //filter filter.FLOAT_PROP_NULLABLE = 1.1f; //act query = FilterQuery.SetFilters <ExoticTestDomain, ExoticFilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(1, rez.Count); }
public void TestFilterUshortNullable() { //arange var domainList = new List <ExoticTestDomain>(); var filter = new ExoticFilterDTO(); IQueryable <ExoticTestDomain> query = domainList.AsQueryable(); //data domainList.Add(new ExoticTestDomain { USHORT_PROP_NULLABLE = 1 }); domainList.Add(new ExoticTestDomain { USHORT_PROP_NULLABLE = 2 }); domainList.Add(new ExoticTestDomain { USHORT_PROP_NULLABLE = 3 }); //filter filter.USHORT_PROP_NULLABLE = 1; //act query = FilterQuery.SetFilters <ExoticTestDomain, ExoticFilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(1, rez.Count); }
public void TestFilterTextContains() { //arange var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { NAME = "da" }); domainList.Add(new TestDomain { NAME = "da" }); domainList.Add(new TestDomain { NAME = "ne" }); domainList.Add(new TestDomain { NAME = "ne" }); domainList.Add(new TestDomain { NAME = "DA" }); domainList.Add(new TestDomain { NAME = "NE" }); domainList.Add(new TestDomain { NAME = "d" }); domainList.Add(new TestDomain { NAME = "n" }); var filter = new FilterDTO(); filter.Name = "d"; FilterSettings settings = new FilterSettings(); settings.FilterName = "Name"; settings.PropertyComparison = QueryFiltering.Enums.PropertyComparisonTypeEnum.Contains; settings.ToLower = false; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter, settings.ToList()); var rez = query.ToList(); //assert Assert.AreEqual(3, rez.Count); }
public void TestFilterTextEqualsWithToLowerWithNullValue() { //arange var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { NAME = "da" }); domainList.Add(new TestDomain { NAME = "DA" }); domainList.Add(new TestDomain { NAME = "ne" }); domainList.Add(new TestDomain { NAME = "NE" }); domainList.Add(new TestDomain { NAME = "Da" }); domainList.Add(new TestDomain { NAME = "Ne" }); domainList.Add(new TestDomain { NAME = "dA" }); domainList.Add(new TestDomain { NAME = "Ne" }); domainList.Add(new TestDomain { NAME = null }); var filter = new FilterDTO(); filter.Name = "da"; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(4, rez.Count); }
public void TestCombinationAndTwoProperties() { //arange var dateNow = DateTime.Now; var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { ID = 1, NAME = "da", }); domainList.Add(new TestDomain { ID = 1, NAME = "da", }); domainList.Add(new TestDomain { ID = 1, NAME = "ne", }); domainList.Add(new TestDomain { ID = 2, NAME = "ne", }); domainList.Add(new TestDomain { ID = 2, NAME = "ne", }); var filter = new FilterDTO(); filter.Id = 1; filter.Name = "ne"; List <FilterSettings> settingsList = new List <FilterSettings> { new FilterSettings { FilterName = "Id", ExpressionCombination = QueryFiltering.Enums.ExpressionCombinationTypeEnum.And }, new FilterSettings { FilterName = "Name", ExpressionCombination = QueryFiltering.Enums.ExpressionCombinationTypeEnum.And } }; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter, settingsList); var rez = query.ToList(); //assert Assert.AreEqual(1, rez.Count); }
public void TestFilterContainsWithToLowerWithNull() { //arange var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { NAME = "da" }); domainList.Add(new TestDomain { NAME = "DA" }); domainList.Add(new TestDomain { NAME = "ne" }); domainList.Add(new TestDomain { NAME = "NE" }); domainList.Add(new TestDomain { NAME = "Da" }); domainList.Add(new TestDomain { NAME = "Ne" }); domainList.Add(new TestDomain { NAME = "dA" }); domainList.Add(new TestDomain { NAME = null }); var filter = new FilterDTO(); filter.Name = "d"; IQueryable <TestDomain> query = domainList.AsQueryable(); FilterSettings setting = new FilterSettings { FilterName = "Name", PropertyComparison = QueryFiltering.Enums.PropertyComparisonTypeEnum.Contains }; //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter, setting.ToList()); var rez = query.ToList(); //assert Assert.AreEqual(4, rez.Count); }
public void TestTextFilterEmptyTextEquals() { //arange var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { NAME = "da" }); domainList.Add(new TestDomain { NAME = "da" }); domainList.Add(new TestDomain { NAME = "ne" }); domainList.Add(new TestDomain { NAME = "ne" }); domainList.Add(new TestDomain { NAME = "DA" }); domainList.Add(new TestDomain { NAME = "NE" }); domainList.Add(new TestDomain { NAME = "d" }); domainList.Add(new TestDomain { NAME = "n" }); var filter = new FilterDTO(); filter.Name = ""; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(8, rez.Count); }
public void TestFilterDateResultLessOrEqualCount() { //arange var dateNow = DateTime.Now; var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { DATUM_TEST = dateNow }); domainList.Add(new TestDomain { DATUM_TEST = dateNow.AddDays(1) }); domainList.Add(new TestDomain { DATUM_TEST = dateNow.AddDays(2) }); domainList.Add(new TestDomain { DATUM_TEST = dateNow.AddDays(1) }); domainList.Add(new TestDomain { DATUM_TEST = dateNow.AddDays(2) }); var filter = new FilterDTO(); filter.DatumTest = dateNow; List <FilterSettings> settingsList = new List <FilterSettings> { new FilterSettings { FilterName = "DatumTest", PropertyComparison = QueryFiltering.Enums.PropertyComparisonTypeEnum.LessOrEqual } }; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter, settingsList); var rez = query.ToList(); //assert Assert.AreEqual(1, rez.Count); }
public void TestFilterLessMultipleResultResultValidityEquals() { //arange var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { ID = 0 }); domainList.Add(new TestDomain { ID = 1 }); domainList.Add(new TestDomain { ID = 2 }); domainList.Add(new TestDomain { ID = 3 }); domainList.Add(new TestDomain { ID = 4 }); domainList.Add(new TestDomain { ID = 5 }); var filter = new FilterDTO(); filter.Id = 1; List <FilterSettings> settingsList = new List <FilterSettings> { new FilterSettings { FilterName = "Id", PropertyComparison = QueryFiltering.Enums.PropertyComparisonTypeEnum.Less } }; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter, settingsList); var rez = query.ToList(); //assert Assert.IsTrue(rez.ElementAt(0).ID < 1, "The actual result was not less than 1"); }
public void TestFilterGreaterMultipleResultEquals() { //arange var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { ID = 1 }); domainList.Add(new TestDomain { ID = 2 }); domainList.Add(new TestDomain { ID = 3 }); domainList.Add(new TestDomain { ID = 4 }); domainList.Add(new TestDomain { ID = 5 }); var filter = new FilterDTO(); filter.Id = 1; List <FilterSettings> settingsList = new List <FilterSettings> { new FilterSettings { FilterName = "Id", PropertyComparison = QueryFiltering.Enums.PropertyComparisonTypeEnum.Greater } }; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter, settingsList); var rez = query.ToList(); //assert Assert.AreEqual(4, rez.Count); }
public void TestFilterTextResultValidity() { //arange var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { NAME = "da" }); domainList.Add(new TestDomain { NAME = "da" }); domainList.Add(new TestDomain { NAME = "ne" }); domainList.Add(new TestDomain { NAME = "ne" }); domainList.Add(new TestDomain { NAME = "DA" }); domainList.Add(new TestDomain { NAME = "NE" }); var filter = new FilterDTO(); filter.Name = "da"; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual("da", rez.ElementAt(0).NAME); }
public void TestFilterBoolDefault() { //arange var dateNow = DateTime.Now; var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { ID = 1, NAME = "da", DATUM_TEST = dateNow, BOOL_PROP = true, CHAR_PROP = 'a', DECIMAL_PROP = 1, INT_PROP = 1 }); domainList.Add(new TestDomain { ID = 1, NAME = "da", DATUM_TEST = dateNow, BOOL_PROP = true, CHAR_PROP = 'a', DECIMAL_PROP = 1, INT_PROP = 1 }); domainList.Add(new TestDomain { ID = 1, NAME = "da", DATUM_TEST = dateNow, BOOL_PROP = true, CHAR_PROP = 'a', DECIMAL_PROP = 1, INT_PROP = 1 }); domainList.Add(new TestDomain { ID = 1, NAME = "ne", DATUM_TEST = dateNow, BOOL_PROP = false, CHAR_PROP = 'b', DECIMAL_PROP = 2, INT_PROP = 2 }); domainList.Add(new TestDomain { ID = 1, NAME = "ne", DATUM_TEST = dateNow, BOOL_PROP = false, CHAR_PROP = 'b', DECIMAL_PROP = 2, INT_PROP = 2 }); var filter = new FilterDTO(); filter.BoolProp = false; IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(2, rez.Count); }
public void TestFilterDateResultTwoCount() { //arange var dateNow = DateTime.Now; var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { DATUM_TEST = dateNow }); domainList.Add(new TestDomain { DATUM_TEST = dateNow.AddDays(1) }); domainList.Add(new TestDomain { DATUM_TEST = dateNow.AddDays(2) }); domainList.Add(new TestDomain { DATUM_TEST = dateNow.AddDays(1) }); domainList.Add(new TestDomain { DATUM_TEST = dateNow.AddDays(2) }); var filter = new FilterDTO(); filter.DatumTest = dateNow.AddDays(1); IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, filter); var rez = query.ToList(); //assert Assert.AreEqual(2, rez.Count); }
public void TestNoFilter() { //arange var domainList = new List <TestDomain>(); domainList.Add(new TestDomain { NAME = "da" }); domainList.Add(new TestDomain { NAME = "da" }); domainList.Add(new TestDomain { NAME = "ne" }); domainList.Add(new TestDomain { NAME = "ne" }); domainList.Add(new TestDomain { NAME = "DA" }); domainList.Add(new TestDomain { NAME = "NE" }); domainList.Add(new TestDomain { NAME = "d" }); domainList.Add(new TestDomain { NAME = "n" }); IQueryable <TestDomain> query = domainList.AsQueryable(); //act query = FilterQuery.SetFilters <TestDomain, FilterDTO>(query, null); var rez = query.ToList(); }