[Fact] // 7. public async Task<IEnumerable<PropertyListServiceModel>> FindAsync(string searchText) public async void FindAsync_WithGivenSearchStringForCity_ShouldReturnListModel() { // Arrange var country = CountryCreator.Create(); var city = CityCreator.Create(country.Id); var city2 = CityCreator.Create(country.Id); var home1 = HomeCreator.CreateAny(city2.Id); home1.City = city2; var home2 = HomeCreator.CreateAny(city.Id); var home3 = HomeCreator.CreateAny(city.Id); var home4 = HomeCreator.CreateAny(city.Id); var home5 = HomeCreator.CreateAny(city.Id); await this.Context.Countries.AddAsync(country); await this.Context.Cities.AddRangeAsync(city, city2); await this.Context.Homes.AddRangeAsync(home1, home2, home3, home4, home5); await this.Context.SaveChangesAsync(); string search = city2.Name; var service = new ListingService(this.Context); // Act var result = (await service.FindAsync(search)).ToList(); var expectedCount = this.Context.Homes .Where(h => h.City.Name == search) .Count(); // Assert result.Should().AllBeOfType <PropertyListServiceModel>(); result.Should().HaveCount(expectedCount); result.Should().HaveCount(1, "Because there is 1 home from the searched city"); }