public void ShouldApplyNoDiscountsfor1Bread1Butter1MilkInShoppingBasket() { // Given var shoppingBasket = new ShoppingBasket { Products = new List <Product> { new Bread { ProductType = ProductType.BREAD }, new Butter { ProductType = ProductType.BUTTER }, new Milk { ProductType = ProductType.MILK } }, Total = 0.0 }; var expectedCount = shoppingBasket.Products.Count; double expectedTotal = 2.95; // When _discountService.ApplyDiscounts(shoppingBasket); // Then Assert.Equal(expectedCount, shoppingBasket.Products.Count); Assert.Equal(expectedTotal, shoppingBasket.Total); }
public decimal GetTotalSum() { var totalSum = CalculateSumPriceOfAllItems(); var totalSumWithDiscounts = _discountService.ApplyDiscounts(totalSum, Items, ValidDiscounts); totalSumWithDiscounts = Math.Round(totalSumWithDiscounts, 2, MidpointRounding.AwayFromZero); _logger.LogBasketToConsole(totalSumWithDiscounts, Items, ValidDiscounts); return(totalSumWithDiscounts); }
public void Checkout(ShoppingBasket shoppingBasket) { _discountService.ApplyDiscounts(shoppingBasket); }