Esempio n. 1
0
        public void Light_Burguer_Should_Be_10_Percent_Cheaper()
        {
            const decimal discount = 0.90m;

            var repository = new TestRepository();
            var burger     = new Burger(BurgerType.XCustom.ToString(),
                                        new List <BurgerIngredient>()
            {
                new BurgerIngredient()
                {
                    Ingredient = repository.GetIngredientByType(IngredientType.Lettuce)
                }
            },
                                        BurgerType.XCustom);

            var burgerOriginalPrice = burger.Price();
            var burgerSalePrice     = burger.Price(new LightSale());

            Assert.AreEqual <decimal>(burgerOriginalPrice * discount, burgerSalePrice);
        }
Esempio n. 2
0
        public BurgerViewModel(Burger burger)
        {
            if (burger == null)
            {
                throw new ArgumentNullException("burger");
            }

            BurgerType             = burger.Type.ToString();
            BurgerName             = burger.Name;
            BurgerPrice            = burger.Price();
            IngredientsDescription = burger.BurgerIngredients.Select(result => result.Ingredient.Description);
        }
Esempio n. 3
0
        public SaleDiscount SaleDiscount(Burger burger)
        {
            var saleDiscount = new SaleDiscount()
            {
                SaleDescription = DESCRIPTION
            };

            if (burger == null)
            {
                throw new ArgumentNullException("burguer");
            }

            var hasLettuce  = burger.BurgerIngredients.Any(has => has.Ingredient.IngredientType == IngredientType.Lettuce);
            var hasNotBacon = !burger.BurgerIngredients.Any(has => has.Ingredient.IngredientType == IngredientType.Bacon);

            if (hasLettuce && hasNotBacon)
            {
                saleDiscount.Discount = burger.Price() * DISCOUNT;
            }

            return(saleDiscount);
        }
Esempio n. 4
0
 public void SetBurger(Burger burger)
 {
     Burger      = burger;
     TotalValue += burger.Price();
 }