/// <summary> /// Apply a new promotional price for the product /// </summary> /// <exception cref="ArgumentNullException">Thrown if the given <c>IPromotionPricingRule</c> is null</exception> /// <param name="theRule">the promotion rule</param> public void AppyPromotionRule(ISpecialPricingRule theRule) { Guard.NotNull(theRule, nameof(theRule)); CurrentPromoPricingRule = theRule; Price = theRule.OriginalPrice; IsPromoProduct = true; }
public void ArrangeWhenPriceApplies() { _fixture = new Fixture(); _fixture.Customize(new AutoRhinoMockCustomization()); _pricingRule = _fixture.Create <ISpecialPricingRule>(); _product = _fixture.Create <Product>(); _pricingRule.Stub(r => r.IsApplicable( Arg <ICollection <Product> > .Matches(p => p.First().ProductId == _product.ProductId))) .Return(true); _pricingRule.Expect(r => r.Apply(Arg <ICollection <Product> > .Matches(p => p.First().ProductId == _product.ProductId))); _sut = new Checkout(new List <ISpecialPricingRule> { _pricingRule }); _sut.AddItem(_product); }
/// <summary> /// Apply the given <c>ISpecialPricingRule</c> to the list of <c>StockKeepingUnit</c> /// </summary> /// <param name="discountedProducts">The rule to apply</param> /// <param name="rule">The list on which to apply the rule</param> private void ApplyDiscountToProducts(List <StockKeepingUnit> discountedProducts, ISpecialPricingRule rule) { discountedProducts.ForEach(x => x.AppyPromotionRule(rule)); }
public GenericCalculator(ISpecialPricingRule discountRule) { _discountRule = discountRule; Guard.NotNull(_discountRule, nameof(_discountRule)); }
/// <summary> /// Set a new price for the product and remove any promo rules currently /// </summary> /// <param name="newPrice">The new price for the product after all promotion is ended</param> public void EndPromo(double newPrice) { CurrentPromoPricingRule = null; Price = newPrice; IsPromoProduct = false; }
public void Act() { _specialPricingRule = PricingRuleFactory.Create(_pricingRuleDto); }