Exemplo n.º 1
0
        static void Main(string[] args)
        {
            List <IProduct> cart = new List <IProduct>();

            cart.Add(new Product("A")
            {
                Quantity = 3
            });
            cart.Add(new Product("B")
            {
                Quantity = 5
            });
            cart.Add(new Product("C")
            {
                Quantity = 1
            });
            cart.Add(new Product("D")
            {
                Quantity = 1
            });

            PromotionProvider promotions = new PromotionProvider();
            decimal           totalprice = promotions.ApplyPromotion(cart);

            Console.WriteLine("Total price after promotion applied:-" + totalprice);

            Console.ReadLine();
        }
Exemplo n.º 2
0
        public void GivenFindWhenNoMatchingPromotionFoundThenReturnNull()
        {
            var sut = new PromotionProvider();

            var promotion = sut.Find(new CartItem(new Item()
            {
                Sku = "Random"
            }, 2));

            promotion.Should().BeNull();
        }
Exemplo n.º 3
0
        public void GivenFindWhenMatchingPromotionFoundThenReturnPromotion()
        {
            var sut = new PromotionProvider();

            var promotion = sut.Find(new CartItem(new Item()
            {
                Sku = "D"
            }, 2));

            promotion.Should().NotBeNull();
            promotion.Should().BeOfType <QuantityForPercentagePromotion>();
        }
Exemplo n.º 4
0
 public PromotionTest()
 {
     _promotionProvider = new PromotionProvider();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Checks binding conditions for given type member. Could be overriden in derived classes.
 ///
 /// This implementation uses BindableAttribute for evaluating conditions
 /// </summary>
 /// <param name="member">Instance of MemberInfo</param>
 /// <returns>true if member could participate in binding</returns>
 public virtual bool CanBind(MemberInfo member)
 {
     return(PromotionProvider.IsPromoted(member));
 }