public void ResolveNoPromotions(decimal productPrice, int quantity, decimal expectedPrice) { var promotionRepository = new Mock <IPromotionRepository>(); promotionRepository.Setup(p => p.FindByProduct("Apple")).Returns(new List <Promotion>()); var priceResolver = new PriceResolver(promotionRepository.Object); var price = priceResolver.Resolve("Test", productPrice, quantity, PricingStrategy.Lowest); Assert.Equal(expectedPrice, price); }
public void Resolve(string productName, decimal productPrice, int quantity, PricingStrategy pricingStrategy, double?expectedPrice) { var promotionRepository = new Mock <IPromotionRepository>(); promotionRepository.Setup(p => p.FindByProduct("Apple")).Returns( new List <Promotion> { new Promotion("Test", "Apple", PromotionType.OnSale, null, 2.5m, null, DateTime.UtcNow.AddDays(-2), DateTime.UtcNow.AddDays(1), null), new Promotion("Test 2", "Apple", PromotionType.GroupSale, 2, 2.0m, null, DateTime.UtcNow.AddDays(-1), DateTime.UtcNow.AddDays(1), null), new Promotion("Test 3", "Apple", PromotionType.AdditionalSale, 1, null, 0.5f, DateTime.UtcNow.AddDays(-1), DateTime.UtcNow.AddDays(1), null) }); var priceResolver = new PriceResolver(promotionRepository.Object); var price = priceResolver.Resolve(productName, productPrice, quantity, pricingStrategy); Assert.Equal((decimal?)expectedPrice, price); }