public async Task ByIdAsyncShouldReturnAnimalById() { var db = DbInfrastructure.GetDatabase(); const string Name = "Animal Name"; await db.AddAsync(new Animal { Name = Name }); for (var i = 0; i < 50; i++) { await db.AddAsync(new Animal { Name = $"Name {i}" }); } await db.SaveChangesAsync(); var animalService = new AnimalService(db); const int Id = 1; var animal = await animalService.ByIdAsync(Id); animal.Should().NotBeNull(); animal.Name.Should().Be(Name); }
public async Task ByIdAsyncShouldReturnNullIfAnimalIsNotFound() { var db = DbInfrastructure.GetDatabase(); var animalService = new AnimalService(db); var animal = await animalService.ByIdAsync(50); animal.Should().BeNull(); }