public async Task AssignUserToSchoolShouldAddTheUserToTheSchool() { var dbOptions = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("test"); var context = new ApplicationDbContext(dbOptions.Options); var schoolService = new SchoolService(context, null); var school = new School(); var user = new ApplicationUser(); await context.Schools.AddAsync(school); await context.Users.AddAsync(user); await context.SaveChangesAsync(); await schoolService.AssignUserToSchool(user, school.Id); var updatedUser = context.Users .FirstOrDefault(x => x.Id == user.Id); Assert.False(string.IsNullOrWhiteSpace(updatedUser.SchoolId)); }