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