Exemplo n.º 1
0
 /// <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;
 }
Exemplo n.º 2
0
            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);
            }
Exemplo n.º 3
0
 /// <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));
 }
Exemplo n.º 4
0
 public GenericCalculator(ISpecialPricingRule discountRule)
 {
     _discountRule = discountRule;
     Guard.NotNull(_discountRule, nameof(_discountRule));
 }
Exemplo n.º 5
0
 /// <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;
 }
Exemplo n.º 6
0
 public void Act()
 {
     _specialPricingRule = PricingRuleFactory.Create(_pricingRuleDto);
 }