Example #1
0
        private static APizza PizzaCreator()
        {
            Console.WriteLine(@"Would you like a MeatPizza, or to create your own Pizza?
1: MeatPizza
2: Create my own!
");
            switch (Common.Answer(1, 2))
            {
            case 1:
            {
                MeatPizza Pizza = new MeatPizza(1);
                return(Pizza);

                break;
            }

            case 2:
            {
                CYOPizza Pizza = new CYOPizza(1);
                return(Pizza);

                break;
            }
            }
            //this shouldnt ever be reached.
            return(null);
        }
Example #2
0
        /// <summary>
        /// Map DBPizza => APizza
        /// Uses enum to determine which crust class to return.
        /// Note: premade pizza classes have constructors to set all variables properly.
        /// Therefore, they do not need any data tobe passed innto them.
        /// Custom pizza however only has 1 constructor that requires crust, size, and toppings
        /// to be passed into them.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public APizza Map(DBPizza entity)
        {
            APizza pizza;

            switch (entity.PIZZA)
            {
            case Entities.EntityModels.PIZZAS.CUSTOM:
                Crust          crust    = mapperCrust.Map(entity.DBCrust);
                Size           size     = mapperSize.Map(entity.DBSize);
                List <Topping> toppings = new List <Topping>();
                entity.DBToppings.ForEach(Topping => toppings.Add(mapperTopping.Map(Topping)));

                pizza = new CustomPizza(crust, size, toppings);
                break;

            case Entities.EntityModels.PIZZAS.HAWAIIAN:
                pizza = new HawaiianPizza();
                break;

            case Entities.EntityModels.PIZZAS.MEAT:
                pizza = new MeatPizza();
                break;

            case Entities.EntityModels.PIZZAS.VEGAN:
                pizza = new VeganPizza();
                break;

            default:
                throw new ArgumentException("Size not recognized. Size could not be mapped properly");
            }

            return(pizza);
        }
Example #3
0
        /// <summary>
        /// Map DBPizza => APizza
        /// Uses enum to determine which crust class to return.
        /// Note: premade pizza classes have constructors to set all variables properly.
        /// Therefore, they do not need any data tobe passed innto them.
        /// Custom pizza however only has 1 constructor that requires crust, size, and toppings
        /// to be passed into them.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public APizza Map(DBPizza entity)
        {
            APizza pizza;

            switch (entity.PIZZA)
            {
            case PIZZAS.CUSTOM:
                ACrust          crust    = mapperCrust.Map(entity.DBCrust);
                ASize           size     = mapperSize.Map(entity.DBSize);
                List <ATopping> toppings = new List <ATopping>();
                entity.DBPlacedToppings.ToList().ForEach(placedTopping => toppings.Add(mapperTopping.Map(placedTopping.Topping)));

                pizza = new CustomPizza(crust, size, toppings);
                break;

            case PIZZAS.HAWAIIAN:
                pizza = new HawaiianPizza(mapperSize.Map(entity.DBSize));
                break;

            case PIZZAS.MEAT:
                pizza = new MeatPizza(mapperSize.Map(entity.DBSize));
                break;

            case PIZZAS.VEGAN:
                pizza = new VeganPizza(mapperSize.Map(entity.DBSize));
                break;

            default:
                throw new ArgumentException("Pizza not recognized. Pizza could not be mapped properly");
            }

            pizza.CalculatePrice();
            pizza.ID = entity.ID;
            return(pizza);
        }
Example #4
0
        private void Test_ConfirmPizzaSizeChanged()
        {
            // arrange
            var order = new Order();
            var meat  = new MeatPizza();

            List <Size> sizes = new List <Size>()
            {
                new Size {
                    EntityId = 1, Name = "Small", Inches = 10, Price = .99m
                },
                new Size {
                    EntityId = 2, Name = "Medium", Inches = 12, Price = 2.99m
                },
                new Size {
                    EntityId = 3, Name = "Large", Inches = 14, Price = 4.99m
                }
            };

            meat.AddSize(sizes);
            order.Pizzas.Add(meat);

            // act
            order.ChangePizzaSize(0, "Small", sizes);
            var actual = order;

            // assert
            Assert.True(actual.Pizzas[0].Size.Name == "Small");
        }
Example #5
0
        public APizza Map(Pizza model)
        {
            APizza pizza;

            switch (model.PizzaType)
            {
            case Entities.PIZZA_TYPE.Meat:
                pizza = new MeatPizza();
                break;

            case Entities.PIZZA_TYPE.Vegan:
                pizza = new VeganPizza();
                break;

            case Entities.PIZZA_TYPE.Custom:
                pizza = new CustomPizza();
                break;

            default:
                throw new ArgumentException("PizzaMapper encountered an unknown type when mapping from DB Model to Domain Model");
            }

            pizza.Crust = crustMapper.Map(model.Crust);
            pizza.Size  = sizeMapper.Map(model.Size);
            List <Domain.Models.Topping> toppings = new List <Domain.Models.Topping>();

            model.Toppings.ForEach(topping => toppings.Add(toppingMapper.Map(topping)));
            pizza.Toppings = toppings;
            //pizza.Price = model.Price;
            return(pizza);
        }
Example #6
0
        private void Test_CheckCrustAdded()
        {
            // arrange
            var sut = new MeatPizza(); // inference

            List <Crust> crusts = new List <Crust>()
            {
                new Crust {
                    EntityId = 1, Name = "Thin", Price = .99m
                },
                new Crust {
                    EntityId = 2, Name = "Regular", Price = 1.99m
                },
                new Crust {
                    EntityId = 3, Name = "Large", Price = 2.99m
                }
            };

            // act
            sut.AddCrust(crusts);
            var actual = sut;

            // assert
            Assert.IsType <Crust>(actual.Crust);
            Assert.NotNull(actual.Crust);
        }
Example #7
0
        private void Test_ConfirmPizzaCrustChanged()
        {
            // arrange
            var order = new Order();
            var meat  = new MeatPizza();

            List <Crust> crusts = new List <Crust>()
            {
                new Crust {
                    EntityId = 1, Name = "Thin", Price = .99m
                },
                new Crust {
                    EntityId = 2, Name = "Regular", Price = 1.99m
                },
                new Crust {
                    EntityId = 3, Name = "Large", Price = 2.99m
                }
            };

            meat.AddCrust(crusts);
            order.Pizzas.Add(meat);

            // act
            order.ChangePizzaCrust(0, "Large", crusts);
            var actual = order;

            // assert
            Assert.True(actual.Pizzas[0].Crust.Name == "Large");
        }
Example #8
0
        private void Test_CheckSizeAdded()
        {
            // arrange
            var sut = new MeatPizza(); // inference

            List <Size> sizes = new List <Size>()
            {
                new Size {
                    EntityId = 1, Name = "Small", Inches = 10, Price = .99m
                },
                new Size {
                    EntityId = 2, Name = "Medium", Inches = 12, Price = 2.99m
                },
                new Size {
                    EntityId = 3, Name = "Large", Inches = 14, Price = 4.99m
                }
            };

            // act
            sut.AddSize(sizes);
            var actual = sut;

            // assert
            Assert.IsType <Size>(actual.Size);
            Assert.NotNull(actual.Size);
        }
        public void Test_MeatPizza()
        {
            var meat_pie = new MeatPizza();

            // Assert.True(meat_pie.Size.Name.Equal("Medium"));
            Assert.NotNull(meat_pie);
            Assert.NotNull(meat_pie.Toppings);
        }
Example #10
0
        private void Test_HasSize()
        {
            var sut = new MeatPizza();

            var actual = sut;

            Assert.IsType <MeatPizza>(actual.Size);
        }
Example #11
0
        public void Test_MeatPizza()
        {
            var sut = new MeatPizza();

            Assert.NotNull(sut.Crust);
            Assert.NotNull(sut.Size);
            Assert.NotNull(sut.Toppings);
        }
Example #12
0
        private void Test_ComputesPrice()
        {
            var sut = new MeatPizza(new Size("small"), new Crust("regular"));

            var actual = sut;

            Assert.NotNull(actual.Price);
        }
Example #13
0
        private void Test_VerifyPricingComputation()
        {
            // arrange
            var sut = new MeatPizza(); // inference

            List <Crust> crusts = new List <Crust>()
            {
                new Crust {
                    EntityId = 1, Name = "Thin", Price = .99m
                },
                new Crust {
                    EntityId = 2, Name = "Regular", Price = 1.99m
                },
                new Crust {
                    EntityId = 3, Name = "Large", Price = 2.99m
                }
            };

            List <Size> sizes = new List <Size>()
            {
                new Size {
                    EntityId = 1, Name = "Small", Inches = 10, Price = .99m
                },
                new Size {
                    EntityId = 2, Name = "Medium", Inches = 12, Price = 2.99m
                },
                new Size {
                    EntityId = 3, Name = "Large", Inches = 14, Price = 4.99m
                }
            };

            List <Topping> toppings = new List <Topping>()
            {
                new Topping {
                    EntityId = 1, Name = "Cheese"
                },
                new Topping {
                    EntityId = 2, Name = "Pepperoni"
                },
                new Topping {
                    EntityId = 3, Name = "Sausage"
                },
                new Topping {
                    EntityId = 4, Name = "Pineapple"
                }
            };

            sut.AddCrust(crusts);
            sut.AddSize(sizes);
            sut.AddToppings(toppings);

            // act
            var actual = sut.GetTotalPrice();

            // assert
            Assert.True(actual == 10.97m);
        }
Example #14
0
        private void Test_PizzaExists()
        {
            var sut = new MeatPizza();

            var actual = sut;

            Assert.IsType <MeatPizza>(actual);
            Assert.NotNull(actual);
        }
Example #15
0
        public static void TestPointer()
        {
            APizza        p = new MeatPizza(SizeType.Large);
            List <APizza> l = new List <APizza>();

            l.Add(p);
            p = null;
            Console.WriteLine(l[0]);
        }
Example #16
0
        private void Test_HasSizeAndCrust()
        {
            var sut = new MeatPizza(new Size(), new Crust());

            var actual = sut;

            Assert.IsType <Size>(actual.Size);
            Assert.IsType <Crust>(actual.Crust);
        }
Example #17
0
        private void Test_MeatPizzaExists()
        {
            // arrange
            Size      size      = new Size("Small");
            string    crust     = "Garlic";
            MeatPizza meatpizza = new MeatPizza(size, crust);

            Assert.Equal(size, meatpizza.Size);
            Assert.Equal(crust, meatpizza.Crust);
        }
        public void Test_Pizza_Price()
        {
            //subject under test
            var sut = new MeatPizza();
            //actual
            var act = sut.PizzaPrice();

            //assert
            Assert.Equal(act, 12.5m);
        }
Example #19
0
        public static void TestOrder()
        {
            var order  = new Order();
            var pizza1 = new MeatPizza(SizeType.Large);
            var pizza2 = new MeatPizza(SizeType.Large);

            order.AddPizza(pizza1);
            order.AddPizza(pizza2);
            // var dict = order.ViewPizzas();
            Console.WriteLine(order);
        }
        [InlineData("Meat Pizza")] //expectation on the outside of the test

        public void Test_MeatPizza_Theory(string expected)
        {
            // arrange
            var sut = new MeatPizza();

            // act
            var actual = sut.Name;

            // assert
            Assert.Equal(expected, actual);
        }
Example #21
0
        public void Test_MeatPizza_ToString()
        {
            var sut = new MeatPizza()
            {
                Name = "Meat Pizza"
            };

            string actual = sut.ToString();

            Assert.IsType <string>(actual);
        }
        public void Test_MeatPizzaSize()
        {
            // arrange
            var sut = new MeatPizza();

            // act
            var actual = sut.Size;

            // assert
            Assert.NotNull(actual);
        }
        public void Test_MeatCrust()
        {
            // arrange
            var sut = new MeatPizza();

            // act
            var actual = sut.Crust;

            // assert
            Assert.NotNull(sut.Crust);
        }
        public void Test_MeatPizzaToppings()
        {
            // arrange
            var sut = new MeatPizza();

            // act
            var actual = sut.Toppings;

            // assert
            Assert.NotNull(actual);
        }
Example #25
0
        private void Test_CheckPriceAdded()
        {
            // arrange
            var sut = new MeatPizza(); // inference

            // act
            var actual = sut;

            // assert
            Assert.True(actual.TypePrice == 5.99m);
        }
Example #26
0
        private void Test_CheckNameAdded()
        {
            // arrange
            var sut = new MeatPizza(); // inference

            // act
            var actual = sut;

            // assert
            Assert.True(actual.Name == "Meat Pizza");
        }
Example #27
0
        private void Test_Pizzas_Have_Crust()
        {
            // arrange
            var sut = new MeatPizza();

            // act
            var actual = sut.Crust;

            // assert
            Assert.NotNull(actual);
        }
Example #28
0
        private void Test_Pizzas_Have_Names()
        {
            // arrange
            var sut = new MeatPizza();

            // act
            var actual = sut.Name;

            // assert
            Assert.True(actual == "Meat Pizza");
        }
Example #29
0
        public void Test_PizzaPrice()
        {
            // arrange
            var sut = new MeatPizza(new MediumSize());

            // act
            var actual = sut.CalculatePrice();

            // assert
            Assert.True(actual == (decimal)11.5);
        }
Example #30
0
        private void Test_Pizzas_Have_Toppings()
        {
            // arrange
            var sut = new MeatPizza();

            // act
            var actual = sut.Toppings;

            // assert
            Assert.NotNull(actual);
        }