public void TestIdPredicate() { var filter = new TodoFilter { Id = 123 }; var predicateGenerator = new PredicateGenerator <TodoFilter, Todo>(); var predicate = predicateGenerator.Generate(filter); //var expectedPredicate = ExpressionExtensions.Expression(x => x.Id == 123); Expression <Func <Todo, bool> > expectedPredicate = x => x.Id == 123; Assert.Equal(expectedPredicate.ToString(), predicate.ToString()); }
public void TestTypePredicate() { var filter = new TodoFilter { Type = new[] { "a", "b" } }; var predicateGenerator = new PredicateGenerator <TodoFilter, Todo>(); var predicate = predicateGenerator.Generate(filter); var items = new List <Todo> { new Todo { Type = "a" }, new Todo { Type = "b" }, new Todo { Type = "c" }, }; var filteredItems = items.AsQueryable().Where(predicate).ToList(); Assert.DoesNotContain(filteredItems, x => x.Type == "c"); }