public void Test_CourseJoinStudentTwiceShouldThrow() { var st = new Student(VALID_NAME, VALID_NUMBER); var course = new Course(); course.Join(st); course.Join(st); }
/// <summary> /// The leave. /// </summary> /// <param name="student"> /// The student. /// </param> /// <exception cref="ArgumentException"> /// </exception> public void Leave(Student student) { if (!this.students.Contains(student)) { throw new ArgumentException("Student is not in this course"); } this.students.Remove(student); }
public void Test_AddTooManyStudentsShouldThrow() { var course = new Course(); for (int i = 0; i < 50; i++) { var st = new Student(VALID_NAME, VALID_NUMBER + 1); course.Join(st); } }
/// <summary> /// The join. /// </summary> /// <param name="student"> /// The student. /// </param> /// <exception cref="ArgumentException"> /// </exception> public void Join(Student student) { if (this.students.Contains(student)) { throw new ArgumentException("Student is already in this course"); } if (this.students.Count >= 29) { throw new ArgumentException("Course is full"); } this.students.Add(student); }
public void Test_CourseWithValidStudentShouldNotThrow() { var st = new Student(VALID_NAME, VALID_NUMBER); var course = new Course(); try { course.Join(st); course.Leave(st); } catch (Exception ex) { Assert.Fail("Expected no exception, but got: " + ex.Message); } }
public void Test_LeaveNotExistingStudentShouldThrow() { var st = new Student(VALID_NAME, VALID_NUMBER); var course = new Course(); course.Leave(st); }
public void Test_StudentWithValidParameters() { var st = new Student(VALID_NAME, VALID_NUMBER); Assert.IsTrue(st.Name == VALID_NAME && st.Number == VALID_NUMBER, "Name and numbers are not corrent!"); }
public void Test_StudentWithInvalidNumber() { var st = new Student(VALID_NAME, NOT_VALID_NUMBER); }
public void Test_StudentWithInvalidName() { var st = new Student(NOT_VALID_NAME, VALID_NUMBER); }