public async Task TestAddStudent() { DbContextOptions <ApplicationDbContext> options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "TestAddStudentsDb").Options; using var dbContext = new ApplicationDbContext(options); dbContext.Database.EnsureDeleted(); using var repository = new EfDeletableEntityRepository <Student>(dbContext); var service = new UsersService(null, repository, null); dbContext.Students.Add(new Student() { Id = 1, ApplicationUserId = "one" }); dbContext.Students.Add(new Student() { Id = 2, ApplicationUserId = "two" }); dbContext.Students.Add(new Student() { Id = 3, ApplicationUserId = "three" }); await dbContext.SaveChangesAsync(); await service.AddStudent(new ApplicationUser() { Id = "newUser" }); Assert.Equal(4, dbContext.Students.Count()); }