public void GetCourseUsersTest() { // ARRANGE PlannerService service = new PlannerService(ctxDb); int cmId = AddCm(); int courseId = ctxDb.Course.Where(c => c.Vakcode == "MGP01A").FirstOrDefault().Id; ctxDb.Users.Add(new ApplicationUser { UserName = "******", Email = "*****@*****.**", GeboorteDatum = new DateTime(1998, 09, 21), Naam = "Claes", VoorNaam = "Thomas", EmailConfirmed = true }); ctxDb.Users.Add(new ApplicationUser { UserName = "******", Email = "*****@*****.**", GeboorteDatum = new DateTime(1998, 09, 21), Naam = "Claes", VoorNaam = "Thomas", EmailConfirmed = true }); ctxDb.Users.Add(new ApplicationUser { UserName = "******", Email = "*****@*****.**", GeboorteDatum = new DateTime(1998, 09, 21), Naam = "Claes", VoorNaam = "Thomas", EmailConfirmed = true }); ctxDb.SaveChanges(); string user1Id = ctxDb.Users.Where(u => u.UserName == "r0000001").FirstOrDefault().Id; string user2Id = ctxDb.Users.Where(u => u.UserName == "r0000002").FirstOrDefault().Id; string user3Id = ctxDb.Users.Where(u => u.UserName == "r0000003").FirstOrDefault().Id; ctxDb.CourseUser.Add(new CourseUser { CourseId = courseId, ApplicationUserId = user1Id, GoedGekeurd = true, AfwijzingBeschr = null }); ctxDb.CourseUser.Add(new CourseUser { CourseId = courseId, ApplicationUserId = user2Id, GoedGekeurd = true, AfwijzingBeschr = null }); ctxDb.CourseUser.Add(new CourseUser { CourseId = courseId, ApplicationUserId = user3Id, GoedGekeurd = false, AfwijzingBeschr = null }); ctxDb.SaveChanges(); ctxDb.Roles.Add(new IdentityRole { Name = "Student", NormalizedName = "STUDENT" }); ctxDb.SaveChanges(); var roleId = ctxDb.Roles.Where(r => r.Name == "Student").FirstOrDefault().Id; ctxDb.UserRoles.Add(new IdentityUserRole <string> { UserId = user1Id, RoleId = roleId }); ctxDb.UserRoles.Add(new IdentityUserRole <string> { UserId = user2Id, RoleId = roleId }); ctxDb.UserRoles.Add(new IdentityUserRole <string> { UserId = user3Id, RoleId = roleId }); ctxDb.SaveChanges(); ctxDb.CourseMomentUsers.Add(new CourseMomentUsers { ApplicationUserId = user2Id, CoursMomentId = cmId }); ctxDb.SaveChanges(); // ACT var list = service.GetCourseUsers(courseId); // ASSERT Assert.AreEqual(1, list.users.Count()); Assert.AreEqual(user2Id, list.users[0].Id); }