예제 #1
0
        public void SubmitAssignmentCorrectlyTest()
        {
            OsbleServiceClient osbleService = new OsbleServiceClient();
            string password = "******"; //We have only one password for all test accounts
            string authToken = CommonTestLibrary.OsbleLogin("*****@*****.**", password); //Use our OsbleLogin() function from our common test library to retrieve auth tokens
            int assignmentID = 0;
            Course[] courses = osbleService.GetCourses(authToken);
            Assignment[] assignments = osbleService.GetCourseAssignments(courses[0].ID, authToken);

            //Get the file in a zip object
            ZipFile file = new ZipFile();
            FileStream stream = File.OpenRead(startDirectory + "\\Test Assignments\\deliverable_zip.zip");
            file.AddEntry("hw1.zip", stream);
            MemoryStream zippedFile = new MemoryStream();
            file.Save(zippedFile);

            //For each assignment in assignments...
            foreach (Assignment assignment in assignments)
            {
                //We are looking for A3...
                if (assignment.AssignmentName == "A3 due Dec 25 by 11:55 PM")
                {
                    assignmentID = assignment.ID;
                }
            }

            bool result = osbleService.SubmitAssignment(assignmentID, zippedFile.ToArray(), authToken);
            Assert.AreEqual(true, result);
            Console.WriteLine("SubmitAssignmentCorrectlyTest() Assert(s) was successful.");
        }
예제 #2
0
        public void SubmitAssignmentLateTest()
        {
            OsbleServiceClient osbleService = new OsbleServiceClient();
            string password = "******"; //We have only one password for all test accounts
            string authToken = CommonTestLibrary.OsbleLogin("*****@*****.**", password); //Use our OsbleLogin() function from our common test library to retrieve auth tokens
            int assignmentID = 0;
            Course[] courses = osbleService.GetCourses(authToken);
            Assignment[] assignments = osbleService.GetCourseAssignments(courses[0].ID, authToken);

            //Get the file in a zip object
            Console.WriteLine("Zipping file...\n");
            ZipFile file = new ZipFile();
            FileStream stream = File.OpenRead(startDirectory + "\\Test Assignments\\deliverable_txt.txt");
            file.AddEntry("hw1.zip", stream);
            MemoryStream zippedFile = new MemoryStream();
            file.Save(zippedFile);
            Console.WriteLine("File zipped.\n");

            //For each assignment in assignments...
            foreach (Assignment assignment in assignments)
            {
                //Find a passed due assignment
                if (assignment.AssignmentName == "A1 due Nov 4 by 6 PM")
                {
                    assignmentID = assignment.ID;
                }
            }

            Console.WriteLine("Attempting to submit assignment now...\n");

            bool result = osbleService.SubmitAssignment(assignmentID, zippedFile.ToArray(), authToken);
            // SubmitAssignment should return false
            Assert.AreEqual(false, result, "OSBLE accepted assignment late when it should not.");
            Console.WriteLine("SubmitAssignmentLateTest() Assert(s) successful. Assignment was not submitted.");
        }
예제 #3
0
        public void VerifyAssignmentContentsTest()
        {
            OsbleServiceClient osbleService = new OsbleServiceClient();
            string password = "******"; //We have only one password for all test accounts
            string authToken = CommonTestLibrary.OsbleLogin("*****@*****.**", password); //Use our OsbleLogin() function from our common test library to retrieve auth tokens
            int assignmentID = 0;
            Course[] courses = osbleService.GetCourses(authToken);
            Assignment[] assignments = osbleService.GetCourseAssignments(courses[0].ID, authToken);

            //Get the file in a zip object
            ZipFile file = new ZipFile();
            FileStream stream = File.OpenRead(startDirectory + "\\Test Assignments\\deliverable_zip.zip");
            file.AddEntry("hw1.zip", stream);
            MemoryStream zippedFile = new MemoryStream();
            file.Save(zippedFile);

            //For each assignment in assignments...
            foreach (Assignment assignment in assignments)
            {
                //We are looking for A3...
                if (assignment.AssignmentName == "A3 due Dec 25 by 11:55 PM")
                {
                    assignmentID = assignment.ID;
                }
            }

            // Retrieve the assignment

            byte[] expected = zippedFile.ToArray();
            byte[] results = osbleService.GetAssignmentSubmission(assignmentID, authToken);

            Console.WriteLine("Expected Length: " + expected.Length + "\nActual Length: " + results.Length);

            Assert.AreEqual(expected.Length, results.Length);
            for (int i = 70; i < expected.Length - 100; i++)
            {
                Assert.AreEqual(expected[i], results[i]);
            }
            Console.WriteLine("VerifyAssignmentContentsTest() Assert(s) was successful.");
        }
예제 #4
0
        public void SubmitAssignmentWrongClassTest()
        {
            OsbleServiceClient osbleService = new OsbleServiceClient();
            string password = "******"; //We have only one password for all test accounts
            // Student that is in class 422
            string authToken = CommonTestLibrary.OsbleLogin("*****@*****.**", password);

            // Student that is not in class 422
            string authToken2 = CommonTestLibrary.OsbleLogin("*****@*****.**", password);

            int assignmentID = 0;

            // get the assignments for course 422
            Course[] courses = osbleService.GetCourses(authToken);
            Assignment[] assignments = osbleService.GetCourseAssignments(courses[0].ID, authToken);

            Console.WriteLine("Zipping file...\n");
            ZipFile file = new ZipFile();
            FileStream stream = File.OpenRead(startDirectory + "\\Test Assignments\\deliverable_txt.txt");
            file.AddEntry("hw1.zip", stream);
            MemoryStream zippedFile = new MemoryStream();
            file.Save(zippedFile);
            Console.WriteLine("File zipped.\n");

            //For each assignment in assignments...
            foreach (Assignment assignment in assignments)
            {
                //Find a passed due assignment
                if (assignment.AssignmentName == "A2 due Nov 6 by 2 PM")
                {
                    assignmentID = assignment.ID;
                }
            }

            Console.WriteLine("Attempting to submit assignment now...\n");

            // the student that was not in 422 is submitting to the assignment ID for an assignment in class 422
            bool result = osbleService.SubmitAssignment(assignmentID, zippedFile.ToArray(), authToken2);
            // SubmitAssignment should return false
            Assert.AreEqual(false, result, "OSBLE accepted assignment to wrong class when it should not.");
            Console.WriteLine("SubmitAssignmentWrongClassTest() Assert(s) was successful. Assignment was not submitted.");
        }
예제 #5
0
        public void SubmitAssignmentOverSizeLimitTest()
        {
            OsbleServiceClient osbleService = new OsbleServiceClient();
            string authToken = CommonTestLibrary.OsbleLogin("*****@*****.**", password); //Use our OsbleLogin() function from our common test library to retrieve auth tokens
            int assignmentID = 0;
            Course[] courses = osbleService.GetCourses(authToken);
            Assignment[] assignments = osbleService.GetCourseAssignments(courses[0].ID, authToken);

            //Get the file in a zip object
            Console.WriteLine("Zipping file...\n");
            ZipFile file = new ZipFile();
            FileStream stream = File.OpenRead(startDirectory + "\\Test Assignments\\deliverable_zip_large.zip");
            file.AddEntry("hw1.zip", stream);
            MemoryStream zippedFile = new MemoryStream();
            file.Save(zippedFile);
            Console.WriteLine("File zipped.\n");

            //For each assignment in assignments...
            foreach (Assignment assignment in assignments)
            {
                //We are looking for A3...
                if (assignment.AssignmentName == "A3 due Dec 25 by 11:55 PM")
                {
                    assignmentID = assignment.ID;
                    Console.WriteLine("Successfully found assignment.\n");
                }
            }

            Console.WriteLine("Attempting to submit assignment now...\n");

            bool result = osbleService.SubmitAssignment(assignmentID, zippedFile.ToArray(), authToken);
            Assert.AreEqual(false, result, "OSBLE accepted oversize assignment when it should not.");
            Console.WriteLine("SubmitAssignmentOverSizeLimitTest() Assert(s) successful. Assignment was not submitted.");
        }
예제 #6
0
        public void SubmitGradebookAsStudent()
        {
            OsbleServiceClient osbleService = new OsbleServiceClient();
            int assignmentID = 0;
            string authToken = CommonTestLibrary.OsbleLogin("*****@*****.**", password); //Use our OsbleLogin() function from our common test library to retrieve auth tokens
            Course[] courses = osbleService.GetCourses(authToken);
            Assignment[] assignments = osbleService.GetCourseAssignments(courses[0].ID, authToken);

            //Get the file in a zip object
            Console.WriteLine("Zipping file...\n");
            ZipFile file = new ZipFile();
            FileStream stream = File.OpenRead(startDirectory + "\\Test Assignments\\review.xlsx");
            file.AddEntry("review.zip", stream);
            MemoryStream zippedFile = new MemoryStream();
            file.Save(zippedFile);
            Console.WriteLine("File zipped.\n");

            //For each assignment in assignments...
            foreach (Assignment assignment in assignments)
            {
                //We are looking for A3...
                if (assignment.AssignmentName == "A3 due Dec 25 by 11:55 PM")
                {
                    assignmentID = assignment.ID;
                    Console.WriteLine("Successfully found assignment.\n");
                }
            }

            int result = osbleService.UploadCourseGradebook(courses[0].ID, zippedFile.ToArray(), authToken);
            Assert.AreEqual(-1, result);
            Console.WriteLine("SubmitGradebookAsStudent() Assert(s) was successful.");
        }