public void AndAlso_Satisfies_Both() { var greaterThanSpecification = new GreaterThanSpecification(-2); var lessThanSpecification = new LessThanSpecification(2); var compositeSpecification = greaterThanSpecification.AndAlso(lessThanSpecification); using (var fruitContext = new FruitContext()) { var integers = GetIntegers(fruitContext); var satisfiedIntegers = compositeSpecification.SatisfiedBy(integers); Assert.IsTrue(satisfiedIntegers.Any()); Assert.IsTrue(satisfiedIntegers.All(i => i > -2 && i < 2)); } }
public void OrElse_Satisfies_Either() { var greaterThanSpecification = new GreaterThanSpecification(2); var lessThanSpecification = new LessThanSpecification(-2); var compositeSpecification = greaterThanSpecification.OrElse(lessThanSpecification); using (var fruitContext = new FruitContext()) { var integers = GetIntegers(fruitContext); var satisfiedIntegers = compositeSpecification.SatisfiedBy(integers); Assert.IsTrue(satisfiedIntegers.Any()); Assert.IsTrue(satisfiedIntegers.All(i => i > 2 || i < -2)); } }