public void Setup() { Mock <Microsoft.Extensions.Logging.ILogger> mockLogger = new Mock <Microsoft.Extensions.Logging.ILogger>(); var mockMultiBuyOfferRepository = new Mock <IMultiBuyOfferRepository>(); mockMultiBuyOfferRepository .SetupGet <IList <int> >(m => m.EligableProducts) .Returns(new List <int> { 1, 2, 3, 4, 5, 6 }); mockMultiBuyOfferRepository .SetupGet <Dictionary <int, decimal> >(m => m.DiscountLookup) .Returns(new Dictionary <int, decimal> { { 2, 0.05m }, { 3, 0.1m }, { 4, 0.2m }, { 5, 0.25m } }); _discountCalculator = new MultiBuyDiscountCalculator(mockLogger.Object, mockMultiBuyOfferRepository.Object); }
public void Setup() { Mock <Microsoft.Extensions.Logging.ILogger> mockLogger = new Mock <Microsoft.Extensions.Logging.ILogger>(); var mockProductRepository = new Mock <IProductRepository>(); mockProductRepository.Setup(m => m.GetProductItems(It.IsAny <IList <int> >())) .Returns((IList <int> productIds) => { var products = new List <IProductItem>(); foreach (var id in productIds) { products.Add(new ProductItem() { ProductId = id, Price = 8 }); } return(products); }); var mockMultiBuyOfferRepository = new Mock <IMultiBuyOfferRepository>(); mockMultiBuyOfferRepository .SetupGet <IList <int> >(m => m.EligableProducts) .Returns(new List <int> { 1, 2, 3, 4, 5, 6 }); mockMultiBuyOfferRepository .SetupGet <Dictionary <int, decimal> >(m => m.DiscountLookup) .Returns(new Dictionary <int, decimal> { { 2, 0.05m }, { 3, 0.1m }, { 4, 0.2m }, { 5, 0.25m } }); var discountCalculator = new MultiBuyDiscountCalculator(mockLogger.Object, mockMultiBuyOfferRepository.Object); _priceCalculator = new PriceCalculator(mockLogger.Object, mockProductRepository.Object, discountCalculator); }