Ejemplo n.º 1
0
        public async Task ShoppingCart_MultipleProducts_Total_Success()
        {
            var products = await _productsService.GetAsync();

            var product = products.First();

            var cartService = new ShoppingCartService(new ProductPricingService());
            await cartService.AddAsync(product);

            await cartService.AddAsync(product);

            var total = await cartService.TotalAsync();

            total.Should().Be(product.Price * 2);
        }
Ejemplo n.º 2
0
        public async Task Shopping_Cart_ProductCount_Increase_Success()
        {
            var products = await _productsService.GetAsync();

            var product = products.First();

            await _shoppingCartService.AddAsync(product);

            var entries = await _shoppingCartService.GetAsync();

            var entry = entries.First(e => e.Product.Id == product.Id);

            ShoppingCartAssertInternal(entry, product, 2);
        }
Ejemplo n.º 3
0
        public async Task ShoppingCart_Discount(int count, decimal expectedPrice)
        {
            var products = await _productsService.GetAsync();

            var jeans = products.First(x => x.Id == ProductsService.Jeans.Id);

            var shoppingCartService = new ShoppingCartService(new ProductPricingService());

            for (var i = 0; i < count; i++)
            {
                await shoppingCartService.AddAsync(jeans);
            }
            var actualPrice = await shoppingCartService.TotalAsync();

            actualPrice.Should().Be(expectedPrice);
        }