public void RulesApplicationGeneratesNonStrictlyMonotonicDescendingPriceTrend(PromotionRuleType type) { var testContext = new TestContext(); IPromotionRule rule = new PromotionRuleFactory(testContext).Create(type); ICart cart = new CartFactory(testContext).Create(type); decimal originalPrice = cart.Total; ICart newCart = rule.Evaluate(cart); decimal newPrice = newCart.Total; Assert.True(newPrice <= originalPrice); }
public void RulesApplicationGeneratesNonStrictlyMonotonicDescendingQuantityTrend(PromotionRuleType type) { var testContext = new TestContext(); IPromotionRule rule = new PromotionRuleFactory(testContext).Create(type); ICart cart = new CartFactory(testContext).Create(type); int originalQuantity = cart.Quantity; ICart newCart = rule.Evaluate(cart); int newQuantity = newCart.Quantity; Assert.True(newQuantity <= originalQuantity); }
public void RulesApplicationChangesNothingWhenAllEntriesAreAlreadyMarkedAsHandled(PromotionRuleType type) { var testContext = new TestContext(); IPromotionRule rule = new PromotionRuleFactory(testContext).Create(type); ICart cart = new CartFactory(testContext).Create(type); var invariantPromotionRule = new InvariantPromotionRule(testContext.CartFactory); ICart cartWithNoPromotableItems = invariantPromotionRule.Evaluate(cart); decimal originalPrice = cartWithNoPromotableItems.Total; int originalQuantity = cartWithNoPromotableItems.Quantity; int originalCount = cartWithNoPromotableItems.Count; ICart newCart = rule.Evaluate(cartWithNoPromotableItems); decimal newPrice = newCart.Total; int newQuantity = newCart.Quantity; int newCount = newCart.Count; Assert.Equal(originalPrice, newPrice); Assert.Equal(originalQuantity, newQuantity); Assert.Equal(originalCount, newCount); }