Beispiel #1
0
        public void SelectById_WhenPassedId_ShouldReturnAccount()
        {
            //arrange
            SqlAccountRepository accountRepository = new SqlAccountRepository(connectionString);

            //act
            Account account = accountRepository.SelectById("acc1");

            //assert
            Assert.Equal("John Smith", account.Name);
        }
Beispiel #2
0
        public void Update_Account_ShouldUpdateAccount()
        {
            //arrange
            SqlAccountRepository accountRepository = new SqlAccountRepository(connectionString);
            Account account = new Account("acc1", "Jim Smith");
            //act
            bool updated = accountRepository.Update(account);

            //assert
            Assert.True(updated);
            Assert.Equal("Jim Smith", accountRepository.SelectById("acc1").Name);
        }
Beispiel #3
0
        public void Delete_WhenPassedId_ShouldRemoveAccount()
        {
            //arrange
            SqlAccountRepository accountRepository = new SqlAccountRepository(connectionString);

            //act
            bool deleted = accountRepository.Delete("acc1");

            //assert
            Assert.True(deleted);
            Assert.Null(accountRepository.SelectById("acc1"));
        }
Beispiel #4
0
        public void Create_DuplicateAccount_ShouldReturnFalse()
        {
            //arrange
            SqlAccountRepository accountRepository = new SqlAccountRepository(connectionString);
            Account account = new Account("acc2", "Jane Jones");
            //act
            bool firstAccountCreated  = accountRepository.Create(account);
            bool secondAccountCreated = accountRepository.Create(account);

            //assert
            Assert.True(firstAccountCreated);
            Assert.False(secondAccountCreated);
        }