public void CheckNoDiscountProducts() { var offer = new DiscountOffer("Soup", 0.3m); var discountProduct = offer.DetermineSpecialOffer(_products); Assert.IsNull(discountProduct); }
public void CheckEggDiscount() { var offer = new DiscountOffer("Eggs", 0.1m); var discountProduct = offer.DetermineSpecialOffer(_products); //expecting 10% off the price of Eggs (30p), so discountProduct should be 3p Assert.AreEqual("Eggs 10% off", discountProduct.ProductName); Assert.AreEqual(-0.03m, discountProduct.Price); }
private void InitAllOffers() { var startThisWeek = new DateTime(2018, 03, 25); var endThisWeek = new DateTime(2018, 04, 1); _offers = new List <SpecialOfferDuration>(); //TODO: move this function out of the code so Offers can be dynamically added var appleOffer = new DiscountOffer("Apples", 0.1m); var soupOffer = new MultibuyOffer("Soup", 2, "Bread", 0.5m); _offers.Add(new SpecialOfferDuration() { StartDate = startThisWeek, EndDate = endThisWeek, SpecialOffer = appleOffer }); _offers.Add(new SpecialOfferDuration() { StartDate = startThisWeek, EndDate = endThisWeek, SpecialOffer = soupOffer }); }