Example #1
0
        public void Testing_PriceCalculation()
        {
            var sut = new PizzaModel();

            sut.Crust = new CrustModel()
            {
                Price = 5
            };
            sut.Size = new SizeModel()
            {
                Price = 7.5m
            };
            sut.Toppings = new List <ToppingModel>()
            {
                new ToppingModel()
                {
                    Price = 0.25m
                },
                new ToppingModel()
                {
                    Price = 0.5m
                }
            };

            decimal price = 13.25m;

            Assert.True(sut.CalculatePrice() == price);
        }
        public void AddPizza(PizzaModel pizza, string CustomerName)
        {
            var order = ReadOpenOrder(CustomerName);

            pizza.PizzaToppings = new List <PizzaToppingModel>();
            foreach (var topping in pizza.Toppings)
            {
                pizza.PizzaToppings.Add(new PizzaToppingModel()
                {
                    Topping = topping
                });
            }

            pizza.Price = pizza.CalculatePrice();

            order.Pizzas.Add(pizza);

            order.Price = order.CalculatePrice();

            _dbContext.Orders.Update(order);
            _dbContext.SaveChanges();
        }