public void GetEducation_Pass() { using (ApplicationDbContext context = new ApplicationDbContext(Options)) { EducationService educationService = new EducationService(context); UserService userService = new UserService(context); User user = new User { FirstName = "Kyle", LastName = "Burgi" }; userService.AddUser(user); Education edu = new Education { CollegeName = "Eastern Washington University", FieldOfStudy = "Computer Science", UserId = user.Id }; educationService.AddEducation(edu); } using (ApplicationDbContext context = new ApplicationDbContext(Options)) { EducationService educationService = new EducationService(context); Education fetchedEducation = educationService.GetEducation(1); Assert.AreEqual("Eastern Washington University", fetchedEducation.CollegeName); Assert.AreEqual(1, fetchedEducation.UserId); } }
public void UpdateEducation_Pass() { using (ApplicationDbContext context = new ApplicationDbContext(Options)) { EducationService educationService = new EducationService(context); UserService userService = new UserService(context); User user = new User { FirstName = "Kyle", LastName = "Burgi" }; userService.AddUser(user); Education edu = new Education { CollegeName = "Eastern Washington University", FieldOfStudy = "Computer Science", UserId = user.Id }; educationService.AddEducation(edu); } using (ApplicationDbContext context = new ApplicationDbContext(Options)) { EducationService educationService = new EducationService(context); UserService userService = new UserService(context); List <User> users = userService.GetBatchUsers(); List <Education> userEdcuation = educationService.GetEducationForUser(users[0].Id); Assert.IsTrue(userEdcuation.Count > 0); userEdcuation[0].CollegeName = "Gonzaga University"; educationService.UpdateEducation(userEdcuation[0]); } using (ApplicationDbContext context = new ApplicationDbContext(Options)) { EducationService educationService = new EducationService(context); UserService userService = new UserService(context); List <User> users = userService.GetBatchUsers(); List <Education> userEdcuation = educationService.GetEducationForUser(users[0].Id); Assert.AreEqual("Gonzaga University", userEdcuation[0].CollegeName); Assert.AreEqual("Computer Science", users[0].EducationHistory[0].FieldOfStudy); } }