コード例 #1
0
        public async Task TestConfirmationPostWhenUcdAccountVerified()
        {
            // Arrange
            OrderData[1].CreatorId   = "Creator1";
            OrderData[1].Status      = OrderStatusCodes.Created;
            OrderData[1].PaymentType = PaymentTypeCodes.UcDavisAccount;
            Controller.ErrorMessage  = null;


            var orderDetails = CreateValidEntities.OrderDetails(2);

            orderDetails.Payment.Account     = "3-1234567";
            orderDetails.Payment.AccountName = "WHAT!";
            orderDetails.ClientInfo.ClientId = null;
            OrderData[1].SaveDetails(orderDetails);

            MockFinancialService.Setup(a => a.GetAccountName(It.IsAny <string>())).ReturnsAsync("My Fake Account");

            // Act
            var controllerResult = await Controller.Confirmation(2, true);

            // Assert
            Controller.ErrorMessage.ShouldBeNull();
            OrderData[1].GetOrderDetails().Payment.AccountName.ShouldBe("My Fake Account");
            MockDbContext.Verify(a => a.SaveChangesAsync(new CancellationToken()), Times.Once);
            MockFinancialService.Verify(a => a.GetAccountName("3-1234567"), Times.Once);
            MockOrderService.Verify(a => a.UpdateAdditionalInfo(OrderData[1]), Times.Once);
            MockOrderService.Verify(a => a.UpdateTestsAndPrices(OrderData[1]), Times.Once);

            var redirectResult = Assert.IsType <RedirectToActionResult>(controllerResult);

            redirectResult.ActionName.ShouldBe("Confirmed");
            redirectResult.RouteValues["id"].ShouldBe(2);
            redirectResult.ControllerName.ShouldBeNull();
        }
コード例 #2
0
        public async Task TestConfirmationPostWhenPaymentOther2()
        {
            // Arrange
            OrderData[1].CreatorId   = "Creator1";
            OrderData[1].Status      = OrderStatusCodes.Created;
            OrderData[1].PaymentType = PaymentTypeCodes.Other;
            Controller.ErrorMessage  = null;


            var orderDetails = CreateValidEntities.OrderDetails(2);

            orderDetails.OtherPaymentInfo.PaymentType = "SomethingElse";
            orderDetails.ClientInfo.ClientId          = null;
            OrderData[1].SaveDetails(orderDetails);

            // Act
            var controllerResult = await Controller.Confirmation(2, true);

            // Assert
            Controller.ErrorMessage.ShouldBeNull();
            OrderData[1].GetOrderDetails().Payment.AccountName.ShouldBeNull();
            MockDbContext.Verify(a => a.SaveChangesAsync(new CancellationToken()), Times.Once);
            MockFinancialService.Verify(a => a.GetAccountName(It.IsAny <string>()), Times.Never);
            MockOrderMessagingService.Verify(a => a.EnqueueBillingMessage(OrderData[1], It.IsAny <string>()), Times.Never);
            MockOrderService.Verify(a => a.UpdateTestsAndPrices(OrderData[1]), Times.Once);
            MockOrderService.Verify(a => a.UpdateAdditionalInfo(OrderData[1]), Times.Once);
            MockLabworksService.Verify(a => a.GetClientDetails(It.IsAny <string>()), Times.Never);
            MockOrderMessagingService.Verify(a => a.EnqueueCreatedMessage(OrderData[1]), Times.Once);

            var redirectResult = Assert.IsType <RedirectToActionResult>(controllerResult);

            redirectResult.ActionName.ShouldBe("Confirmed");
            redirectResult.RouteValues["id"].ShouldBe(2);
            redirectResult.ControllerName.ShouldBeNull();
        }
コード例 #3
0
        public async Task TestConfirmationPostWhenUcdAccountNotVerified2()
        {
            // Arrange
            OrderData[1].CreatorId   = "Creator1";
            OrderData[1].Status      = OrderStatusCodes.Created;
            OrderData[1].PaymentType = PaymentTypeCodes.UcDavisAccount;
            Controller.ErrorMessage  = null;


            var orderDetails = CreateValidEntities.OrderDetails(2);

            orderDetails.Payment.Account     = "3-1234567";
            orderDetails.Payment.AccountName = "WHAT!";
            OrderData[1].SaveDetails(orderDetails);

            MockFinancialService.Setup(a => a.GetAccountName(It.IsAny <string>())).ReturnsAsync(string.Empty);

            // Act
            var controllerResult = await Controller.Confirmation(2, true);

            // Assert
            Controller.ErrorMessage.ShouldBe("Unable to verify UC Account number. Please edit your order and re-enter the UC account number. Then try again.");
            OrderData[1].GetOrderDetails().Payment.AccountName.ShouldBeEmpty();
            MockDbContext.Verify(a => a.SaveChangesAsync(new CancellationToken()), Times.Once);
            MockFinancialService.Verify(a => a.GetAccountName("3-1234567"), Times.Once);

            var redirectResult = Assert.IsType <RedirectToActionResult>(controllerResult);

            redirectResult.ActionName.ShouldBe("Confirmation");
            redirectResult.RouteValues["id"].ShouldBe(2);
            redirectResult.ControllerName.ShouldBeNull();
        }