Exemplo n.º 1
0
        public void Test_TermGPA()
        {
            Course[] courses = new Course[]
            {
                new Course("Course", 1, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 2, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 4, "Test Category", true, 67,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 72,
                           true, "补考", "Lecturer", System.DateTime.Today)
            };

            Term term = new Term(2018, 1);

            foreach (Course c in courses)
            {
                term.AddCourse(c);
            }

            Assert.AreEqual(2.11, term.GPA, 0.01);
        }
Exemplo n.º 2
0
        private void AddCourse()
        {
            Console.WriteLine("Which term would you like to add this course to?");

            String termName = Console.ReadLine();
            Term   tempTerm = GetTerm(termName);

            Console.WriteLine("What's the name of this course?");
            String newCourseName = Console.ReadLine();
            Course newUserCourse = new Course(newCourseName);

            try
            {
                tempTerm.AddCourse(newUserCourse);
            }
            catch (PreExistingCourseException)
            {
                Console.WriteLine("This course already exists in this term! Please try again...");
            }

            Console.WriteLine("The course has been added!");
            DisplayCourseOptions();

            String key = Console.ReadLine();

            key.ToUpper();

            if (key.Equals("J"))
            {
                Process(key);
            }
        }
Exemplo n.º 3
0
        public void Test_ScoreReverse()
        {
            Course[] courses1 = new Course[]
            {
                new Course("Course", 1, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 2, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 4, "Test Category", true, 67,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 72,
                           true, "补考", "Lecturer", System.DateTime.Today)
            };
            // 2.11

            Term term1 = new Term(2018, 1);

            foreach (Course c in courses1)
            {
                term1.AddCourse(c);
            }

            Course[] courses2 = new Course[]
            {
                new Course("Course", 2, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 1, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
            };
            // 3.72

            Term term2 = new Term(2017, 3);

            foreach (Course c in courses2)
            {
                term2.AddCourse(c);
            }

            Score score = new Score("20444444", "DL444", 2044, "SE", "SE01", true);

            score.AddTerm(term1);
            score.AddTerm(term2);

            score.Reverse();
            Assert.AreSame(term1, score.Terms[0]);
            Assert.AreSame(term2, score.Terms[1]);
        }
Exemplo n.º 4
0
        public void Test_Score_GPA_Year()
        {
            Course[] courses1 = new Course[]
            {
                new Course("Course", 1, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 2, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 4, "Test Category", true, 67,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 72,
                           true, "补考", "Lecturer", System.DateTime.Today)
            };
            // 2.11

            Term term1 = new Term(2018, 1);

            foreach (Course c in courses1)
            {
                term1.AddCourse(c);
            }

            Course[] courses2 = new Course[]
            {
                new Course("Course", 2, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 1, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
            };
            // 3.72

            Term term2 = new Term(2018, 3);

            foreach (Course c in courses2)
            {
                term2.AddCourse(c);
            }

            Score score = new Score("20444444", "DL444", 2044, "SE", "SE01", true);

            score.AddTerm(term1);
            score.AddTerm(term2);

            Assert.AreEqual(2.65, score.GetGPA(2018), 0.01);
            term2.BeginningYear = 2017;
            Assert.AreEqual(2.11, score.GetGPA(2018), 0.01);
        }
Exemplo n.º 5
0
        public void Test_Compare()
        {
            Course[] courses1 = new Course[]
            {
                new Course("Course", 1, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 2, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 4, "Test Category", true, 67,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 72,
                           true, "补考", "Lecturer", System.DateTime.Today)
            };
            // 2.11

            Term term1 = new Term(2017, 3);

            foreach (Course c in courses1)
            {
                term1.AddCourse(c);
            }

            Course[] courses2 = new Course[]
            {
                new Course("Course", 2, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 1, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
            };
            // 3.72

            Term term2 = new Term(2018, 1);

            foreach (Course c in courses2)
            {
                term2.AddCourse(c);
            }

            Score score = new Score("20444444", "DL444", 2044, "SE", "SE01", true);

            score.AddTerm(term1);

            Course[] courses3 = new Course[] { courses1[0], courses1[1], courses1[3], courses1[4] };
            Term     term3    = new Term(2017, 3);

            foreach (Course c in courses3)
            {
                term3.AddCourse(c);
            }

            Score score2 = new Score("20444444", "DL444", 2044, "SE", "SE01", true);

            score2.AddTerm(term3);
            score2.AddTerm(term2);

            Assert.AreEqual(false, score == score2);
            Assert.AreEqual(true, score == score);
        }
Exemplo n.º 6
0
        public void Test_Diff()
        {
            Course[] courses1 = new Course[]
            {
                new Course("Course", 1, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 2, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 4, "Test Category", true, 67,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 72,
                           true, "补考", "Lecturer", System.DateTime.Today)
            };
            // 2.11

            Term term1 = new Term(2017, 3);

            foreach (Course c in courses1)
            {
                term1.AddCourse(c);
            }

            Course[] courses2 = new Course[]
            {
                new Course("Course", 2, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 3, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course", 1, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
            };
            // 3.72

            Term term2 = new Term(2018, 1);

            foreach (Course c in courses2)
            {
                term2.AddCourse(c);
            }

            Score score = new Score("20444444", "DL444", 2044, "SE", "SE01", true);

            score.AddTerm(term1);

            Course[] courses3 = new Course[] { courses1[0], courses1[1], courses1[3], courses1[4] };
            Term     term3    = new Term(2017, 3);

            foreach (Course c in courses3)
            {
                term3.AddCourse(c);
            }

            Score score2 = new Score("20444444", "DL444", 2044, "SE", "SE01", true);

            score2.AddTerm(term3);
            score2.AddTerm(term2);

            var diffResult = Score.Diff(score, score2);
            List <CourseDiffInfo> expDiffResult = new List <CourseDiffInfo>()
            {
                new CourseDiffInfo(CourseDiffInfo.DiffType.Remove, courses1[2]),
                new CourseDiffInfo(CourseDiffInfo.DiffType.Add, courses2[0]),
                new CourseDiffInfo(CourseDiffInfo.DiffType.Add, courses2[1]),
                new CourseDiffInfo(CourseDiffInfo.DiffType.Add, courses2[2])
            };

            Assert.AreEqual(expDiffResult.Count, diffResult.Count);
            foreach (var i in expDiffResult)
            {
                Assert.AreEqual(true, diffResult.Any(x => x.Type == i.Type && x.Course == i.Course));
            }
        }
Exemplo n.º 7
0
        public void Test_Diff()
        {
            Course course3Retake1 = new Course("Course3", 3, "Test Category", true, 72, true, "补考", "Lecturer", System.DateTime.Today);
            Course course3Retake2 = new Course("Course3", 3, "Test Category", true, 73, true, "补考", "Lecturer", System.DateTime.Today);
            Course course4        = new Course("Course4", 4, "Test Category", true, 67, true, "", "Lecturer", System.DateTime.Today);
            Course course5        = new Course("Course5", 5, "Test Category", true, 67, true, "", "Lecturer", System.DateTime.Today);

            Course[] courses1 = new Course[]
            {
                new Course("Course1", 1, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course2", 2, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course3", 3, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
                course4,
                course3Retake1
            };

            Course[] courses2 = new Course[]
            {
                new Course("Course1", 1, "Test Category", true, 83,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course2", 2, "Test Category", true, 96,
                           true, "", "Lecturer", System.DateTime.Today),
                new Course("Course3", 3, "Test Category", true, 42,
                           true, "", "Lecturer", System.DateTime.Today),
                course3Retake2,
                course5
            };


            Term term1 = new Term(2018, 1);

            foreach (Course c in courses1)
            {
                term1.AddCourse(c);
            }

            Term term2 = new Term(2018, 1);

            foreach (Course c in courses2)
            {
                term2.AddCourse(c);
            }

            var diffResult = Term.Diff(term1, term2);
            List <CourseDiffInfo> expDiffResult = new List <CourseDiffInfo>()
            {
                new CourseDiffInfo(CourseDiffInfo.DiffType.Add, course3Retake2),
                new CourseDiffInfo(CourseDiffInfo.DiffType.Remove, course3Retake1),
                new CourseDiffInfo(CourseDiffInfo.DiffType.Add, course5),
                new CourseDiffInfo(CourseDiffInfo.DiffType.Remove, course4)
            };

            Assert.AreEqual(expDiffResult.Count, diffResult.Count);
            foreach (var i in expDiffResult)
            {
                Assert.AreEqual(true, diffResult.Any(x => x.Type == i.Type && x.Course == i.Course));
            }
        }