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();
        }
예제 #2
0
        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();
        }