Example #1
0
        public void Exception_On_Calculate_With_Null()
        {
            var menu = new List <Item>();

            menu.Add(new Item {
                Name = "Cola", Price = (decimal)0.5, Category = ItemCategory.Drink, Temperature = ItemTemperature.Cold
            });
            menu.Add(new Item {
                Name = "Coffee", Price = (decimal)1, Category = ItemCategory.Drink, Temperature = ItemTemperature.Hot
            });
            menu.Add(new Item {
                Name = "Cheese Sandwich", Price = (decimal)2, Category = ItemCategory.Food, Temperature = ItemTemperature.Cold
            });
            menu.Add(new Item {
                Name = "Steak Sandwich", Price = (decimal)4.5, Category = ItemCategory.Food, Temperature = ItemTemperature.Hot
            });

            var sut = new SurchargeCalculator(menu);

            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => sut.Calculate(0, null));

            Assert.Equal("order", ex.ParamName);
        }
Example #2
0
        public void Order_Cold_Food_With_Roundup(string[] order, decimal expectedValue)
        {
            var menu = new List <Item>();

            menu.Add(new Item {
                Name = "Cola", Price = (decimal)0.5, Category = ItemCategory.Drink, Temperature = ItemTemperature.Cold
            });
            menu.Add(new Item {
                Name = "Coffee", Price = (decimal)1, Category = ItemCategory.Drink, Temperature = ItemTemperature.Hot
            });
            menu.Add(new Item {
                Name = "Cheese Sandwich", Price = (decimal)2, Category = ItemCategory.Food, Temperature = ItemTemperature.Cold
            });
            menu.Add(new Item {
                Name = "Steak Sandwich", Price = (decimal)4.5, Category = ItemCategory.Food, Temperature = ItemTemperature.Hot
            });

            var sut = new SurchargeCalculator(menu);

            var result = sut.Calculate((decimal)10.01, order);

            Assert.Equal(expectedValue, result);
        }