public void CanCreateMultipleUniqueCourses()
        {
            AdministratorController admin = new AdministratorController();
            Team55LMSContext        db    = ConfigureDatabaseNoData();

            admin.UseLMSContext(db);

            var databases    = admin.CreateCourse("CS", 5530, "Database Systems") as JsonResult;
            var begRussian   = admin.CreateCourse("RUSS", 1010, "Beginner Russian") as JsonResult;
            var interWriting = admin.CreateCourse("WRTG", 2010, "Intermediate Writing") as JsonResult;

            Assert.Equal("{ success = True }", databases.Value.ToString());
            Assert.Equal("{ success = True }", begRussian.Value.ToString());
            Assert.Equal("{ success = True }", interWriting.Value.ToString());
        }
        public void CannotCreateDuplicateCourse()
        {
            AdministratorController admin = new AdministratorController();
            Team55LMSContext        db    = ConfigureDatabaseNoData();

            admin.UseLMSContext(db);

            admin.CreateCourse("ESSF", 1710, "Elem Hip-Hop Dance");
            var duplicateCourse = admin.CreateCourse("ESSF", 1710, "Elem Hip-Hop Dance") as JsonResult;

            var courses = from co in db.Courses
                          select co;

            Assert.Equal("{ success = False }", duplicateCourse.Value.ToString());
            Assert.Equal(1, courses.Count());
        }
Exemplo n.º 3
0
        protected Team63LMSContext AddProfessorCourseClass()
        {
            Team63LMSContext db = mockDB();

            AdministratorController controller = new AdministratorController();

            controller.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.CreateClass("CS", 1, "Spring", 2019, new DateTime(2009, 05, 30, 7, 9, 16),
                                   new DateTime(2009, 05, 30, 9, 16, 25), "WEB 1250", "u0000000");

            return(db);
        }
        public void CanCreateOneCourse()
        {
            AdministratorController admin = new AdministratorController();
            Team55LMSContext        db    = ConfigureDatabaseNoData();

            admin.UseLMSContext(db);

            var result = admin.CreateCourse("CHEM", 1210, "Organic Chemistry I") as JsonResult;

            Assert.Equal("{ success = True }", result.Value.ToString());
        }
        public void TestCreateCourseAddExistingCourse()
        {
            var db = mockDB();

            AdministratorController controller = new AdministratorController();

            controller.UseLMSContext(db);

            var result = controller.CreateCourse("HF", 1550, "Classical Mythology") as JsonResult;

            dynamic jdata = result.Value;

            Assert.Equal(true, jdata.ToString().Contains("True"));

            // Return false if course already exists
            var result2 = controller.CreateCourse("HF", 1550, "Classical Mythology") as JsonResult;

            dynamic jdata2 = result2.Value;

            Assert.Equal(true, jdata2.ToString().Contains("False"));
        }
Exemplo n.º 6
0
        protected Team63LMSContext AddClasses()
        {
            Team63LMSContext db = mockDB();

            AdministratorController controller = new AdministratorController();

            controller.UseLMSContext(db);

            // Create Professor to teach class
            Professors p = new Professors();

            p.FName   = "Danny";
            p.LName   = "Kopta";
            p.UId     = uIDGen(db);
            p.WorksIn = "CS";
            p.Dob     = new DateTime(1992, 10, 23);


            db.Professors.Add(p);
            db.SaveChanges();

            controller.CreateCourse("CS", 5530, "Database Systems");

            var query = from pr in db.Professors
                        select pr.UId;

            var query2 = from cr in db.Courses
                         select cr.CatalogId;

            // Create class associated with a CS course
            Classes c = new Classes();

            c.Loc        = "WEB 1250";
            c.Start      = new TimeSpan(7, 9, 16);
            c.End        = new TimeSpan(9, 16, 25);
            c.Semester   = "Spring 2019";
            c.TaughtBy   = query.SingleOrDefault();
            c.CategoryId = query2.SingleOrDefault();

            db.Classes.Add(c);

            db.SaveChanges();

            return(db);
        }
        public void CanGetOneCourse()
        {
            AdministratorController admin = new AdministratorController();
            Team55LMSContext        db    = ConfigureDatabaseNoData();

            admin.UseLMSContext(db);
            admin.CreateCourse("RUSS", 1010, "Beginner Russian I");

            var     courses = admin.GetCourses("RUSS") as JsonResult;
            dynamic result  = courses.Value;

            var query = from co in db.Courses
                        where co.SubjectAbbr == "RUSS"
                        select co;

            Assert.True(query.ToArray().Length == 1);
            Assert.Equal("{ number = 1010, name = Beginner Russian I }", result[0].ToString());
        }
Exemplo n.º 8
0
        protected Team63LMSContext AddClasses2()
        {
            Team63LMSContext db = mockDB();

            AdministratorController controller = new AdministratorController();

            controller.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");

            return(db);
        }
Exemplo n.º 9
0
        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);
        }