public void MultipleAndSpecifications_ReturnOneItem() { var specification = new ActiveItemsSpecification() .And(new CodeStartsWithSpecification("Defqon.1")) .And(new NameContainsSpecification("easy")); var sut = specification.GetExpression(); var result = Context.Events.Where(sut).ToList(); Assert.Single(result); Assert.Equal(5, result.First().Id); Assert.Equal("Defqon.1 Australia", result.First().Code); }
public void NegationMultipleSpecifications_ReturnAllExceptOneItem() { var specification = new ActiveItemsSpecification() .And(new CodeStartsWithSpecification("Defqon.1")) .And(new NameContainsSpecification("easy")) .Not(); var sut = specification.GetExpression(); var notExpected = Context.Events.Single(i => i.Id == 5); var result = Context.Events.Where(sut).ToList(); Assert.Equal(9, result.Count); Assert.DoesNotContain(notExpected, result); }