public void GetItemPrice() { var fileReader = new Mock <IProductCatalogFileReader>(); fileReader.Setup(x => x.GetTextReader()).Returns(_catalogTestData.GetValidTestData()); var testRepository = new ProductCatalogRepository(fileReader.Object); var priceService = new PriceService(testRepository); var saleItem = new BasketItem() { Name = "Apple" }; var normalItem = new BasketItem() { Name = "Banana" }; var saleItemResult = priceService.GetItemPrice(saleItem); var normalItemResult = priceService.GetItemPrice(normalItem); Assert.IsTrue(saleItemResult == 0.50M); Assert.IsTrue(normalItemResult == 0.75M); }
public void TestLoadANormalCatalog() { var fileReader = new Mock <IProductCatalogFileReader>(); fileReader.Setup(x => x.GetTextReader()).Returns(_catalogTestData.GetValidTestData()); var testRepository = new ProductCatalogRepository(fileReader.Object); var catalog = testRepository.GetItems().ToList(); Assert.IsTrue(catalog.Count() == 2); }