public async Task DeleteAppointmentFromDatabase() { IFixture fixture = new Fixture(); fixture.Behaviors.Add(new OmitOnRecursionBehavior()); var databaseName = fixture.Create <string>(); var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName).Options; var appointment = fixture.Create <Appointment>(); using (var context = new ApplicationDbContext(options)) { var repository = new AppointmentsRepository(context); await repository.CreateAsync(appointment, CancellationToken.None); } using (var context = new ApplicationDbContext(options)) { context.Appointments.Count().Should().Be(1); var repository = new AppointmentsRepository(context); await repository.DeleteAsync(appointment, CancellationToken.None); context.Appointments.Count().Should().Be(0); } }