Пример #1
0
        public void CoffeeWithMilkAndSprinkles()
        {
            var cofee = new Coffee();
            var coffeeWithMilkAndSprinkles = new WithMilkDecorator(new WithSprinklesDecorator(cofee));

            Assert.AreEqual(1.7, coffeeWithMilkAndSprinkles.Cost);
            Assert.AreEqual(3, coffeeWithMilkAndSprinkles.Contents.Count);
            CollectionAssert.Contains(coffeeWithMilkAndSprinkles.Contents, Ingredients.Coffee);
            CollectionAssert.Contains(coffeeWithMilkAndSprinkles.Contents, Ingredients.Milk);
            CollectionAssert.Contains(coffeeWithMilkAndSprinkles.Contents, Ingredients.Sprinkles);
        }
Пример #2
0
        public void CoffeeWithMilk()
        {
            var coffee         = new Coffee();
            var coffeeWithMilk = new WithMilkDecorator(coffee);

            // Coffee
            Assert.AreEqual(1, coffee.Cost);
            Assert.AreEqual(1, coffee.Contents.Count);
            Assert.AreEqual(Ingredients.Coffee, coffee.Contents.Single());

            // CoffeeWithMilk
            Assert.AreEqual(1.5, coffeeWithMilk.Cost);
            Assert.AreEqual(2, coffeeWithMilk.Contents.Count);
            CollectionAssert.Contains(coffeeWithMilk.Contents, Ingredients.Coffee);
            CollectionAssert.Contains(coffeeWithMilk.Contents, Ingredients.Milk);
        }
Пример #3
0
        public void CoffeeWithDoubleMilk()
        {
            var coffee = new Coffee();
            var coffeeWithDoubleMilk = new WithMilkDecorator(new WithMilkDecorator(coffee));

            // Coffee
            Assert.AreEqual(1, coffee.Cost);
            Assert.AreEqual(1, coffee.Contents.Count);
            Assert.AreEqual(Ingredients.Coffee, coffee.Contents.Single());

            // CoffeeWithDoubleMilk
            Assert.AreEqual(2, coffeeWithDoubleMilk.Cost);
            Assert.AreEqual(3, coffeeWithDoubleMilk.Contents.Count);
            CollectionAssert.AreEquivalent(
                new[] { Ingredients.Coffee, Ingredients.Milk, Ingredients.Milk },
                coffeeWithDoubleMilk.Contents);
        }