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(); }
public void GivenFindWhenNoMatchingPromotionFoundThenReturnNull() { var sut = new PromotionProvider(); var promotion = sut.Find(new CartItem(new Item() { Sku = "Random" }, 2)); promotion.Should().BeNull(); }
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>(); }
public PromotionTest() { _promotionProvider = new PromotionProvider(); }
/// <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)); }