public void GivenABasketWithTwoOffers(string[] product, int[] quantity, decimal expectedPrice) { if (product.Length != quantity.Length) { throw new System.ArgumentException("Products and Quantity arrays must match"); } TestLogger butterOfferLogger = new TestLogger(); TestLogger milkOfferLogger = new TestLogger(); IOffer butterOffer = new NItemsOfFirstProductDeterminesDiscountOnSecond(butterOfferLogger, "Butter", "Bread", (noOfDiscounts) => new FiftyPercentOffDiscount(butterOfferLogger, noOfDiscounts)); IOffer milkOffer = new NthItemDiscount(milkOfferLogger, "Milk", 4, (noOfDiscounts) => new FreeItemDiscount(milkOfferLogger, noOfDiscounts)); Basket basket = new Basket(new IOffer[] { butterOffer, milkOffer }); // For each product, if this test requires it, put it into the basket with the appropriate quantity for (int i = 0; i < product.Length; i++) { basket.AddProductToBasket(GetProduct(product[i]), quantity[i]); } var result = basket.GetBasketTotalPrice(); Assert.That(result, Is.EqualTo(expectedPrice)); }
public void GivenABasketWithNoOffers(string[] product, int[] quantity, decimal expectedPrice) { if (product.Length != quantity.Length) { throw new System.ArgumentException("Products and Quantity arrays must match"); } Basket basket = new Basket(new IOffer[] { }); // For each product, if this test requires it, put it into the basket with the appropriate quantity for (int i = 0; i < product.Length; i++) { basket.AddProductToBasket(GetProduct(product[i]), quantity[i]); } var result = basket.GetBasketTotalPrice(); Assert.That(result, Is.EqualTo(expectedPrice)); }