public void IgnoreKeys() { //arrange var source = CreateTestObjectCollection().AsQueryable(); var querystring = GetQueryNameValuePairs("nomatch_key=asdf"); //act var actual = QueryableExtensions.AddFilters(source, querystring, "nomatch_key"); //assert actual.Should().BeSameAs(source); }
public void Null_Filters() { //arrange var source = CreateTestObjectCollection().AsQueryable(); IEnumerable <FilterOptions> filters = null; //act var actual = QueryableExtensions.AddFilters(source, filters); //assert actual.Should().BeSameAs(source); }
public void Zero_Filters() { //arrange var source = new List <Object>().AsQueryable(); IEnumerable <FilterOptions> filters = new List <FilterOptions>(); //act var actual = QueryableExtensions.AddFilters(source, filters); //assert actual.Should().BeSameAs(source); }
public void EmptyKey() { //arrange var source = CreateTestObjectCollection().AsQueryable(); var GetQueryNameValuePairs = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("", "") }; //act var actual = QueryableExtensions.AddFilters(source, GetQueryNameValuePairs); //assert actual.Should().BeSameAs(source); }
public void DynamicExpressions_TypeConversions(string filterstring, bool shouldContain1111, bool shouldContain9911, string expectedIds) { //arrange var items = filterstring.Split('&').Select(_ => { var t = _.Split('='); return(new KeyValuePair <string, string>(t[0], t[1])); }); var filterOps = new FilterOptionsParser().Parse(items); var testObjList = CreateTestData(); var byKeys = testObjList.ToDictionary(_ => _.IdStr); //act var actual = QueryableExtensions.AddFilters(testObjList.AsQueryable(), filterOps) .ToList(); //run the query //assert var expectedIdsList = expectedIds.Split(','); actual.Should().HaveCount(expectedIdsList.Count()); if (shouldContain1111) { actual.Should().Contain(byKeys["1111"]); } else { actual.Should().NotContain(byKeys["1111"]); } if (shouldContain9911) { actual.Should().Contain(byKeys["9911"]); } else { actual.Should().NotContain(byKeys["9911"]); } //actual.Should().ContainInOrder(expectedIdsList.ToArray()); }