Esempio n. 1
0
        public void GetPaymentApprovalAndGenerateTransactionMethod_NoInputParams_GeneratesTransaction()
        {
            const int   accountId   = 12351;
            var         sut         = new ProcessTransactionService();
            Transaction transaction = sut.GetPaymentApprovalAndGenerateTransaction(accountId);

            Assert.IsTrue(transaction.GrossAmount > 0);
        }
Esempio n. 2
0
        public void GetPaymentApprovalAndGenerateTransactionMethod_AccountPassedToConstructor_GeneratesApprovalAndTransaction()
        {
            const int accountId = 12351;
            var       sut       = new ProcessTransactionService(new FakeAccountRepository(), new FakeTransactionsRepository(),
                                                                new FakePaymentGateway());
            Transaction transaction = sut.GetPaymentApprovalAndGenerateTransaction(accountId);

            Assert.IsTrue(transaction.GrossAmount > 0);
        }
Esempio n. 3
0
        public void GetPaymentApprovalAndGenerateTransactionMethod_AccountPassedToConstructor_GeneratesApprovalAndTransaction()
        {
            // declare constants
            const decimal totalAmount  = 35.27M;
            const int     accountId    = 12354;
            var           shoppingCart = new ShoppingCart
            {
                Id      = 12531515,
                Total   = totalAmount,
                Account = new Account
                {
                    Id             = accountId,
                    CreditCardInfo = new CreditCardInfo()
                }
            };

            var paymentGatewayResultDto = new PaymentGatewayResultDTO
            {
                ApprovedTotal = totalAmount
            };

            var transaction = new Transaction
            {
                GrossAmount = totalAmount
            };

            // set expectations
            Expect.Call(_accountRepository.GetCurrentShoppingCart(accountId)).Return(shoppingCart);
            Expect.Call(_paymentGateway.ApprovePayment(shoppingCart)).Return(paymentGatewayResultDto);
            _transactionsRepository.Save(transaction);

            _mockRepository.ReplayAll();

            var sut = new ProcessTransactionService(_accountRepository, _transactionsRepository, _paymentGateway);

            sut.GetPaymentApprovalAndGenerateTransaction(accountId);

            _mockRepository.VerifyAll();

            Assert.AreEqual(shoppingCart.Total, paymentGatewayResultDto.ApprovedTotal);
            Assert.AreEqual(paymentGatewayResultDto.ApprovedTotal, transaction.GrossAmount);
        }