예제 #1
0
 public void TestStudent_JoinCourse()
 {
     Student testStudentOne = new Student("Pesho");
     Course javascript = new Course("Javascript Course", "Nakov");
     testStudentOne.JoinCourse(javascript);
     Assert.IsTrue(javascript.Students.Contains(testStudentOne), "Student has not been included in the course");
 }
예제 #2
0
 public void TestStudentConstructor_IdOutOfRange()
 {
     //The last student that is created in the loop have ID bigger than the maxID and the proprty throws an exception
     for (int i = Student.MinIdNumber; i < Student.MaxIdNumber; i++)
     {
         Student testStudentIdOutOfRange = new Student("Pesho");
     }
 }
예제 #3
0
 public void AddStudent(Student student)
 {
     if (student == null)
     {
         throw new ArgumentNullException("Student can't be null");
     }
     if (this.students.Count == MaxStudentsInClass)
     {
         throw new InvalidOperationException("The number of students in one class must not exceed " + MaxStudentsInClass);
     }
     if (this.students.Contains(student))
     {
         throw new ArgumentException("This student is already in the class");
     }
     this.students.Add(student);
 }
예제 #4
0
 public void TestCourse_RemoveStudent()
 {
     Course course = new Course(courseName, teacherName);
     Student pesho = new Student("Pesho");
     course.AddStudent(pesho);
     course.RemoveStudent(pesho);
     Assert.IsFalse(course.Students.Contains(pesho), "Student is still in the course");
 }
예제 #5
0
 public void TestCourse_AddStudentInvalidOperation()
 {
     Course testCourseInvalid = new Course(courseName, teacherName);
     for (int i = 0; i < Course.MaxStudentsInClass + 1; i++)
     {
         Student student = new Student("Gosho");
         testCourseInvalid.AddStudent(student);
     }
 }
예제 #6
0
 public void RemoveStudent(Student student)
 {
     if (student == null)
     {
         throw new ArgumentNullException("Student can't be null");
     }
     if (!this.students.Contains(student))
     {
         throw new ArgumentException("There is no such student in the class.");
     }
     this.students.Remove(student);
 }
예제 #7
0
 public void TestStudent_LeaveCourseNull()
 {
     Student testStudentOne = new Student("Pesho");
     Course javascript = new Course("Javascript Course", "Nakov");
     testStudentOne.JoinCourse(javascript);
     testStudentOne.LeaveCourse(null);
 }
예제 #8
0
 public void TestStudentConstructor_BlankThrowException()
 {
     Student blankStudent = new Student(string.Empty);
 }
예제 #9
0
 public void TestCourse_AddStudent()
 {
     Course course = new Course(courseName, teacherName);
     Student pesho = new Student("Pesho");
     course.AddStudent(pesho);
     Assert.IsTrue(course.Students.Contains(pesho), "Student is not in the course");
 }
예제 #10
0
 public void TestStudentConstructor_WhitespaceThrowException()
 {
     Student whitespaceStudent = new Student("   ");
 }
예제 #11
0
 public void TestStudentConstructor_NullThrowException()
 {
     Student nullStudent = new Student(null);
 }
예제 #12
0
 public void TestStudentConstructor_Name()
 {
     Student testStudent = new Student("Gosho Peshov");
     Assert.AreEqual("Gosho Peshov", testStudent.Name, "Student name is not set in a correct way");
 }
예제 #13
0
 public void TestStudentConstructor_Id()
 {
     Student testStudentId = new Student("Pesho");
     Assert.IsTrue((Student.MinIdNumber < testStudentId.Id && Student.MaxIdNumber > testStudentId.Id), "Id is not set in a correct way");
 }
예제 #14
0
 public void TestStudentConstructor_CompareId()
 {
     Student testStudentOne = new Student("Pesho");
     Student testStudentTwo = new Student("Gosho");
     Assert.IsTrue((testStudentOne.Id == (testStudentTwo.Id - 1)), "Id of the two students is not set in a correct way");
 }
예제 #15
0
 public void TestCourse_RemoveStudentArgumentNone()
 {
     Course testCourse = new Course(courseName, teacherName);
     Student gosho = new Student("Gosho");
     testCourse.RemoveStudent(gosho);
 }
예제 #16
0
 public void TesttCourse_ToString()
 {
     Course course = new Course(courseName, teacherName);
     Student pesho = new Student("Pesho");
     course.AddStudent(pesho);
     //Student StringBuilder
     StringBuilder studentStr = new StringBuilder();
     studentStr.AppendFormat("Name: Pesho, Id: {0}", pesho.Id).AppendLine();
     //Course StringBUilder
     StringBuilder message = new StringBuilder();
     message.AppendLine("------COURSE-INFO-------");
     message.AppendLine("Name = Javascript, Teacher = Nakov ");
     message.AppendFormat("Students: \n{0}", studentStr.ToString());
     message.AppendLine("------END-COURSE-INFO-------");
     Assert.AreEqual(message.ToString(), course.ToString(), "Strings don't match");
 }
예제 #17
0
 public void TestStudent_JoinCourseNull()
 {
     Student testStudentOne = new Student("Pesho");
     testStudentOne.JoinCourse(null);
 }
예제 #18
0
 public void TestCourse_AddStudentArgument()
 {
     Course testCourse = new Course(courseName, teacherName);
     Student studentGosho = new Student("Gosho");
     testCourse.AddStudent(studentGosho);
     testCourse.AddStudent(studentGosho);
 }
예제 #19
0
 public void TestStudent_ToString()
 {
     Student testStudentString = new Student("Pesho");
     Assert.AreEqual(string.Format("Name: {0}, Id: {1}", testStudentString.Name, testStudentString.Id), testStudentString.ToString());
 }