Exemplo n.º 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");
 }
Exemplo n.º 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");
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 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");
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 7
0
 public void TestStudent_LeaveCourseNull()
 {
     Student testStudentOne = new Student("Pesho");
     Course javascript = new Course("Javascript Course", "Nakov");
     testStudentOne.JoinCourse(javascript);
     testStudentOne.LeaveCourse(null);
 }
Exemplo n.º 8
0
 public void TestStudentConstructor_BlankThrowException()
 {
     Student blankStudent = new Student(string.Empty);
 }
Exemplo n.º 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");
 }
Exemplo n.º 10
0
 public void TestStudentConstructor_WhitespaceThrowException()
 {
     Student whitespaceStudent = new Student("   ");
 }
Exemplo n.º 11
0
 public void TestStudentConstructor_NullThrowException()
 {
     Student nullStudent = new Student(null);
 }
Exemplo n.º 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");
 }
Exemplo n.º 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");
 }
Exemplo n.º 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");
 }
Exemplo n.º 15
0
 public void TestCourse_RemoveStudentArgumentNone()
 {
     Course testCourse = new Course(courseName, teacherName);
     Student gosho = new Student("Gosho");
     testCourse.RemoveStudent(gosho);
 }
Exemplo n.º 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");
 }
Exemplo n.º 17
0
 public void TestStudent_JoinCourseNull()
 {
     Student testStudentOne = new Student("Pesho");
     testStudentOne.JoinCourse(null);
 }
Exemplo n.º 18
0
 public void TestCourse_AddStudentArgument()
 {
     Course testCourse = new Course(courseName, teacherName);
     Student studentGosho = new Student("Gosho");
     testCourse.AddStudent(studentGosho);
     testCourse.AddStudent(studentGosho);
 }
Exemplo n.º 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());
 }