Esempio n. 1
0
        public void Cost_WithoutCondiments_ReturnOneDollarAndFiveCents()
        {
            var decaf = new Decaf();

            var cost = decaf.Cost();

            cost.Should().Be(1.05m);
        }
        public void TestDecaf()
        {
            Beverage beverage = new Decaf();

            beverage = new Mocha(beverage);
            beverage = new Whip(beverage);
            Assert.AreEqual("Decaf Coffee, Mocha, Whip $1.35", beverage.GetDescription() +
                            " $" + beverage.Cost());
        }
Esempio n. 3
0
        public void TestDecafCost2()
        {
            Beverage coffee = new Decaf();

            // add soy to Decaf coffee
            coffee = new SoyBeverageDecorator(coffee);

            Assert.Equal(1.50, coffee.getCost());
        }
Esempio n. 4
0
        public void Cost_WithMocha_ReturnOneDollarAndTwentyFiveCents()
        {
            Beverage decaf = new Decaf();

            decaf = new Mocha(decaf);

            var cost = decaf.Cost();

            cost.Should().Be(1.25m);
        }
Esempio n. 5
0
        public void TestDecafCost3()
        {
            Beverage coffee = new Decaf();

            // add soy and caramel to Decaf coffee object
            coffee = new SoyBeverageDecorator(coffee);
            coffee = new CaramelBeverageDecorator(coffee);

            Assert.Equal(2, coffee.getCost());
        }
Esempio n. 6
0
        public void StartBuzz()
        {
            Beverage testBeverage = new Decaf();

            testBeverage = new Whip(testBeverage);
            testBeverage = new SteamedMilk(testBeverage);
            testBeverage = new Soy(testBeverage);

            Assert.AreEqual("Decaf, Whip, Steamed Milk, Soy", testBeverage.GetDescription());
            Assert.AreEqual((double)(1.05 + .10 + .10 + .15), testBeverage.Cost());
        }
Esempio n. 7
0
        public void DecafPriceTest()
        {
            //Arrange
            Beverage bev = new Decaf();
            decimal  price;

            //Act
            price = bev.GetPrice();
            //Assert
            Assert.AreEqual(price, 1.05m);
        }
Esempio n. 8
0
        public void Decaf_ShouldBeExpressoAndCostOneDollarAndFiveCents_WhenIsInstantiate()
        {
            //Arrange
            Beverage beverage = new Decaf();

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

            //Assert
            description.Should().Be("Decaf Coffee");
            cost.Should().Be(1.05);
        }
Esempio n. 9
0
        public void DecafWithMochaPriceTest()
        {
            //Arrange
            Beverage bev = new Decaf();

            bev = new SteamedMilk(bev);
            decimal price;

            //Act
            price = bev.GetPrice();
            //Assert
            Assert.AreEqual(price, 1.15m);
        }
Esempio n. 10
0
        public void DecafWithSoyPriceTest()
        {
            //Arrange
            Beverage bev = new Decaf();

            bev = new Soy(bev);
            decimal price;

            //Act
            price = bev.GetPrice();
            //Assert
            Assert.AreEqual(price, 1.20m);
        }
Esempio n. 11
0
        public void ToString_Override_ReturnDecafCoffee()
        {
            var decaf = new Decaf();

            decaf.ToString().Should().Be("Decaf Coffee");
        }
Esempio n. 12
0
        public void TestDecafCost1()
        {
            Beverage coffee = new Decaf();

            Assert.Equal(1.25, coffee.getCost());
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            TestVirtual testVirtual = new TestVirtual();

            Console.WriteLine(testVirtual.resultA);         //using method from overrride
            Console.WriteLine(testVirtual.resultB);         //using method from base class

            Console.WriteLine(testVirtual.add(1, 2));       //using method from overrride
            Console.WriteLine(testVirtual.substract(9, 1)); //using method from base class
            Console.WriteLine();
            //======================================================================================

            SealMethod sealMethod = new SealMethod();

            Console.WriteLine(sealMethod.add(1, 1));
            Console.WriteLine(sealMethod.substract(2, 2));
            Console.WriteLine(sealMethod.multipy(2, 2));
            Console.WriteLine();
            //======================================================================================

            ProtectBase   protectBase   = new ProtectBase();
            TestProtected testProtected = new TestProtected();

            // below will have complier error as "add" method can only be used inside TestProtected
            //Console.WriteLine(TestProtected.add(4, 5));
            Console.WriteLine();
            //======================================================================================

            // below will have compier error - abstract can't be instantiate
            //AbstractBase ab = new AbstractBase();
            TestAbstract testAb = new TestAbstract();

            Console.WriteLine(testAb.add(3, 8));
            Console.WriteLine();
            //======================================================================================

            Console.WriteLine("---- test order system ----");
            Order order = new Order {
                Id = 1, FirstName = "Tan", Email = "*****@*****.**", Price = 10.50M
            };
            OrderingFactory factory = new OrderingFactory();
            IOrderProcess   orderA  = factory.GetOrderSupplier("A");

            orderA.MakeOrder(order);

            Console.WriteLine("");

            IOrderProcess orderB = factory.GetOrderSupplier("B");

            orderB.MakeOrder(order);

            Console.WriteLine("");
            Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++");
            Console.WriteLine("");
            Console.WriteLine(Multi10000(1, 1));
            Console.WriteLine();
            //======================================================================================
            IStore    store    = new Document();
            ICompress compress = new Document();

            store.Read();
            store.Write();
            compress.Compress();
            compress.Decompress();

            using (SimpleClass simple = new SimpleClass())
            {
                Console.WriteLine(simple.returnA());
            }
            Console.WriteLine();
            //======================================================================================


            Duck d1 = new DecoyDuck();

            d1.Display();
            d1.PerformFly();
            d1.PerformQuack();
            Duck d2 = new RubberDuck();

            d2.Display();
            d2.PerformFly();
            d2.PerformQuack();
            Console.WriteLine();
            //======================================================================================

            /*
             * WeatherData weatherData = new WeatherData();
             *
             * CurrentConditionsDisplay currDisplay = new CurrentConditionsDisplay(weatherData);
             * ForecastDisplay foreDisplay = new ForecastDisplay(weatherData);
             *
             * weatherData.setMeasurements(80, 65, 30.4f);
             */

            Console.WriteLine();
            //======================================================================================

            WeatherTracker provider = new WeatherTracker();

            CurrentConditionsDisplay currDisplay = new CurrentConditionsDisplay(provider);
            ForecastDisplay          foreDisplay = new ForecastDisplay(provider);

            provider.UpdateWeather(new WeatherData(80, 65, 30.4f));

            Console.WriteLine();
            //======================================================================================
            BeverageBase beverage = new Decaf();

            Console.WriteLine(beverage.Description
                              + " $" + beverage.cost());

            BeverageBase beverage2 = new DarkRoast();

            beverage2 = new Milk(beverage2);
            beverage2 = new Mocha(beverage2);
            Console.WriteLine(beverage2.Description
                              + " $" + beverage2.cost());


            Console.WriteLine();
            //======================================================================================
            Console.WriteLine(Singleton.Instant.getTest());
            Console.WriteLine(Singleton.Instant.getTest());
            Console.WriteLine(Singleton.Instant.getTest());


            Console.WriteLine();
            //======================================================================================
            Booking booking = new Booking {
                BookingId = 1, SupplierCode = "GTA", FirstName = "Tan", LastName = "Tang", TotalAmount = (decimal)299.99
            };
            ProcessBooking bookingProcess = new ProcessBooking(booking);

            bookingProcess.Initial();
            Console.WriteLine("  Booking State = {0}, Status = {1}", booking.State.ToString(), booking.Status);

            bookingProcess.PreAuthorisation();
            Console.WriteLine("  Booking State = {0}, Status = {1}", booking.State.ToString(), booking.Status);

            bookingProcess.MakeBooking();
            Console.WriteLine("  Booking State = {0}, Status = {1}", booking.State.ToString(), booking.Status);

            bookingProcess.MakePayment();
            Console.WriteLine("  Booking State = {0}, Status = {1}", booking.State.ToString(), booking.Status);

            bookingProcess.FinaliseBooking();
            Console.WriteLine("  Booking State = {0}, Status = {1}", booking.State.ToString(), booking.Status);


            Console.Read();
        }
        //Below is used to get the int value for X amounts the user selects for the condiments
        public ActionResult display(string Coffee, int?Decorator1, int?Decorator2, int?Decorator3, int?Decorator4, int?Decorator5, int?Decorator6, int?Decorator7, int?Decorator8, int?Decorator9, int?Decorator10)
        {
            //assign base coffees different orders
            CoffeeNull  anOrder0 = new CoffeeNull();
            ViennaRoast anOrder  = new ViennaRoast();
            Espresso    anOrder2 = new Espresso();
            Columbian   anOrder3 = new Columbian();
            Decaf       anOrder4 = new Decaf();
            FrenchRoast anOrder5 = new FrenchRoast();

            //gets price of condiment under an empty order so you just get condiments price
            PumpkinSpice addon1  = new PumpkinSpice(anOrder0);
            Milk         addon2  = new Milk(anOrder0);
            Soy          addon3  = new Soy(anOrder0);
            CaramelSyrup addon4  = new CaramelSyrup(anOrder0);
            EspressoShot addon5  = new EspressoShot(anOrder0);
            Mocha        addon6  = new Mocha(anOrder0);
            SkimMilk     addon7  = new SkimMilk(anOrder0);
            Vanilla      addon8  = new Vanilla(anOrder0);
            WhipCream    addon9  = new WhipCream(anOrder0);
            Cinnamon     addon10 = new Cinnamon(anOrder0);


            //declare condiments
            double price        = 0;
            double pumpkinSpice = 0;
            double milk         = 0;
            double soy          = 0;
            double cinnamon     = 0;
            double whipcream    = 0;
            double vanilla      = 0;
            double skimmilk     = 0;
            double caramelsyrup = 0;
            double espressoshot = 0;
            double mocha        = 0;

            //declare condiments variable description
            string spumpkinSpice = "";
            string smilk         = "";
            string ssoy          = "";
            string svanilla      = "";
            string swhipcream    = "";
            string sespressoshot = "";
            string smocha        = "";
            string scaramelsyrup = "";
            string sskimmilk     = "";
            string scinnamon     = "";

            //convert users  input numbers for X amounts of condiments to variables we can use here
            int decorator1  = Decorator1 ?? default(int);
            int decorator2  = Decorator2 ?? default(int);
            int decorator3  = Decorator3 ?? default(int);
            int decorator4  = Decorator4 ?? default(int);
            int decorator5  = Decorator5 ?? default(int);
            int decorator6  = Decorator6 ?? default(int);
            int decorator7  = Decorator7 ?? default(int);
            int decorator8  = Decorator8 ?? default(int);
            int decorator9  = Decorator9 ?? default(int);
            int decorator10 = Decorator10 ?? default(int);


            //gets the cost of the condiment if it is selected * X amount and a Coffee is checked
            if (decorator1 > 0 && Coffee == "FrenchRoast" || Coffee == "ViennaRoast" || Coffee == "Espresso" || Coffee == "Columbian" || Coffee == "Decaf")
            {
                pumpkinSpice = addon1.GetCost() * decorator1;
                price        = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                //repeats the string in qoutes based on users input amount
                spumpkinSpice = String.Concat(Enumerable.Repeat("PumpkinSpice ", decorator1));
            }



            if (decorator2 > 0 && Coffee == "ViennaRoast" || decorator2 > 0 && Coffee == "FrenchRoast" || decorator2 > 0 && Coffee == "Espresso" || decorator2 > 0 && Coffee == "Columbian" || decorator2 > 0 && Coffee == "Decaf")
            {
                milk  = addon2.GetCost() * decorator2;
                price = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                smilk = String.Concat(Enumerable.Repeat("Milk ", decorator2));
            }

            if (decorator3 > 0 && Coffee == "ViennaRoast" || decorator3 > 0 && Coffee == "FrenchRoast" || decorator3 > 0 && Coffee == "Espresso" || decorator3 > 0 && Coffee == "Columbian" || decorator3 > 0 && Coffee == "Decaf")
            {
                soy   = addon3.GetCost() * decorator3;
                price = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                ssoy = String.Concat(Enumerable.Repeat("Soy ", decorator3));
            }


            if (decorator4 > 0 && Coffee == "ViennaRoast" || decorator4 > 0 && Coffee == "FrenchRoast" || decorator4 > 0 && Coffee == "Espresso" || decorator4 > 0 && Coffee == "Columbian" || decorator4 > 0 && Coffee == "Decaf")
            {
                caramelsyrup = addon4.GetCost() * decorator4;
                price        = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                scaramelsyrup = String.Concat(Enumerable.Repeat("CaramelSyrup ", decorator4));
            }


            if (decorator5 > 0 && Coffee == "ViennaRoast" || decorator5 > 0 && Coffee == "FrenchRoast" || decorator5 > 0 && Coffee == "Espresso" || decorator5 > 0 && Coffee == "Columbian" || decorator5 > 0 && Coffee == "Decaf")
            {
                espressoshot = addon5.GetCost() * decorator5;
                price        = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                sespressoshot = String.Concat(Enumerable.Repeat("EspressoShot ", decorator5));
            }



            if (decorator6 > 0 && Coffee == "ViennaRoast" || decorator6 > 0 && Coffee == "FrenchRoast" || decorator6 > 0 && Coffee == "Espresso" || decorator6 > 0 && Coffee == "Columbian" || decorator6 > 0 && Coffee == "Decaf")
            {
                mocha = addon6.GetCost() * decorator6;
                price = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                smocha = String.Concat(Enumerable.Repeat("Mocha ", decorator6));
            }


            if (decorator7 > 0 && Coffee == "ViennaRoast" || decorator7 > 0 && Coffee == "FrenchRoast" || decorator7 > 0 && Coffee == "Espresso" || decorator7 > 0 && Coffee == "Columbian" || decorator7 > 0 && Coffee == "Decaf")
            {
                skimmilk = addon7.GetCost() * decorator7;
                price    = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                sskimmilk = String.Concat(Enumerable.Repeat("SkimMilk ", decorator7));
            }


            if (decorator8 > 0 && Coffee == "ViennaRoast" || decorator8 > 0 && Coffee == "FrenchRoast" || decorator8 > 0 && Coffee == "Espresso" || decorator8 > 0 && Coffee == "Columbian" || decorator8 > 0 && Coffee == "Decaf")
            {
                vanilla = addon8.GetCost() * decorator8;
                price   = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                svanilla = String.Concat(Enumerable.Repeat("Vanilla ", decorator8));
            }


            if (decorator9 > 0 && Coffee == "ViennaRoast" || decorator9 > 0 && Coffee == "FrenchRoast" || decorator9 > 0 && Coffee == "Espresso" || decorator9 > 0 && Coffee == "Columbian" || decorator9 > 0 && Coffee == "Decaf")
            {
                whipcream = addon9.GetCost() * decorator9;
                price     = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                swhipcream = String.Concat(Enumerable.Repeat("WhipCream ", decorator9));
            }

            if (decorator10 > 0 && Coffee == "ViennaRoast" || decorator10 > 0 && Coffee == "FrenchRoast" || decorator10 > 0 && Coffee == "Espresso" || decorator10 > 0 && Coffee == "Columbian" || decorator10 > 0 && Coffee == "Decaf")
            {
                cinnamon = addon10.GetCost() * decorator10;
                price    = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                scinnamon = String.Concat(Enumerable.Repeat("Cinnamon ", decorator10));
            }



            //display for if coffee is selected without any addons
            if (decorator1 == 0 && decorator2 == 0 && decorator3 == 0 && decorator4 == 0 && decorator5 == 0 && decorator6 == 0 && decorator7 == 0 && decorator8 == 0 && decorator9 == 0 && decorator10 == 0)
            {
                price = anOrder.GetCost();
            }

            //declare viewbags to display data
            ViewBag.CofeeNull   = anOrder0;
            ViewBag.ViennaRoast = anOrder;
            ViewBag.espresso    = anOrder2;
            ViewBag.columbian   = anOrder3;
            ViewBag.Decaf       = anOrder4;
            ViewBag.FrenchRoast = anOrder5;


            ViewBag.price        = price;
            ViewBag.pumpkinSpice = spumpkinSpice;
            ViewBag.milk         = smilk;
            ViewBag.soy          = ssoy;
            ViewBag.caramelsyrup = scaramelsyrup;
            ViewBag.espressoshot = sespressoshot;
            ViewBag.mocha        = smocha;
            ViewBag.skimMilk     = sskimmilk;
            ViewBag.vanilla      = svanilla;
            ViewBag.whipcream    = swhipcream;
            ViewBag.cinnamon     = scinnamon;


            //if coffee is selected, return its name, and not all coffee names
            if (Coffee == "Columbian")
            {
                ViewBag.columbian = anOrder3;
            }
            else
            {
                ViewBag.columbian = anOrder0;
            }
            if (Coffee == "Decaf")
            {
                ViewBag.Decaf = anOrder4;
            }
            else
            {
                ViewBag.Decaf = anOrder0;
            }
            if (Coffee == "Espresso")
            {
                ViewBag.espresso = anOrder2;
            }
            else
            {
                ViewBag.espresso = anOrder0;
            }
            if (Coffee == "FrenchRoast")
            {
                ViewBag.FrenchRoast = anOrder5;
            }
            else
            {
                ViewBag.FrenchRoast = anOrder0;
            }
            if (Coffee == "ViennaRoast")
            {
                ViewBag.ViennaRoast = anOrder;
            }
            else
            {
                ViewBag.ViennaRoast = anOrder0;
            }


            return(View());
        }