Exemple #1
0
 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));
 }
Exemple #3
0
 public Offer(SpecialOfferType offerType, Product product, double argument)
 {
     OfferType = offerType;
     Argument  = argument;
     _product  = product;
 }
Exemple #4
0
 public void AddSpecialOffer(SpecialOfferType offerType, Product product, double argument)
 {
     _offers[product] = new Offer(offerType, product, argument);
 }
Exemple #5
0
 public Offer(SpecialOfferType offerType, Product product, double argument)
 {
     this.OfferType = offerType;
     this.Argument  = argument;
     this._product  = product;
 }
Exemple #6
0
 public Offer(SpecialOfferType offerType, Product product)
 {
     OfferType = offerType;
     Product   = product;
 }
 public void AddSpecialOffer(SpecialOfferType offerType, Product product)
 {
     _offers[product] = new Offer(offerType, product);
 }
Exemple #8
0
        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);
        }