public async Task GetAllIncidentsAsyncShouldReturnAllIncidents() { optionsBuilder.UseInMemoryDatabase("GetAllIncidentsAsyncShouldReturnAllIncidents"); using (var context = new DatabaseContext(optionsBuilder.Options)) { context.AddRange ( new Incident { Description = "Regular 'dividing by zero' incident, nothing special", Status = "Opened" }, new Incident { Description = "Pug-dog rebellion", Status = "Pending" }, new Incident { Description = "Grass is green", Status = "Declined" } ); context.SaveChanges(); IIncidentService testIncidentService = new IncidentService(context); var incidents = await testIncidentService.GetAllIncidentsAsync(); incidents.ToList(); Assert.AreEqual(3, incidents.Count()); } }
public async Task GetAllIncidentsAsyncShouldReturnEmptyIEnumerableIfThereNoIncidents() { optionsBuilder.UseInMemoryDatabase("GetAllIncidentsAsyncShouldReturnEmptyIEnumerableIfThereNoIncidents"); using (var context = new DatabaseContext(optionsBuilder.Options)) { IIncidentService testIncidentService = new IncidentService(context); var incidents = await testIncidentService.GetAllIncidentsAsync(); Assert.IsFalse(incidents.Any()); } }