Example #1
0
        public void LargePizza()
        {
            var pizza = new LargePizza();

            Assert.AreEqual(pizza.Description(), "Large Pizza");
            Assert.AreEqual(pizza.Cost(), 9.00);
        }
        public void Get_Description_And_Calculate_Cost()
        {
            Pizza largePizza = new LargePizza();

            Assert.Equal("Large Pizza", largePizza.GetDescription());
            Assert.Equal(9, largePizza.CalculateCost());
        }
Example #3
0
        private void Opslaan()
        {
            try
            {
                string stringetje = "Bestelling_" + DateTime.Now.ToShortDateString().Replace("/", "-") + "om" +
                                    DateTime.Now.ToShortTimeString().Replace(":", "-");
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.FileName   = stringetje;
                dlg.DefaultExt = ".pizza";
                dlg.Filter     = "Pizza bestelDocument |*.pizza";

                if (dlg.ShowDialog() == true)
                {
                    using (StreamWriter bestand = new StreamWriter(dlg.FileName))
                    {
                        bestand.WriteLine(SmallPizza.ToString());
                        bestand.WriteLine(MediumPizza.ToString());
                        bestand.WriteLine(LargePizza.ToString());
                        bestand.WriteLine(DikkeKorst.ToString());
                        bestand.WriteLine(ExtraKaas.ToString());
                        bestand.WriteLine(AantalPizzas);
                        bestand.WriteLine(Ham.ToString());
                        bestand.WriteLine(Ananas.ToString());
                        bestand.WriteLine(Salami.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Kan het bestand niet opslaan \n" + ex.Message);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            //LargePizza largePizza = new LargePizza();
            Pizza largePizza = new LargePizza();

            largePizza = new Cheese(largePizza);
            largePizza = new Ham(largePizza);
            largePizza = new Peppers(largePizza);

            //Console.WriteLine(largePizza.Description);
            Console.WriteLine(largePizza.GetDescription());
            Console.WriteLine("{0:C2}", largePizza.CalculateCost());

            Console.ReadKey();
            Console.WriteLine();

            Beverage coffee = new Espresso();

            coffee = new Mocha(coffee);
            coffee = new Mocha(coffee);
            coffee = new Whip(coffee);

            Console.WriteLine(coffee.GetDescription());
            Console.WriteLine("{0:C2}", coffee.Cost());

            Console.ReadKey();
        }
        public void Allow_Being_Decorated_With_Cheese()
        {
            Pizza largePizza = new LargePizza();

            largePizza = new Cheese(largePizza);

            Assert.Equal("Large Pizza, Cheese", largePizza.GetDescription());
            Assert.Equal(10.25m, largePizza.CalculateCost());
        }
Example #6
0
        public void LargePizzaWithCheeseAndHam()
        {
            Pizza pizza = new LargePizza();

            pizza = new Cheese(pizza);
            pizza = new Ham(pizza);
            Assert.AreEqual("Large Pizza, Cheese Topping, Ham Topping", pizza.Description());
            Assert.AreEqual(11.75, pizza.Cost());
        }
        public void ReturnDescription_WhenGetDescriptionIsCalled()
        {
            var expectedDescription = "Large Pizza";
            var largePizza          = new LargePizza();

            var actualDescription = largePizza.GetDescription();

            actualDescription.Should().Be(expectedDescription);
        }
        public void ReturnCost_WhenGetCostIsCalled()
        {
            var expectedCost = 7.0;
            var largePizza   = new LargePizza();

            var actualCost = largePizza.GetCost();

            actualCost.Should().Be(expectedCost);
        }
Example #9
0
        public void CreateLargePizza_WhenCreatePizzaWithSizeLargeIsCalled()
        {
            var expectedPizza = new LargePizza();
            var customPizza   = new PizzaBuilder();

            customPizza.CreatePizzaWithSize(Size.Large);
            var actualPizza = customPizza.Bake();

            actualPizza.Should().BeEquivalentTo(expectedPizza);
        }
        public void Allow_Being_Decorated_With_Cheese_And_Ham_And_Peppers()
        {
            Pizza largePizza = new LargePizza();

            largePizza = new Cheese(largePizza);
            largePizza = new Ham(largePizza);
            largePizza = new Peppers(largePizza);

            Assert.Equal("Large Pizza, Cheese, Ham, Peppers", largePizza.GetDescription());
            Assert.Equal(13.25m, largePizza.CalculateCost());
        }
Example #11
0
        public void GetDescription_Returns_LargePizza()
        {
            //Arrange
            var largePizza = new LargePizza();

            //Act
            var description = largePizza.GetDescription();

            //Assert
            Assert.AreEqual("Large Pizza", description);
        }
Example #12
0
        public void CalculateCost_Returns_9()
        {
            //Arrange
            var largePizza = new LargePizza();

            //Act
            var cost = largePizza.CalculateCost();

            //Assert
            Assert.AreEqual(9.00, cost);
        }
Example #13
0
        public void Decorator_pattern_test()
        {
            Pizza largePizza = new LargePizza();

            largePizza = new CheeseTopping(largePizza);
            largePizza = new HamTopping(largePizza);
            largePizza = new PappersTopping(largePizza);

            string desc = largePizza.GetDescription();

            Assert.AreEqual("Large pizza with cheese with Ham with pappers", desc);
        }
Example #14
0
        private static void Main(string[] args)
        {
            Pizza largePizza = new LargePizza();

            largePizza = new Cheese(largePizza);
            largePizza = new Ham(largePizza);
            largePizza = new Peppers(largePizza);

            Console.WriteLine(largePizza.GetDescription());
            Console.WriteLine("{0:C2}", largePizza.CalculateCost());

            Console.ReadLine();
        }
Example #15
0
        static void executeDecorator()
        {
            Pizza largePizza = new LargePizza();

            largePizza = new Cheese(largePizza);
            largePizza = new Ham(largePizza);
            largePizza = new Pepper(largePizza);

            Console.WriteLine(largePizza.GetDescription());
            Console.WriteLine("{0:C2}", largePizza.CalculateCost());

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Pizza smallPizza = new SmallPizza();

            Console.WriteLine($"{smallPizza.Name} - {smallPizza.Price} ron");

            Pizza mediumPizza = new MediumPizza();

            Console.WriteLine($"{mediumPizza.Name} - {mediumPizza.Price} ron");

            Pizza largePizza = new LargePizza();

            Console.WriteLine($"{largePizza.Name} - {largePizza.Price} ron");
        }
Example #17
0
        public static void Bake()
        {
            Pizza pizza = new LargePizza();

            Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}");
            pizza = new Ham(pizza);
            Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}");
            pizza = new Cheese(pizza);
            Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}");
            pizza = new Corn(pizza);
            Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}");
            pizza = new Cheese(pizza);
            Console.WriteLine($"{pizza.CalculateCost()}EUR for {pizza.GetDescription()}");
        }
        public void CanGetTheCurrentPriceOfPizza()
        {
            SmallPizza smallPizza = new SmallPizza();

            smallPizza.AddTopping(new Mushrooms());
            Assert.AreEqual(990, smallPizza.Price());

            MediumPizza mediumPizza = new MediumPizza();

            mediumPizza.AddTopping(new Mushrooms());
            Assert.AreEqual(1725, mediumPizza.Price());

            LargePizza largePizza = new LargePizza();

            largePizza.AddTopping(new Mushrooms());
            Assert.AreEqual(2124, largePizza.Price());
        }
        public void TopingsCanBeAdded()
        {
            SmallPizza smallPizza = new SmallPizza();

            smallPizza.AddTopping(new Mushrooms());
            Assert.Pass();

            MediumPizza mediumPizza = new MediumPizza();

            mediumPizza.AddTopping(new Mushrooms());
            Assert.Pass();

            LargePizza largePizza = new LargePizza();

            largePizza.AddTopping(new Mushrooms());
            Assert.Pass();
        }
Example #20
0
        private static void DemoDecoratorPattern()
        {
            #region Without DecoratorPattern
            //LargePizza largePizza = new LargePizza();

            //Console.WriteLine(largePizza.Description);
            //Console.WriteLine("{0:C2}", largePizza.CalculateCost());
            #endregion

            #region With DecoratorPattern
            Pizza largePizza = new LargePizza();
            largePizza = new Cheese(largePizza);
            largePizza = new Ham(largePizza);
            largePizza = new Peppers(largePizza);

            Console.WriteLine(largePizza.GetDescription());
            Console.WriteLine("{0:C2}", largePizza.CalculateCost());
            #endregion

            Console.ReadKey();
        }
Example #21
0
        public void Test()
        {
            // Arrange
            IPizza pizza = new LargePizza();

            pizza = new Cheese(pizza);
            pizza = new Ham(pizza);
            pizza = new Cheese(pizza);

            // Act
            var description = pizza.GetDescription();
            var cost        = pizza.CalculateCost();

            // Assert
            Assert.AreEqual("Large Pizza, Cheese, Ham, Cheese", description);
            Assert.AreEqual(12.5, cost);

            // Analysis
            Console.WriteLine(description);
            Console.WriteLine("{0:C2}", cost);
        }
Example #22
0
 public void Initialise()
 {
     _largePizza = new LargePizza();
 }