예제 #1
0
        public void AddProducts_HappyPath()
        {
            GenerateDummy dummyGeneration = new GenerateDummy(_serviceProvider);
            var           products        = dummyGeneration.GenerateDummyProductList();
            var           CartRepository  = Substitute.For <IShoppingCartRepository>();

            _serviceProvider.GetService <IShoppingCartRepository>().Returns(CartRepository);
            var productService = new ShoppingCartService(_serviceProvider);

            Assert.True(productService.AddProducts(products) != null);
        }
예제 #2
0
        public async Task Shopping_Cart_Add_Success()
        {
            var products = await _productsService.GetAsync();

            await _shoppingCartService.AddProducts(products);

            var entries = await _shoppingCartService.GetAsync();

            entries.Should().NotBeEmpty();
            entries.Length.Should().Be(2);

            ShoppingCartAssertInternal(entries[0], products[0], 1);
            ShoppingCartAssertInternal(entries[1], products[1], 1);
        }
예제 #3
0
        public async Task Shopping_Cart_TotalPrice_Get_Success()
        {
            var products = await _productsService.GetAsync();

            products.Should().NotBeNullOrEmpty();

            var total = products.Sum(p => p.Price);

            var shoppingCartService = new ShoppingCartService(new ProductPricingService());
            await shoppingCartService.AddProducts(products);

            var totalPrice = await shoppingCartService.TotalAsync();

            totalPrice.Should().Be(total);
        }