Пример #1
0
        public void CalculateProductPrice_ProductWithoutPromotion_ShouldBeQuantityTimeUnitPrice()
        {
            var product = new Product
            {
                Id        = 1,
                Name      = "t-shirt",
                Price     = 10,
                Promotion = null
            };

            var actual = sut.CalculateProductPrice(product, 2);

            actual.ShouldBe(20);
        }
Пример #2
0
 private IEnumerable <CheckoutItem> GetItems(IEnumerable <SelectedProduct> selection, IEnumerable <Product> products)
 {
     foreach (var product in products.Where(p => selection.Select(sel => sel.Id).Contains(p.Id)))
     {
         var quantity = selection.FirstOrDefault(s => s.Id == product.Id).Quantity;
         yield return(new CheckoutItem
         {
             Product = product,
             Price = priceCalculator.CalculateProductPrice(product, quantity)
         });
     }
 }