Exemple #1
0
        public void Failure_NotLoggedIn()
        {
            new UseCase_LogOut_TestLogic(SystemContext).Success_Normal();
            ProductId productId = productsToRemove.First().ProductId;

            Assert.IsFalse(MarketBridge.RemoveProductFromShop(ShopId, productId));
        }
        public void Failure_NotMatchingKeywords()
        {
            ProductSearchResults?results = MarketBridge.SearchProducts(new ProductSearchCreteria("suabjkbeio"));

            Assert.NotNull(results, "Products search - null results");
            Assert.IsEmpty(results, "Products search - not matching keywords - expected no results");
        }
 public void Success_Normal_NoCheckCartItems()
 {
     foreach (ProductIdentifiable product in ProductsRemove)
     {
         Assert.IsTrue(MarketBridge.RemoveProductFromUserCart(product.ProductId));
     }
 }
Exemple #4
0
        public void Failure_ShopDoesntExist()
        {
            ProductId   productId   = ShopImage.ShopProducts[0].ProductId;
            ProductInfo productInfo = ProductEditInfos.First().ProductInfoEdit;

            Assert.IsFalse(MarketBridge.EditProductInShop(new ShopId(Guid.NewGuid(), "notexists"), productId, productInfo));
        }
Exemple #5
0
        public void Failure_InsufficientPermissions()
        {
            LoginToBuyer();
            ProductId productId = productsToRemove.First().ProductId;

            Assert.IsFalse(MarketBridge.RemoveProductFromShop(ShopId, productId));
        }
Exemple #6
0
 private void EditProducts()
 {
     foreach (ProductShopEditInfo productEditInfo in ProductEditInfos)
     {
         Assert.IsTrue(MarketBridge.EditProductInShop(ShopId, productEditInfo.ProductOriginal.ProductId, productEditInfo.ProductInfoEdit));
     }
 }
Exemple #7
0
 private void RemoveProducts()
 {
     foreach (ProductIdentifiable product in productsToRemove)
     {
         Assert.IsTrue(MarketBridge.RemoveProductFromShop(ShopId, product.ProductId));
     }
 }
Exemple #8
0
        public void Failure_InsufficientPermissions()
        {
            LoginToBuyer();
            ProductId   productId   = ShopImage.ShopProducts[0].ProductId;
            ProductInfo productInfo = ProductEditInfos.First().ProductInfoEdit;

            Assert.IsFalse(MarketBridge.EditProductInShop(ShopId, productId, productInfo));
        }
Exemple #9
0
        public void Failure_NotLoggedIn()
        {
            new UseCase_LogOut_TestLogic(SystemContext).Success_Normal();
            ProductId   productId   = ShopImage.ShopProducts[0].ProductId;
            ProductInfo productInfo = ProductEditInfos.First().ProductInfoEdit;

            Assert.IsFalse(MarketBridge.EditProductInShop(ShopId, productId, productInfo));
        }
        // Not a test case for now
        public void Failure_Typo()
        {
            ProductSearchResults?results = MarketBridge.SearchProducts(new ProductSearchCreteria("abg"));

            Assert.NotNull(results, "Products search - null results");
            Assert.IsEmpty(results, "Products search - not matching keywords - expected no results");
            Assert.AreEqual(results !.TypoFixes, "bag", "Product search - typo - expected fix");
        }
Exemple #11
0
        public ShopId Success_Normal(ShopInfo shopInfo)
        {
            ShopId?shop = MarketBridge.AssureOpenShop(shopInfo);

            Assert.IsNotNull(shop);
            // TODO: check the owner and the founder
            return(shop !.Value);
        }
 private void AssertCartDidntChange()
 {
     new Assert_SetEquals <ProductId, ProductInCart>
     (
         ProductForCart.ToProductInCart(useCase_addProductToCart.ProductsAdd),
         x => x.ProductId
     ).AssertEquals(MarketBridge.GetShoppingCartItems());
 }
Exemple #13
0
 public override void Teardown()
 {
     _ = UserBridge.AssureLogin(ShopImage.OwnerUser);
     foreach (ProductId productId in teardownProducts)
     {
         _ = MarketBridge.RemoveProductFromShop(ShopId, productId);
     }
     useCase_openShop.Teardown();
 }
 public void Success_Normal_CheckCartItems(IEnumerable <ProductInCart> productsAdd, IEnumerable <ProductInCart> expected)
 {
     Success_Normal_NoCheckCartItems(productsAdd);
     new Assert_SetEquals <ProductId, ProductInCart>
     (
         expected,
         x => x.ProductId
     ).AssertEquals(MarketBridge.GetShoppingCartItems());
 }
        public void Success_Normal_NoCheckCartItems(IEnumerable <ProductInCart> productsAdd)
        {
            foreach (ProductInCart product in productsAdd)
            {
                Assert.IsTrue(MarketBridge.AddProductToUserCart(product));
            }

            Products?.AddRange(productsAdd);
        }
Exemple #16
0
 public void Failure_NoShoppingBasket()
 {
     Success_Normal_CheckCartItems();
     Assert.IsFalse(MarketBridge.RemoveProductFromUserCart(ShopImage.ShopProducts[1].ProductId));
     new Assert_SetEquals <ProductId, ProductInCart>
     (
         Enumerable.Empty <ProductInCart>(),
         x => x.ProductId
     ).AssertEquals(MarketBridge.GetShoppingCartItems());
 }
        public void Failure_MatchingKeywordsButNotFilter()
        {
            ProductSearchResults?results = MarketBridge.SearchProducts(new ProductSearchCreteria("charger")
            {
                PriceRange_High = 1
            });

            Assert.NotNull(results, "Products search - null results");
            Assert.IsEmpty(results, "Products search - not matching filter - expected no results");
        }
        public void Success_Normal()
        {
            IEnumerable <ProductInCart>?cartItems = MarketBridge.GetShoppingCartItems();

            new Assert_SetEquals <ProductId, ProductInCart>
            (
                ChosenProducts,
                x => x.ProductId
            ).AssertEquals(cartItems);
        }
 public override void Teardown()
 {
     base.Teardown();
     _ = UserBridge.AssureLogin(UserInfo);
     foreach (ProductId productId in ProductsAdditionalTeardown.Select(x => x.ProductId))
     {
         _ = MarketBridge.RemoveProductFromUserCart(productId);
     }
     useCase_addProductToCart.Teardown();
 }
Exemple #20
0
 public override void Teardown()
 {
     useCase_AddProductToCart_TestLogic_competitor?.Teardown();
     useCase_AddProductToCart_TestLogic_2?.Teardown();
     useCase_AddProductToCart_TestLogic_1?.Teardown();
     useCase_addProductToShop?.Teardown();
     useCase_login?.Teardown();
     MarketBridge.DisableExternalTransactionMocks();
     base.Teardown();
 }
 public void Success_AllChanged()
 {
     Assert.IsTrue(MarketBridge.EditUserCart(
                       productsForEdit.ProductsAdd,
                       productsForEdit.ProductsRemove,
                       productsForEdit.ProductsEdit
                       ));
     /// TODO: check cart items changed properly
     /// <see cref="AcceptanceTests.AppInterface.MarketBridge.IMarketBridge.GetShoppingCartItems"/>
 }
Exemple #22
0
        public async Task Failure_EmptyCart()
        {
            useCase_login = Prepare(BuyerUser_Empty, buyerUser =>
            {
                SetupMock_Delivery_NeverCalled("Delivery have been called despite no products in cart.");
                SetupMock_Payment_NeverCalled("Payment have been called despite no products in cart.");
            });

            Assert.IsFalse(await MarketBridge.PurchaseShoppingCart(BuyerUser));
            AssertHistory_Empty();
        }
Exemple #23
0
        public async Task Failure_PaymentFailed()
        {
            _ = Prepare(BuyerUser, buyerUser =>
            {
                SetupMock_Delivery_NeverCalled("Delivery have been called despite payment failure.");
                SetupMock_Payment_Fails(buyerUser);
            });

            Assert.IsFalse(await MarketBridge.PurchaseShoppingCart(BuyerUser));
            AssertHistory_Empty();
        }
Exemple #24
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());
        }
Exemple #25
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 override void Teardown()
 {
     base.Teardown();
     if (productsForEdit != null && productsForEdit.ProductsAdd != null)
     {
         foreach (ProductInCart product in productsForEdit.ProductsAdd)
         {
             MarketBridge.RemoveProductFromUserCart(product.ProductId);
         }
     }
     useCase_viewShoppingCart.Teardown();
 }
        public void Success_Normal(ShopId shopId, IEnumerable <ProductIdentifiable> expected)
        {
            IEnumerable <ProductIdentifiable>?resultProducts = MarketBridge.GetShopProducts(shopId);

            Assert.IsNotNull(resultProducts);
            Assert.IsTrue(resultProducts.All(x => x.ProductId.IsValid()), $"contains invalid product IDs");
            new Assert_SetEquals <ProductIdentifiable>
            (
                expected,
                ProductIdentifiable.DeepEquals
            ).AssertEquals(resultProducts);
        }
        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);
        }
        private void TestSuccess(ProductSearchCreteria searchCreteria, IEnumerable <ProductIdentifiable> expectedResults)
        {
            ProductSearchResults?results = MarketBridge.SearchProducts(searchCreteria);

            Assert.IsNotNull(results);
            Assert.IsNull(results !.TypoFixes, $"expected no typo fixes");
            Assert.IsTrue(results !.IsValid(), $"expect valid results (valid IDs)");
            new Assert_SetEquals <ProductIdentifiable>
            (
                expectedResults,
                ProductIdentifiable.DeepEquals
            ).AssertEquals(results);
        }
Exemple #30
0
        private async Task Success_Normal(BuyerUserInfo buyerUser, IEnumerable <ProductInCart> expectedProductsCartHistory)
        {
            _ = Prepare(buyerUser, buyerUser =>
            {
                SetupMock_Delivery_Success(buyerUser);
                SetupMock_Payment_Success(buyerUser);
            });

            Assert.IsTrue(await MarketBridge.PurchaseShoppingCart(buyerUser));
            AssertHistory(new PurchaseHistoryRecord[]
            {
                new PurchaseHistoryRecord(expectedProductsCartHistory, TicketId_Delivery, true, TicketId_Payment, true),
            });
        }