public async void PriceProviderAddsPriceFromPricePart() { var cart = new List <ShoppingCartItem> { new ShoppingCartItem(1, "foo"), new ShoppingCartItem(4, "bar"), new ShoppingCartItem(1, "baz") }; var productService = new DummyProductService( BuildProduct("foo", 50.0M), BuildProduct("bar", 30.0M), BuildProduct("baz", 10.0M)); var priceProvider = new PriceProvider(productService); await priceProvider.AddPrices(cart); foreach (var item in cart) { Assert.Single(item.Prices); Assert.Equal(item.Prices.Single().Value, (await productService.GetProduct(item.ProductSku)).ContentItem.As <PricePart>().Price.Value, 2); } }
public async void PriceProviderAddsPriceFromPricePart() { var cart = new ShoppingCart( new ShoppingCartItem(1, "foo"), new ShoppingCartItem(4, "bar"), new ShoppingCartItem(1, "baz")); var productService = new DummyProductService( BuildProduct("foo", 50.0M), BuildProduct("bar", 30.0M), BuildProduct("baz", 10.0M)); var priceProvider = new PriceProvider(productService, new TestMoneyService()); cart = cart.With(await priceProvider.AddPrices(cart.Items)); foreach (var item in cart.Items) { Assert.Single(item.Prices); Assert.Equal( item.Prices.Single().Price.Value, (await productService.GetProduct(item.ProductSku)).ContentItem.As <PricePart>().Price.Value, precision: 2); } }