public void CannotEnrollInSameClass() { StudentController student = new StudentController(); Team55LMSContext db = MakeTinyCatalog(); student.UseLMSContext(db); student.Enroll("LING", 1069, "Fall", 2020, "u0000003"); var enrolled = student.Enroll("LING", 1069, "Fall", 2020, "u0000003") as JsonResult; dynamic result = enrolled.Value; Assert.Equal("{ success = False }", result.ToString()); }
public void CanEnrollInClass() { StudentController student = new StudentController(); Team55LMSContext db = MakeTinyCatalog(); student.UseLMSContext(db); var result = student.Enroll("LING", 1069, "Fall", 2020, "u0000003") as JsonResult; Assert.Equal("{ success = True }", result.Value.ToString()); }
protected Team63LMSContext AddStudentstoMultipleClasses() { Team63LMSContext db = mockDB(); AdministratorController controller = new AdministratorController(); controller.UseLMSContext(db); StudentController sController = new StudentController(); sController.UseLMSContext(db); // Create Professor to teach class Professors p = new Professors(); p.FName = "Danny"; p.LName = "Kopta"; p.UId = uIDGen(db); p.WorksIn = "CS"; db.Professors.Add(p); db.SaveChanges(); controller.CreateCourse("CS", 5530, "Database Systems"); controller.CreateCourse("CS", 4400, "Computer Systems"); controller.CreateCourse("CS", 3500, "Software Practice I"); controller.CreateClass("CS", 1, "Spring", 2019, new DateTime(2009, 05, 30, 7, 9, 16), new DateTime(2009, 05, 30, 9, 16, 25), "WEB 1250", "u0000000"); controller.CreateClass("CS", 4400, "Spring", 2019, new DateTime(2009, 05, 30, 7, 9, 16), new DateTime(2009, 05, 30, 9, 16, 25), "WEB 2000", "u0000000"); controller.CreateClass("CS", 3500, "Spring", 2019, new DateTime(2009, 05, 30, 7, 9, 16), new DateTime(2009, 05, 30, 9, 16, 25), "WEB 1999", "u0000000"); //Add student to class Students s = new Students(); s.UId = "u0000001"; s.FName = "Steen"; s.LName = "Sia"; s.Dob = new DateTime(2000, 07, 01); s.Major = "Electrical Engineering"; Students s2 = new Students(); s.UId = "u0000002"; s.FName = "Benjamin"; s.LName = "Button"; s.Dob = new DateTime(2000, 07, 01); s.Major = "Electrical Engineering"; Students s3 = new Students(); s.UId = "u0000003"; s.FName = "J"; s.LName = "Fish"; s.Dob = new DateTime(2000, 07, 01); s.Major = "Computer Science"; db.Students.Add(s); db.Students.Add(s2); db.Students.Add(s3); db.SaveChanges(); sController.Enroll("CS", 5530, "Spring", 2019, "u0000001"); sController.Enroll("CS", 5530, "Spring", 2019, "u0000002"); sController.Enroll("CS", 4400, "Spring", 2019, "u0000001"); sController.Enroll("CS", 4400, "Spring", 2019, "u0000002"); sController.Enroll("CS", 3500, "Spring", 2019, "u0000003"); sController.Enroll("CS", 3500, "Spring", 2019, "u0000001"); return(db); }