public void InMemoryAccountRepository_AddAccountAsync_AccountAlreadyAdded() { var accounts = new List <Account>() { new Account(), new Account() }; Account account = new Account(); var expectedResult1 = true; var expectedResult2 = false; var expectedCount = accounts.Count + 1; var expectedLastAccount = account; var repository = new InMemoryAccountRepository(accounts); var actual1 = repository.AddAsync(account).GetAwaiter().GetResult(); var actual2 = repository.AddAsync(account).GetAwaiter().GetResult(); var actualCount = accounts.Count; var actualLastAccount = accounts.Last(); Assert.AreEqual(expectedResult1, actual1); Assert.AreEqual(expectedResult2, actual2); Assert.AreEqual(expectedCount, actualCount); Assert.AreSame(expectedLastAccount, actualLastAccount); }
public void InMemoryAccountRepository_AddAccountAsync_Valid() { var accounts = new List <Account>() { new Account(), new Account() }; Account account = new Account(); var expectedResult = true; var expectedCount = accounts.Count + 1; var expectedLastAccount = account; var repository = new InMemoryAccountRepository(accounts); var actual = repository.AddAsync(account).GetAwaiter().GetResult(); var actualCount = accounts.Count; var actualLastAccount = accounts.Last(); Assert.AreEqual(expectedResult, actual); Assert.AreEqual(expectedCount, actualCount); Assert.AreSame(expectedLastAccount, actualLastAccount); }