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); }
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); }
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); }
public void SetBurger(Burger burger) { Burger = burger; TotalValue += burger.Price(); }