public async Task SearchPeopleAsync_GivenNullSearchString_ShouldReturnAllPeople() { // Arrange using (PeopleSearchDbContext testContext = GetTestContext()) { Person added1 = TestData.TestPerson1(); Person added2 = TestData.TestPerson2(); List <Person> expected = new List <Person> { added1, added2 }; testContext.People.Add(added1); testContext.People.Add(added2); await testContext.SaveChangesAsync(); PersonRepository repository = new PersonRepository(testContext); // Act List <Person> actual = (await repository.AllPeopleAsync()).ToList(); // Assert List <Person> actualSorted = actual.OrderBy(p => p.Id).ToList(); ModelComparisonHelper.AssertPersonListsAreEqual(expected, actualSorted); } }
public async Task AllPeopleAsync_GivenNoPeopleExist_ShouldReturnEmptyList() { // Arrange using (PeopleSearchDbContext testContext = GetTestContext()) { PersonRepository repository = new PersonRepository(testContext); List <Person> expected = new List <Person>(); // Act List <Person> actual = (await repository.AllPeopleAsync()).ToList(); // Assert ModelComparisonHelper.AssertPersonListsAreEqual(expected, actual); } }