Ejemplo n.º 1
0
            public void Should_return_transactionresult_on_successfulldeposit()
            {
                // Arrange
                var accountSummary = new AccountSummaryEntity()
                {
                    AccountNumber = 1253667,
                    Balance       = 55000,
                    Currency      = "INR"
                };

                var accountTransaction = new AccountTransaction()
                {
                    AccountNumber   = 1253667,
                    TransactionType = Types.TransactionType.Deposit,
                    Amount          = new Types.Money(1000, Types.Currency.INR)
                };

                AccountTransactionRepositoryMock
                .Setup(i => i.Create(It.IsAny <AccountTransactionEntity>(), It.IsAny <AccountSummaryEntity>()))
                .Returns(Task.CompletedTask);

                AccountSummaryRepositoryMock
                .Setup(i => i.Read(It.IsAny <int>()))
                .ReturnsAsync(accountSummary);

                // Act
                var result = TransactionServiceUnderTest.Deposit(accountTransaction).Result;

                // Assert
                Assert.Equal(accountSummary.Balance, result.Balance.Amount);
            }
Ejemplo n.º 2
0
            public void Should_throw_transactionexception__when_transactiondetails_are_invalid()
            {
                // Arrange
                var accountSummary = new AccountSummaryEntity()
                {
                    AccountNumber = 1253667,
                    Balance       = 55000,
                    Currency      = "INR"
                };

                var accountTransaction = new AccountTransaction()
                {
                    AccountNumber   = 1253667,
                    TransactionType = Types.TransactionType.Withdrawal,
                    Amount          = new Types.Money(65000, Types.Currency.INR)
                };

                AccountTransactionRepositoryMock
                .Setup(i => i.Create(It.IsAny <AccountTransactionEntity>(), It.IsAny <AccountSummaryEntity>()))
                .Returns(Task.CompletedTask);

                AccountSummaryRepositoryMock
                .Setup(i => i.Read(It.IsAny <int>()))
                .ReturnsAsync(accountSummary);

                // Act
                var result = TransactionServiceUnderTest.Withdraw(accountTransaction);

                // Assert
                Assert.ThrowsAsync <InsufficientBalanceException>(async() => await result);
            }