Beispiel #1
0
        private void ApplyOffer(Product item, IList <IOffer> offers, int offerId)
        {
            IOffer openOffer = offers.FirstOrDefault(o => o.Id == offerId && !o.OfferSatisfied);

            if (openOffer == null)
            {
                if (offerId == 1)
                {
                    openOffer = new Offer1();
                }
                else
                {
                    openOffer = new Offer2();
                }

                openOffer.ProductsInOffer.Add(item);
                openOffer.CheckOfferConditions();
                offers.Add(openOffer);
            }
            else
            {
                openOffer.ProductsInOffer.Add(item);
                openOffer.CheckOfferConditions();
            }
        }
Beispiel #2
0
        public void Constructor_SetsTheDefaultValues()
        {
            IOffer cut = new Offer2();

            Assert.Equal("Buy 3 Milk and get the 4th milk for free", cut.OfferDescription);
            Assert.Equal(3.45m, cut.OfferPrice);
            Assert.NotNull(cut.OfferRules);
            Assert.NotNull(cut.ProductsInOffer);
        }