public async Task GetByIdShouldReturnWhenCityDoesntExists() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var addressesService = new Mock <IAddressesService>(); var repository = new EfDeletableEntityRepository <City>(dbContext); var service = new CitiesService(repository, addressesService.Object); var city = new City() { Id = 1, }; dbContext.Add(city); await dbContext.SaveChangesAsync(); var cities = await service.GetByIdAsync <CityServiceModel>(3); Assert.Null(cities); }