예제 #1
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");
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
0
        private void Test_VerifyOrderTally()
        {
            // arrange
            var order     = new Order();
            var meat      = new MeatPizza();
            var pineapple = new PineapplePizza();

            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"
                }
            };

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

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

            order.Pizzas.Add(meat);
            order.Pizzas.Add(pineapple);

            // act
            var actual = order.GetCurrentTally();

            // assert
            Assert.True(actual == 21.94m);
        }
예제 #5
0
        private void Test_CheckToString()
        {
            // arrange
            var user  = new User("test", "12345");
            var store = new Store();

            store.Name         = "First Store";
            user.SelectedStore = store;
            var order     = new Order();
            var meat      = new MeatPizza();
            var pineapple = new PineapplePizza();

            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"
                }
            };

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

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

            order.Pizzas.Add(meat);
            order.Pizzas.Add(pineapple);

            user.Orders.Add(order);

            // act
            var actual = user.ToString();

            // assert
            Assert.True(actual == "you have selected this store: First Store and ordered these pizzas: Meat Pizza\nPineapple Pizza\n");
        }