public void ReserveSeat()
        {
            var testClass         = GetTestClass();
            var testStudent       = GetTestStudents();
            var seatController    = new SeatController(_seatLogger);
            var studentController = new StudentController(_studentLogger);
            var classController   = new ClassController(_classLogger);

            DatabaseConnector.Connector.RemoveClass(testClass[0].className);

            // add student
            studentController.RemoveStudent(testStudent);
            var request2 = studentController.AddStudent(testStudent);

            Assert.True(request2[0].response);

            // add class
            var request = classController.MakeClassAPI(testClass);

            Assert.True(request[0].response);

            // reserve a seat
            request = seatController.ReserveSeatAPI(testClass);
            Assert.True(request[0].response);

            // attempt to reserve same seat
            request = seatController.ReserveSeatAPI(testClass);
            Assert.False(request[0].response);

            // cleanup
            studentController.RemoveStudent(testStudent);
            request = classController.RemoveClassAPI(testClass);
        }
        public void GetClassCode()
        {
            var testClass       = GetTestClasses();
            var controller      = new InviteLinkController(_logger);
            var classController = new ClassController(_classLogger);

            // get invalid class from key
            testClass[0].className = "INVALID_CLASS";
            var request = controller.GetClassCodeAPI(testClass);

            Assert.False(request[0].response);
            testClass[0].className = "TEST1003";

            // get class from invalid key
            testClass[0].classCode = "INVALID_CODE";
            request = controller.GetClassCodeAPI(testClass);
            Assert.False(request[0].response);

            // make class
            classController.RemoveClassAPI(testClass);
            request = classController.MakeClassAPI(testClass);
            Assert.True(request[0].response);

            // generate key for class
            request = controller.GenerateClassCodeAPI(testClass);
            Assert.True(request[0].response);
            var classCode1 = request[0].classCode;

            // get key
            testClass[0].classCode = classCode1;
            request = controller.GetClassCodeAPI(testClass);
            Assert.True(request[0].response);
            Assert.True(classCode1 == request[0].classCode);
            Assert.True(testClass[0].className == request[0].className);

            // delete class
            request = classController.RemoveClassAPI(testClass);
        }
        public void GenerateClassCode()
        {
            var testClass       = GetTestClasses();
            var controller      = new InviteLinkController(_logger);
            var classController = new ClassController(_classLogger);

            classController.RemoveClassAPI(testClass);

            // generate key for nonexistant class
            var request = controller.GenerateClassCodeAPI(testClass);

            Assert.False(request[0].response);

            // make class
            request = classController.MakeClassAPI(testClass);
            Assert.True(request[0].response);

            // generate key for class
            request = controller.GenerateClassCodeAPI(testClass);
            Assert.True(request[0].response);

            // delete class
            request = classController.RemoveClassAPI(testClass);
        }
        public void MakeAndRemoveClass()
        {
            var testClass       = GetTestClass();
            var classController = new ClassController(_classLogger);

            // add class
            DatabaseConnector.Connector.RemoveClass(testClass[0].className);

            var request = classController.MakeClassAPI(testClass);

            Assert.True(request[0].response);

            // attempt to add class again
            request = classController.MakeClassAPI(testClass);
            Assert.False(request[0].response);

            // delete class
            request = classController.RemoveClassAPI(testClass);
            Assert.True(request[0].response);

            // attempt to delete class again
            request = classController.RemoveClassAPI(testClass);
            Assert.False(request[0].response);
        }
        public void ChangeNotificationFrequency()
        {
            var testClass       = GetTestClass();
            var classController = new ClassController(_classLogger);

            classController.MakeClassAPI(testClass);
            var classObject = DatabaseConnector.Connector.GetClass(testClass[0].className);

            Assert.True(classObject.notificationFreq == 3);
            testClass[0].notificationFreq = 5;
            classController.ChangeFreqAPI(testClass);

            classObject = DatabaseConnector.Connector.GetClass(testClass[0].className);
            Assert.True(classObject.notificationFreq == 5);

            classController.RemoveClassAPI(testClass);
        }
Пример #6
0
        public void RemoveClassFromStudent()
        {
            var testClass         = GetTestClass();
            var testStudent       = GetTestStudents();
            var studentController = new StudentController(_studentLogger);
            var classController   = new ClassController(_classLogger);

            // add student
            DatabaseConnector.Connector.RemoveStudent(testStudent[0].email);
            var request = studentController.AddStudent(testStudent);

            Assert.True(request[0].response);

            // make class
            DatabaseConnector.Connector.RemoveClass(testClass[0].className);
            var request2 = classController.MakeClassAPI(testClass);

            Assert.True(request2[0].response);

            //add class
            request = studentController.AddClass(testStudent);
            Assert.True(request[0].response);

            // get student, assert class attached to student
            request = studentController.GetStudentAPI(testStudent);
            Assert.True(request[0].classes.Length == 1);

            // remove class from student
            request = studentController.RemoveClassFromStudent(testStudent);
            Assert.True(request[0].response);

            // get student
            request = studentController.GetStudentAPI(testStudent);
            //Assert.True(request[0].classes.Length == 0);

            // cleanup
            classController.RemoveClassAPI(testClass);
            request = studentController.RemoveStudent(testStudent);
            Assert.True(request[0].response);
        }
        public void DisableSeat()
        {
            var testClass       = GetTestClass();
            var seatController  = new SeatController(_seatLogger);
            var classController = new ClassController(_classLogger);

            // attempt to disable non existent seat
            DatabaseConnector.Connector.RemoveClass(testClass[0].className);

            var request = seatController.DisableSeatAPI(testClass);

            Assert.False(request[0].response);

            // add class
            request = classController.MakeClassAPI(testClass);
            Assert.True(request[0].response);

            // disable a seat
            request = seatController.DisableSeatAPI(testClass);
            Assert.True(request[0].response);

            // cleanup
            request = classController.RemoveClassAPI(testClass);
        }