public static OfferType GetOfferType(SpecialOfferType type) { if (type == SpecialOfferType.ThreeForTwo) { return(new ThreeForTwoOffer()); } else if (type == SpecialOfferType.FiveForAmount) { return(new FiveForAmount()); } else if (type == SpecialOfferType.TenPercentDiscount) { return(new TenPercentDiscountOffer()); } else if (type == SpecialOfferType.TwoForAmount) { return(new TwoForAmountDiscount()); } else { throw new Exception(); } }
public void AddSpecialOffer(SpecialOfferType offerType, Product product, double argument) { this.offers.Add(product, new Offer(offerType, product, argument)); }
public Offer(SpecialOfferType offerType, Product product, double argument) { OfferType = offerType; Argument = argument; _product = product; }
public void AddSpecialOffer(SpecialOfferType offerType, Product product, double argument) { _offers[product] = new Offer(offerType, product, argument); }
public Offer(SpecialOfferType offerType, Product product, double argument) { this.OfferType = offerType; this.Argument = argument; this._product = product; }
public Offer(SpecialOfferType offerType, Product product) { OfferType = offerType; Product = product; }
public void AddSpecialOffer(SpecialOfferType offerType, Product product) { _offers[product] = new Offer(offerType, product); }
public void GetTotalCartPrice_OfferNotValidOnProduct_ReturnAmountWithUnDiscountedPrice(SpecialOfferType specialOfferType) { double expectedValue = 29.31; IShoppingCatalog Catalog = new FakeCatalog(); Catalog.AddProduct(Talc, 19.54); ShoppingCart cart = new ShoppingCart(); cart.AddLine(new OrderLine(Talc, 1.5)); var order = new Order(Catalog); order.AddSpecialOffer(specialOfferType, Talc); var receipt = order.ChecksOutGoods(cart); double actaulValue = receipt.GetTotalPrice(); Assert.AreEqual(expectedValue, actaulValue); }