示例#1
0
        public static void Main(string[] args)
        {
            try
            {
                School SMG = new School("Sofia Math Gymnasium");
                Console.WriteLine(SMG.ToString());

                SMG.AddStudent("Ivan Ivanov");
                SMG.AddStudent("Georgi Georgiev");
                SMG.AddStudent("Ivan Georgiev");
                SMG.AddStudent("Georgi Ivanov");

                SMG.AddCourse("Biology");
                SMG.AddCourse("Mathematics");

                // First we get the list of student to find which student id we need!
                SMG.EnrollStudentToCourse("Biology", 10001);
                SMG.EnrollStudentToCourse("Biology", 10002);
                SMG.EnrollStudentToCourse("Biology", 10000);
                // SMG.EnrollStudentToCourse("Biology", 10000); // Exception thrown: "The student you are trying to enroll is allready enrolled in this course"

                SMG.DismissStudentFromCourse("Biology", 10000);
                // SMG.DismissStudentFromCourse("Biology", 10000); // Exception thrown: "There is no such student in this course"

                Console.WriteLine(SMG.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
 public void TestEnrollStudentToCourse()
 {
     School newSchool = new School("smg");
     newSchool.AddStudent("Ivan");
     newSchool.AddCourse("Math");
     newSchool.EnrollStudentToCourse("Math", 10000);
 }
 public void DismissStudentFromCourse()
 {
     School newSchool = new School("smg");
     newSchool.AddStudent("Ivan");
     newSchool.AddCourse("Math");
     newSchool.EnrollStudentToCourse("Math", 10000);
     newSchool.DismissStudentFromCourse("Math", 10000);
 }
 public void TestEnrollStudentToCourseArgumentExeption()
 {
     School newSchool = new School("smg");
     newSchool.EnrollStudentToCourse(null, 1);
 }
 public void TestCoursesListDefaultMsg()
 {
     School newSchool = new School("smg");
     Assert.AreEqual("Sorry, there are no courses in this school", newSchool.CoursesList());
 }
 public void TestAddStudentArgumentExeption()
 {
     School newSchool = new School("smg");
     newSchool.AddStudent(null);
 }
 public void TestAddStudent()
 {
     School newSchool = new School("smg");
     newSchool.AddStudent("Petkan");
 }
 public void TestAddCourseArgumentExeption()
 {
     School newSchool = new School("smg");
     newSchool.AddCourse(null);
 }
 public void TestGetNextFreeIdArgumentOutOfRangeException()
 {
     School newSchool = new School("smg");
     for (int i = 0; i < 1000001; i++)
     {
         newSchool.AddStudent(i.ToString());
     }
 }
示例#10
0
 public void DismissStudentFromCourseArgumentOutOfRangeException()
 {
     School newSchool = new School("smg");
     newSchool.DismissStudentFromCourse("Ivan Ivanov", 1);
 }
示例#11
0
 public void DismissStudentFromCourseArgumentExeption()
 {
     School newSchool = new School("smg");
     newSchool.DismissStudentFromCourse(null, 1);
 }
示例#12
0
 public void TestToStringEmpty()
 {
     School newSchool = new School("smg");
     StringBuilder result = new StringBuilder();
     result.AppendLine(newSchool.CoursesList());
     result.AppendLine(newSchool.StudentsList());
     Assert.AreEqual(result.ToString(), newSchool.ToString());
 }
示例#13
0
        public void TestToString()
        {
            School SMG = new School("Sofia Math Gymnasium");

            SMG.AddStudent("Ivan Ivanov");
            SMG.AddStudent("Georgi Georgiev");
            SMG.AddStudent("Ivan Georgiev");
            SMG.AddStudent("Georgi Ivanov");

            SMG.AddCourse("Biology");
            SMG.AddCourse("Mathematics");

            SMG.EnrollStudentToCourse("Biology", 10001);
            SMG.EnrollStudentToCourse("Biology", 10002);
            SMG.EnrollStudentToCourse("Biology", 10000);

            string expected =
                @"Course Name: Biology Enrolled Students: 3
            Course Name: Mathematics Enrolled Students: 0

            Id: 10000  Name: Ivan Ivanov
            Id: 10001  Name: Georgi Georgiev
            Id: 10002  Name: Ivan Georgiev
            Id: 10003  Name: Georgi Ivanov

            ";

            Assert.AreEqual(expected, SMG.ToString());
        }
示例#14
0
 public void TestStudentsListDefaultMsg()
 {
     School newSchool = new School("smg");
     Assert.AreEqual("Sorry, there are no students in this school", newSchool.StudentsList());
 }
示例#15
0
 public void TestSchoolCtor()
 {
     School newSchool = new School(null);
 }
示例#16
0
 public void TestEnrollStudentToCourseArgumentOutOfRangeException()
 {
     School newSchool = new School("smg");
     newSchool.EnrollStudentToCourse("Ivan Ivanov", 1);
 }
示例#17
0
 public void TestAddCourse()
 {
     School newSchool = new School("smg");
     newSchool.AddCourse("Math");
 }
示例#18
0
 public void TestGetNameArgumentException()
 {
     School newSchool = new School("smg");
     string name = newSchool.Name;
     newSchool.Name = null;
 }