public void GivenAccount_WhenUpdate_ThenReturnUpdated() { var uow = new UoW(_chatContext); using (var dbContextTransaction = uow.BeginTransaction()) { try { //ARRANGE string newPassword = "******"; Account account = AccountMother.NewAccount(); _accountRepository.Add(account); uow.SaveChanges(); //ACT var attachedAccount = _accountRepository.Get(account.AccountID); attachedAccount.Password = newPassword; uow.SaveChanges(); //ASSERT var updatedAccount = _accountRepository.Get(account.AccountID); Assert.NotNull(updatedAccount); Assert.Equal(updatedAccount.Password, newPassword); } finally { dbContextTransaction.Rollback(); } } }
public void GivenNewAccount_WhenInsert_ThenReturnNotNull() { var uow = new UoW(_chatContext); using (var dbContextTransaction = uow.BeginTransaction()) { try { //ARRANGE Account account = AccountMother.NewAccount(); _accountRepository.Add(account); //ACT uow.SaveChanges(); //ASSERT var insertedAccount = _accountRepository.Get(account.AccountID); Assert.NotNull(insertedAccount); Assert.Equal(insertedAccount.Password, account.Password); } finally { dbContextTransaction.Rollback(); } } }