Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            OpenApplication();

            string input = Console.ReadLine();

            //Check Valid Input
            bool isInputValid = CheckIfInputIsValid(input);

            if (isInputValid == true)
            {
                IDrink drink = CafeFactory.CreateDrink(ConfigurationManager.AppSettings[input]);

                if (drink != null)
                {
                    AcuCafeLibrary.OrderDrink(drink);

                    Console.WriteLine($"The cost of your drink is {AcuCafeLibrary.GetCost(drink)}");
                }
                else
                {
                    Console.WriteLine("Drink unavailable");
                }
            }
            else
            {
                Console.WriteLine("Invalid Input\n");
            }
        }
Exemplo n.º 2
0
        public void ShouldGetCost()
        {
            //Arrange
            var drinks = new List <IDrink>()
            {
                new MilkDecorator(new SugarDecorator(new Tea())),
                new SugarDecorator(new IceTea()),
                new ChocolateDecorator(new MilkDecorator(new SugarDecorator((new Expresso()))))
            };

            //Act

            /*  Values to check
             *  Hot Tea with Milk and Sugar
             *  Ice Tea with Sugar
             *  Expresso with Chocolate and Milk and Sugar
             *  */
            double actualCost = AcuCafeLibrary.GetCost(CafeFactory.CreateDrink("Expresso with Chocolate and Milk and Sugar"));

            //Assert

            /*  Values to check
             *  Hot Tea with Milk and Sugar - 2
             *  Ice Tea with Sugar - 2
             *  Expresso with Chocolate and Milk and Sugar - 2.75
             *  */
            Assert.Equal(2.75, actualCost);
        }
Exemplo n.º 3
0
        public void ShouldSupportCondiments()
        {
            //Arrange
            var drinks = new List <IDrink>()
            {
                new MilkDecorator(new SugarDecorator(new Tea())),
                new SugarDecorator(new IceTea()),
                new ChocolateDecorator(new MilkDecorator(new SugarDecorator((new Expresso()))))
            };

            //Act

            /*  Values to check
             *  Hot Tea with Milk and Sugar
             *  Ice Tea with Sugar
             *  Expresso with Chocolate and Milk and Sugar
             *  */
            IDrink actual = AcuCafeLibrary.OrderDrink(CafeFactory.CreateDrink("Expresso with Chocolate and Milk and Sugar"));

            //Asert
            Assert.Equal(drinks[2].Description, actual.Description);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            List <Cliente> ordenes = new List <Cliente>();

            Cliente cliente1 = new Cliente();

            cliente1.Nombre = "Carlos";
            cliente1.Orden  = new Orden(TipoCafe.Mocaccino, Tamaño.Venti);
            ordenes.Add(cliente1);

            Cliente cliente2 = new Cliente();

            cliente2.Nombre = "Diego";
            cliente2.Orden  = new Orden(TipoCafe.Latte, Tamaño.Alto);
            ordenes.Add(cliente2);

            foreach (var cliente in ordenes)
            {
                IServidorCafe barista = CafeFactory.Instanciar(cliente.Orden.TipoCafe);
                var           orden   = barista.Servir(cliente.Orden.Tamaño);
                Console.WriteLine(orden);
            }
            Console.ReadKey();
        }