public void TestAddClassExistingClass()
        {
            var db = AddClasses();

            AdministratorController controller = new AdministratorController();

            controller.UseLMSContext(db);

            var result = 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") as JsonResult;

            dynamic jdata = result.Value;

            var query = from c in db.Classes
                        select c;

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

            Assert.Equal(1, query.Count());
            Assert.Equal("WEB 1250", query.ToArray()[0].Loc);
            Assert.Equal(new TimeSpan(7, 9, 16), query.ToArray()[0].Start);
            Assert.Equal(new TimeSpan(9, 16, 25), query.ToArray()[0].End);
            Assert.Equal("Spring 2019", query.ToArray()[0].Semester);
            Assert.Equal("u0000000", query.ToArray()[0].TaughtBy);
            Assert.Equal(1, (int)query.ToArray()[0].CategoryId);
        }
Beispiel #2
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 CannotCreateClassSameClassesThatViolateTimeRange()
        {
            AdministratorController admin = new AdministratorController();
            Team55LMSContext        db    = ConfigureDatabaseNoData();

            admin.UseLMSContext(db);

            DateTime start       = new DateTime(2020, 8, 24, 10, 45, 0);
            DateTime secondStart = new DateTime(2020, 8, 24, 11, 0, 0);
            DateTime end         = new DateTime(2020, 8, 24, 11, 35, 0);

            admin.CreateClass("CS", 2420, "Spring", 2020, start, end, "WEB L104", "Swaroop Joshi");
            var     createClass = admin.CreateClass("CS", 2420, "Spring", 2020, secondStart, end, "WEB L104", "Swaroop Joshi") as JsonResult;
            dynamic result      = createClass.Value;

            Assert.Equal("{ success = False }", result.ToString());
        }
        public void CannotCreateClassesOfSameOffering()
        {
            AdministratorController admin = new AdministratorController();
            Team55LMSContext        db    = ConfigureDatabaseNoData();

            admin.UseLMSContext(db);

            DateTime start = new DateTime(2020, 8, 24, 14, 00, 00);
            DateTime end   = new DateTime(2020, 8, 24, 15, 20, 00);

            admin.CreateClass("CS", 2420, "Spring", 2020, start, end, "WEB L104", "Swaroop Joshi");
            var     createClass = admin.CreateClass("CS", 2420, "Spring", 2020, start, end, "WEB L104", "Swaroop Joshi") as JsonResult;
            dynamic result      = createClass.Value;

            var classes = from cla in db.Classes
                          select cla;

            Assert.Equal("{ success = False }", result.ToString());
        }
        public void CanCreateOneClass()
        {
            AdministratorController admin = new AdministratorController();
            Team55LMSContext        db    = DatabaseWithOneCourse();

            admin.UseLMSContext(db);

            DateTime start = new DateTime(2020, 8, 24, 10, 45, 0);
            DateTime end   = new DateTime(2020, 8, 24, 11, 35, 0);

            var result = admin.CreateClass("RUSS", 1010, "Fall", 2020, start, end, "LNCO 1104", "Elena Khordova") as JsonResult;

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

            AdministratorController controller = new AdministratorController();

            controller.UseLMSContext(db);

            var result = controller.CreateClass("CS", 1, "Spring", 2019, new DateTime(2009, 05, 30, 7, 25, 49),
                                                new DateTime(2009, 05, 30, 9, 25, 49), "MEB 3232", "u0000000") as JsonResult;

            dynamic jdata = result.Value;

            var query = from c in db.Classes
                        select c;

            //Assert.Equal(true, jdata.ToString().Contains("False"));
            //Assert.Equal(1, query.Count());
        }
Beispiel #7
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);
        }