public void ReturnsDiscountSpecialOfferCreatedByFactory() { var testPromotion = _fixture.Create <Promotion>(); _mockPromotionFactory.Setup(x => x.Create(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <decimal>())) .Returns(testPromotion); var promotions = _sut.All(); testPromotion.ShouldBe(promotions.ElementAt <IPromotion>(0)); }
public AppliedPromotionInfo ApplyPromotions() { var promotions = _promotionRepository.All(); var appliedPromotionInfo = new AppliedPromotionInfo(); foreach (var currentPromotion in promotions) { var discount = currentPromotion.CalculateDiscount(_products); if (discount > 0) { appliedPromotionInfo.Discount = discount; return(appliedPromotionInfo); } } return(appliedPromotionInfo); }