Example #1
0
        public void CreateAccountGeneratesUniqueIds()
        {
            const int    userId         = 1;
            const string bankId         = "TestBank";
            const string accountNumber1 = "12346578";
            const string accountNumber2 = "12346579";

            var repository = new InMemoryBankAccountRepository();

            var createdAccount1 = repository.CreateAccount(userId, bankId, accountNumber1);
            var createdAccount2 = repository.CreateAccount(userId, bankId, accountNumber2);

            Assert.That(createdAccount1.Id, Is.Not.EqualTo(createdAccount2.Id));
        }
Example #2
0
        public void GetAccountByBankIdAndAccountNumberCanLocateAccount()
        {
            const int    userId        = 1;
            const string bankId        = "TestBank";
            const string accountNumber = "12346578";

            var repository = new InMemoryBankAccountRepository();

            var createdAccount = repository.CreateAccount(userId, bankId, accountNumber);
            var locatedAccount = repository.GetAccountByBankIdAndAccountNumber(bankId, accountNumber);

            Assert.That(createdAccount, Is.EqualTo(locatedAccount));
        }
Example #3
0
        public void GetAllAccountsByUserIdReturnsAllCreatedAccounts()
        {
            const int    userId1        = 1;
            const int    userId2        = 2;
            const string bankId         = "TestBank";
            const string accountNumber1 = "12346578";
            const string accountNumber2 = "12346579";
            const string accountNumber3 = "12346570";

            var repository = new InMemoryBankAccountRepository();

            var createdAccount1 = repository.CreateAccount(userId1, bankId, accountNumber1);
            var createdAccount2 = repository.CreateAccount(userId1, bankId, accountNumber2);
            var createdAccount3 = repository.CreateAccount(userId2, bankId, accountNumber3);

            var allAccounts = repository.GetAllAccountsByUserId(userId1).ToList();

            Assert.That(allAccounts.Count, Is.EqualTo(2));
            Assert.That(allAccounts, Contains.Item(createdAccount1));
            Assert.That(allAccounts, Contains.Item(createdAccount2));
            Assert.That(allAccounts, Does.Not.Contain(createdAccount3));
        }
Example #4
0
        public void CreateAccountRejectsDuplicateAccountDetails()
        {
            const int    userId         = 1;
            const string bankId1        = "TestBank1";
            const string bankId2        = "TestBank2";
            const string accountNumber1 = "12346578";
            const string accountNumber2 = "12346579";

            var repository = new InMemoryBankAccountRepository();

            repository.CreateAccount(userId, bankId1, accountNumber1);

            Assert.DoesNotThrow(
                () => repository.CreateAccount(userId, bankId1, accountNumber2)
                );

            Assert.DoesNotThrow(
                () => repository.CreateAccount(userId, bankId2, accountNumber1)
                );

            Assert.Throws <InvalidOperationException>(
                () => repository.CreateAccount(userId, bankId1, accountNumber1)
                );
        }
Example #5
0
        public void CreateAccountCanAddAccount()
        {
            const int    userId        = 1;
            const string bankId        = "TestBank";
            const string accountNumber = "12346578";

            var repository = new InMemoryBankAccountRepository();

            var createdAccount = repository.CreateAccount(userId, bankId, accountNumber);

            Assert.That(createdAccount, Is.Not.Null);
            Assert.That(createdAccount.Id, Is.GreaterThan(0));
            Assert.That(createdAccount.UserId, Is.EqualTo(userId));
            Assert.That(createdAccount.BankId, Is.EqualTo(bankId));
            Assert.That(createdAccount.AccountNumber, Is.EqualTo(accountNumber));
        }