private void AssertCartDidntChange()
 {
     new Assert_SetEquals <ProductId, ProductInCart>
     (
         ProductForCart.ToProductInCart(useCase_addProductToCart.ProductsAdd),
         x => x.ProductId
     ).AssertEquals(MarketBridge.GetShoppingCartItems());
 }
示例#2
0
        private UseCase_AddProductToCart_TestLogic AddProductsToCart(UserInfo user, IEnumerable <ProductForCart> products)
        {
            var useCase_addProductToCart_testLogic = new UseCase_AddProductToCart_TestLogic(SystemContext, user);

            useCase_addProductToCart_testLogic.Setup();
            IEnumerable <ProductInCart> products_add = ProductForCart.ToProductInCart(products);

            useCase_addProductToCart_testLogic.Success_Normal_CheckCartItems(products_add, products_add);
            return(useCase_addProductToCart_testLogic);
        }
        private IEnumerable <ProductInCart> CalculateExpected()
        {
            IDictionary <ProductId, ProductForCart> expected = ProductForCart.ToDictionary(ProductsForCart);

            foreach (ProductIdentifiable productRemoved in ProductsRemove)
            {
                _ = expected.Remove(productRemoved.ProductId);
            }
            return(ProductForCart.ToProductInCart(expected.Values));
        }
示例#4
0
        public void Failure_ProductDoesntExist()
        {
            ProductForCart product = ProductsAdd.First();

            Assert.IsFalse(MarketBridge.AddProductToUserCart(new ProductInCart(new ProductId(Guid.NewGuid()), product.CartQuantity)));
            new Assert_SetEquals <ProductId, ProductInCart>
            (
                Enumerable.Empty <ProductInCart>(),
                x => x.ProductId
            ).AssertEquals(MarketBridge.GetShoppingCartItems());
        }
示例#5
0
        public void Failure_ProductAlreadyInCart()
        {
            Success_NoBasket();
            ProductForCart product = ProductsAdd.First();

            Assert.IsFalse(MarketBridge.AddProductToUserCart(new ProductInCart(product.ProductIdentifiable.ProductId, product.CartQuantity + 1)));
            new Assert_SetEquals <ProductId, ProductInCart>
            (
                new ProductInCart[] { new ProductInCart(product.ProductIdentifiable.ProductId, product.CartQuantity) },
                x => x.ProductId
            ).AssertEquals(MarketBridge.GetShoppingCartItems());
        }
        public IEnumerable <ProductInCart> Success_Normal_NoCheckCartItems()
        {
            IDictionary <ProductId, ProductInCart> expected = ProductForCart.ToDictionary_InCart(useCase_addProductToCart.ProductsAdd);

            foreach (ProductCartEditInfo productEdit in ProductsEdit)
            {
                ProductId productId       = productEdit.ProductOriginal.ProductId;
                var       productEditBare = new ProductInCart(productId, productEdit.NewQuantity);
                Assert.IsTrue(MarketBridge.EditProductInUserCart(productEditBare));
                expected[productId] = productEditBare;
            }
            return(expected.Values);
        }
示例#7
0
        public void Success_BasketExists()
        {
            Success_NoBasket();
            IEnumerable <ProductInCart> productsBefore = ProductForCart.ToProductInCart(ProductsAdd);
            IEnumerable <ProductInCart> productsAdd    = new ProductInCart[]
            {
                new ProductInCart(ShopImage.ShopProducts[1].ProductId, 14)
            };
            IEnumerable <ProductInCart> products = productsBefore.Concat(productsAdd);

            testLogic.Success_Normal_CheckCartItems(productsAdd, products);
            testLogic.Products?.AddRange(productsAdd);
        }
示例#8
0
        public void Success_NoBasket()
        {
            IEnumerable <ProductInCart> products = ProductForCart.ToProductInCart(ProductsAdd);

            testLogic.Success_Normal_CheckCartItems(products, products);
        }