public void OrderDrink_ReturnsExpressoWithoutMilkAndSugar_WhenHasMilkAndHasSugarAreFalse()
        {
            //Arrange
            DrinkAddOn addOn = new DrinkAddOn();

            //Act
            IDrink drink = DrinkFactory.OrderDrink(DrinkType.Expresso, addOn);

            //Assert
            Assert.IsTrue(drink is Expresso);
            Assert.AreEqual("We are preparing the following drink for you: Expresso without milk without sugar", drink.Description);
            Assert.AreEqual(1.8, drink.GetCost());
        }
        public void OrderDrink_ReturnsExpressoWithSugar_WhenHasSugarIsTrue()
        {
            //Arrange
            DrinkAddOn addOn = new DrinkAddOn();

            addOn.HasSugar = true;
            //Act
            IDrink drink = DrinkFactory.OrderDrink(DrinkType.Expresso, addOn);

            //Assert
            Assert.IsTrue(drink is SugarDecorator);
            Assert.AreEqual("We are preparing the following drink for you: Expresso without milk with sugar", drink.Description);
            Assert.AreEqual(2.3, drink.GetCost());
        }
        public void OrderDrink_ReturnsTeaWithMilk_WhenHasMilkIsTrue()
        {
            //Arrange
            DrinkAddOn addOn = new DrinkAddOn();

            addOn.HasMilk = true;
            //Act
            IDrink drink = DrinkFactory.OrderDrink(DrinkType.Tea, addOn);

            //Assert
            Assert.IsTrue(drink is MilkDecorator);
            Assert.AreEqual("We are preparing the following drink for you: Hot tea with milk without sugar", drink.Description);
            Assert.AreEqual(1.5, drink.GetCost());
        }
示例#4
0
        public void ExpressoNoMilkNoSugarTest()
        {
            // Arrange
            double expectedPrice = 1.8;
            bool   hasSugar      = false;
            bool   hasMilk       = false;

            // act
            ITopping topping = new Topping(false, false);
            Drink    actual  = DrinkFactory.OrderDrink(DrinkType.Expresso, topping);

            Assert.AreEqual(expectedPrice, actual.Cost());
            Assert.AreEqual(hasSugar, actual.HasSugar);
            Assert.AreEqual(hasMilk, actual.HasMilk);
        }
示例#5
0
        public void IceTeaMilkSugarTest()
        {
            // Arrange
            double expectedPrice = 2;
            bool   hasSugar      = true;
            bool   hasMilk       = false;

            // act
            ITopping topping = new Topping(true, true);
            Drink    actual  = DrinkFactory.OrderDrink(DrinkType.IceTea, topping);

            Assert.AreEqual(expectedPrice, actual.Cost());
            Assert.AreEqual(hasSugar, actual.HasSugar);
            Assert.AreEqual(hasMilk, actual.HasMilk);
        }
        public void OrderDrink_ReturnsExpressoWithMilkAndSugarWithChocolate_WhenHasMilkAndHasSugarAndHasChocolateAreTrue()
        {
            //Arrange
            DrinkAddOn addOn = new DrinkAddOn();

            addOn.HasSugar     = true;
            addOn.HasMilk      = true;
            addOn.HasChocolate = true;
            //Act
            IDrink drink = DrinkFactory.OrderDrink(DrinkType.Expresso, addOn);

            //Assert
            Assert.IsTrue(drink is ChocolateDecorator);
            Assert.AreEqual("We are preparing the following drink for you: Expresso with milk with sugar with chocolate", drink.Description);
            Assert.AreEqual(3.3, drink.GetCost());
        }
示例#7
0
        public void ExpressoMilkSugarChocolateTest()
        {
            // Arrange
            double expectedPrice = 3.3;
            bool   hasSugar      = true;
            bool   hasMilk       = true;
            bool   hasChocolate  = true;

            // act
            ITopping topping = new Topping(true, true, true);
            Drink    actual  = DrinkFactory.OrderDrink(DrinkType.Expresso, topping);

            Assert.AreEqual(expectedPrice, actual.Cost());
            Assert.AreEqual(hasSugar, actual.HasSugar);
            Assert.AreEqual(hasMilk, actual.HasMilk);
            Assert.AreEqual(hasChocolate, actual.HasChocolate);
        }
示例#8
0
        public static async Task Main(string[] args)
        {
            try
            {
                ITopping topping = new Topping(false, false);
                Drink    drink   = DrinkFactory.OrderDrink(DrinkType.IceTea, topping);
                string   result  = await AcuCafe.AcuCafe.PrepareOrder(drink, topping.HasMilk);

                var cost = drink.Cost();
                Console.WriteLine(result);
                Console.WriteLine($"The price is: {cost}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                string path = ConfigurationManager.AppSettings[Constants.FILE_PATH];

                System.IO.File.WriteAllText(path, ex.ToString());
            }

            Console.ReadLine();
        }