public void Not() { // Arrange Drink blackberryJuice = Drink.BlackberryJuice(); Drink appleJuice = Drink.AppleJuice(); Drink orangeJuice = Drink.OrangeJuice(); // Assert new[] { blackberryJuice, appleJuice, orangeJuice }.Are(Spec.Not <Drink>()).Should().BeFalse(); }
public void AppleOrOrangeJuice() { // Arrange Drink blackberryJuice = Drink.BlackberryJuice(); Drink appleJuice = Drink.AppleJuice(); Drink orangeJuice = Drink.OrangeJuice(); ISpecification <Drink> juiceSpec = Spec.For <Drink>(d => d.With.Any(w => w.ToLower().Contains("juice"))); ISpecification <Drink> appleSpec = Spec.For <Drink>(d => d.With.Any(w => w.ToLower().Contains("apple"))); ISpecification <Drink> orangeSpec = Spec.For <Drink>(d => d.With.Any(w => w.ToLower().Contains("orange"))); // Act var appleOrOrangeJuiceSpec = juiceSpec.And(appleSpec.Or(orangeSpec)); // Assert appleOrOrangeJuiceSpec.IsSatisfiedBy(appleJuice).Should().BeTrue(); appleOrOrangeJuiceSpec.IsSatisfiedBy(orangeJuice).Should().BeTrue(); appleOrOrangeJuiceSpec.IsSatisfiedBy(blackberryJuice).Should().BeFalse(); }
public void AppleOrOrangeJuice() { // Arrange Drink blackberryJuice = Drink.BlackberryJuice(); Drink appleJuice = Drink.AppleJuice(); Drink orangeJuice = Drink.OrangeJuice(); ASpec <Drink> juiceSpec = new Spec <Drink>(d => d.With.Any(w => w.ToLower().Contains("juice"))); ASpec <Drink> appleSpec = new Spec <Drink>(d => d.With.Any(w => w.ToLower().Contains("apple"))); ASpec <Drink> orangeSpec = new Spec <Drink>(d => d.With.Any(w => w.ToLower().Contains("orange"))); // Act var appleOrOrangeJuice = juiceSpec & (appleSpec | orangeSpec); // Assert appleOrOrangeJuice.IsSatisfiedBy(appleJuice).Should().BeTrue(); appleOrOrangeJuice.IsSatisfiedBy(orangeJuice).Should().BeTrue(); appleOrOrangeJuice.IsSatisfiedBy(blackberryJuice).Should().BeFalse(); // And new[] { appleJuice, orangeJuice }.Are(appleOrOrangeJuice).Should().BeTrue(); blackberryJuice.Is(appleOrOrangeJuice).Should().BeFalse(); }