public void DecoratorTest()
        {
            DIServiceLocator.Current.RegisterInstance(typeof(ITextProvider));
            Support.Configure();

            Beverage beverage = new Espresso();

            beverage = new Mocha(beverage);
            Assert.AreEqual(beverage.Description, "Espresso, Mocha");
            Assert.AreEqual(beverage.Cost(), 2.19);

            Beverage beverage2 = new DarkRoast();

            beverage2 = beverage2.AddComponent <Mocha>();
            beverage2 = beverage2.AddComponent <Mocha>();
            beverage2 = beverage2.AddComponent <Whip>();
            Assert.AreEqual(beverage2.Description, "Dark Roast, Mocha, Mocha, Whip");
            Assert.AreEqual(beverage2.Cost(), 1.49);

            Beverage beverage3 = new HouseBlend();

            SupportExtensions.AddComponent <Soy>(ref beverage3);
            SupportExtensions.AddComponent <Mocha>(ref beverage3);
            SupportExtensions.AddComponent <Whip>(ref beverage3);
            Assert.AreEqual(beverage3.Description, "House Blend Coffee, Soy, Mocha, Whip");
            Assert.AreEqual(beverage3.Cost(), 1.34);
        }
Exemple #2
0
        public void CostShouldReturnEigthyNineCents()
        {
            var expectedValue = 0.89M;
            var houseBlend    = new HouseBlend();

            houseBlend.Cost().Should().Be(expectedValue);
        }
        public void HouseBlendWithSoyWithMochaWithWhip()
        {
            HouseBlend beverage = new HouseBlend();
            beverage.HasSoy = true;
            beverage.HasMocha = true;
            beverage.HasWhip = true;

            Assert.AreEqual(1.34, beverage.Cost(), DELTA);
        }
        public void HouseBlendWithSoyWithMochaWithWhip()
        {
            HouseBlend beverage = new HouseBlend();

            beverage.HasSoy   = true;
            beverage.HasMocha = true;
            beverage.HasWhip  = true;

            Assert.AreEqual(1.34, beverage.Cost(), DELTA);
        }
Exemple #5
0
        public void HouseBlend_ShouldBeExpressoAndCostEightyNineCents_WhenIsInstantiate()
        {
            //Arrange
            Beverage beverage = new HouseBlend();

            //Act
            var description = beverage.GetDescription();
            var cost        = beverage.Cost();

            //Assert
            description.Should().Be("House Blend Coffee");
            cost.Should().Be(.89);
        }
        public static void Start()
        {
            DIServiceLocator.Current.RegisterInstance <IPriceProvider>(new ComponentCosts());

            Beverage beverage = new Espresso();

            beverage = new Mocha(beverage);
            "{0} ${1}".P(beverage.Description, beverage.Cost());

            Beverage beverage2 = new DarkRoast();

            beverage2 = beverage2.AddComponent <Mocha>();
            beverage2 = beverage2.AddComponent <Mocha>();
            beverage2 = beverage2.AddComponent <Whip>();
            "{0} ${1}".P(beverage2.Description, beverage2.Cost());

            Beverage beverage3 = new HouseBlend();

            SupportExtensions.AddComponent <Soy>(ref beverage3);
            SupportExtensions.AddComponent <Mocha>(ref beverage3);
            SupportExtensions.AddComponent <Whip>(ref beverage3);
            "{0} ${1}".P(beverage3.Description, beverage3.Cost());
        }