예제 #1
0
파일: SchoolTest.cs 프로젝트: elibk/KPK
        public void AddNewStudent_AddOneStudent()
        {
            School theSchool = new School();
            theSchool.AddNewStudent("Gosho");

            School myObject = theSchool;
            Type myType = typeof(School);
            FieldInfo setOfStudents = myType.GetField("students", BindingFlags.NonPublic | BindingFlags.Instance);

            IList<Student> students = setOfStudents.GetValue(myObject) as IList<Student>;

            Assert.IsTrue(students.Count == 1);
        }
예제 #2
0
파일: SchoolTest.cs 프로젝트: elibk/KPK
        public void AddNewStudent_AddFewStudents()
        {
            School theSchool = new School();
            int few = 5;
            for (int i = 0; i < few; i++)
            {
                theSchool.AddNewStudent("Gosho");
            }

            School myObject = theSchool;
            Type myType = typeof(School);
            FieldInfo setOfStudents = myType.GetField("students", BindingFlags.NonPublic | BindingFlags.Instance);

            IList<Student> students = setOfStudents.GetValue(myObject) as IList<Student>;

            Assert.IsTrue(students.Count == few);
        }
예제 #3
0
파일: SchoolTest.cs 프로젝트: elibk/KPK
        public void AddNewStudent_AddTooManyStudents()
        {
            School theSchool = new School();
            Type myType = typeof(School);

            FieldInfo maxID = myType.GetField("maxID", BindingFlags.NonPublic | BindingFlags.Static);
            FieldInfo minID = myType.GetField("minID", BindingFlags.NonPublic | BindingFlags.Static);
            FieldInfo idGenerator = myType.GetField("studentIDGenerator", BindingFlags.NonPublic | BindingFlags.Instance);

            uint minimumIDValue = 10;
            uint maximumIDValue = 99;
            minID.SetValue(myType, minimumIDValue);
            maxID.SetValue(myType, maximumIDValue);
            idGenerator.SetValue(theSchool, minimumIDValue);

            for (uint count = minimumIDValue; count <= maximumIDValue + 1; count++)
            {
                theSchool.AddNewStudent("Gosho");
            }
        }
예제 #4
0
파일: SchoolTest.cs 프로젝트: elibk/KPK
 public void SignStudentForCourse_SighStudentForUnexistingCourse()
 {
     School theSchool = new School();
     Student newStudent = theSchool.AddNewStudent("Pesho");
     theSchool.SignUpStudentForCourse(newStudent.Id, "CSharp");
 }
예제 #5
0
파일: SchoolTest.cs 프로젝트: elibk/KPK
        public void SignStudentForCourse_SighOneStudentForOneCourse()
        {
            School theSchool = new School();
            Student newStudent = theSchool.AddNewStudent("Pesho");
            Course newCourse = theSchool.AddNewCourse("CSharp");
            theSchool.SignUpStudentForCourse(newStudent.Id, newCourse.Name);

            School myObject = theSchool;
            Type myType = typeof(School);
            FieldInfo setOfCourses = myType.GetField("courses", BindingFlags.NonPublic | BindingFlags.Instance);

            IList<Course> courses = setOfCourses.GetValue(myObject) as IList<Course>;

            Assert.IsTrue(courses[courses.IndexOf(newCourse)].IsAttendingTheCourse(newStudent));
        }