Exemple #1
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 #2
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 #3
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),
            });
        }
Exemple #4
0
        public async Task Failure_ProductsUnavailable()
        {
            // Another user buys enough units so the primary user don't enough left
            await Success_Normal(CompetitorUser, useCase_AddProductToCart_TestLogic_competitor.Products !);

            // log in again to the primary user and re-setup the mocks
            _ = Prepare(BuyerUser2, buyerUser =>
            {
                SetupMock_Delivery_NeverCalled("Delivery have been called despite the products unavailablity in the shop.");
                SetupMock_Payment_NeverCalled("Payment have been called despite the products unavailablity in the shop.");
            });

            Assert.IsFalse(await MarketBridge.PurchaseShoppingCart(BuyerUser2));
            AssertHistory_Empty();
        }
Exemple #5
0
        public async Task Failure_DeliveryFailed()
        {
            _ = Prepare(BuyerUser, buyerUser =>
            {
                SetupMock_Delivery_Fails(buyerUser);
                SetupMock_Payment_Success(buyerUser);

                // make sure cancel payment is called
                TicketId_Payment_Cancel = GenerateTicket();
                _ = Mock_Payment
                    .Setup(ps => ps.CancelPayment(It.Is <string>(x => x.Equals(TicketId_Payment))))
                    .Returns(Task.FromResult(TicketId_Payment_Cancel));
            });

            Assert.IsFalse(await MarketBridge.PurchaseShoppingCart(BuyerUser));
            AssertHistory_Empty();
        }