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 And() { // Arrange Drink coldWhiskey = Drink.ColdWhiskey(); Drink appleJuice = Drink.AppleJuice(); ISpecification <Drink> whiskeySpec = Spec.For <Drink>(d => d.Name.ToLower() == "whiskey"); ISpecification <Drink> coldSpec = Spec.For <Drink>(d => d.With.Any(a => a.ToLower() == "ice")); // Act var coldWhiskeySpec = whiskeySpec.And(coldSpec); // Assert coldWhiskeySpec.IsSatisfiedBy(coldWhiskey).Should().BeTrue(); coldWhiskeySpec.IsSatisfiedBy(appleJuice).Should().BeFalse(); }
public void And() { // Arrange Drink coldWhiskey = Drink.ColdWhiskey(); Drink appleJuice = Drink.AppleJuice(); ASpec <Drink> whiskeySpec = new Spec <Drink>(d => d.Name.ToLower() == "whiskey"); ASpec <Drink> coldSpec = new Spec <Drink>(d => d.With.Any(a => a.ToLower() == "ice")); // Act var coldWhiskeySpec = whiskeySpec & coldSpec; // Assert coldWhiskeySpec.IsSatisfiedBy(coldWhiskey).Should().BeTrue(); coldWhiskeySpec.IsSatisfiedBy(appleJuice).Should().BeFalse(); // And coldWhiskey.Is(coldWhiskeySpec).Should().BeTrue(); appleJuice.Is(coldWhiskeySpec).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(); }