public void TestAddStudentExceptionWhenAlreadyAdded() { Course course = new Course("Math"); Student student = new Student("Pesho"); course.AddStudent(student); course.AddStudent(student); }
public void StudentConstructorTestUniqueNumber() { string name = "Maria Petrova"; int uniqueNumber = 12345; Student student = new Student(name, uniqueNumber); Assert.AreEqual(student.UniqueNumber, 12345); }
public void UniqueNumberTestEndValuePlus10000() { string name = "Maria Petrova"; int uniqueNumber = 109999; Student student = new Student(name, uniqueNumber); Assert.IsTrue(uniqueNumber >= 10000 && uniqueNumber <= 99999); }
public void TestRemoveStudentExceptionWhenNotExisting() { Course course = new Course("Math"); Student studentOne = new Student("Pesho"); Student studentTwo = new Student("Gosho"); course.AddStudent(studentOne); course.RemoveStudent(studentTwo); }
public void AddStudentTestSameStudentTwoTimes() { string name = "Javascript"; IList<Student> students = new List<Student>(); Course course = new Course(name); Student maria = new Student("Maria Petrova", 12345); course.AddStudent(maria); course.AddStudent(maria); }
public void AddStudentTestOneStudent() { string name = "Javascript"; IList<Student> students = new List<Student>(); Course course = new Course(name); Student maria = new Student("Maria Petrova", 12345); course.AddStudent(maria); Assert.IsTrue(course.Students.Count == 1); }
public void ToStringTest() { string name = "Maria Petrova"; int uniqueNumber = 12345; Student student = new Student(name, uniqueNumber); string expected = "Student Maria Petrova, ID 12345; "; string actual; actual = student.ToString(); Assert.AreEqual(expected, actual); }
public void RemoveStudent(Student student) { bool isStudentFound = this.FindStudent(student); if (!isStudentFound) { throw new ArgumentException("The student is not in this course!"); } this.Students.Remove(student); }
public void AddStudentTestTwoStudents() { string name = "Javascript"; IList<Student> students = new List<Student>(); Course course = new Course(name); Student maria = new Student("Maria Petrova", 12345); Student petar = new Student("Petar Marinov", 23445); course.AddStudent(maria); course.AddStudent(petar); Assert.IsTrue(course.Students.Count == 2); }
public void RemoveStudent(Student student) { if (!HasStudent(student.Id)) { throw new KeyNotFoundException("Student with this id doesn't exist in the course!"); } for (int i = 0; i < this.students.Count; i++) { if (this.students[i].Id == student.Id) { this.students.RemoveAt(i); break; } } }
public void AddStudent(Student student) { if (student == null) { throw new ArgumentNullException("Student cannot be null!"); } if (students.Count > MaxStudentsInCourse) { throw new InvalidOperationException("The course is full! Cannot add more students!"); } if (HasStudent(student.Id)) { throw new InvalidOperationException("This student is already enrolled the course!"); } this.students.Add(student); }
public void TestAddStudentRemoveStudent() { Course course = new Course("Math"); Student student = new Student("Pesho"); course.AddStudent(new Student("Gosho")); Assert.AreEqual(course.Students.Count, 1); course.AddStudent(student); Assert.AreEqual(course.Students.Count, 2); Assert.AreEqual(course.Students[1].Name, "Pesho"); course.RemoveStudent(student); Assert.AreEqual(course.Students.Count, 1); Assert.AreEqual(course.Students[0].Name, "Gosho"); }
public void AddStudent(Student student) { bool isStudentFound = this.FindStudent(student); if (isStudentFound) { throw new ArgumentException("The student has been added already!"); } if (this.Students.Count < (MAX_STUDENTS-1)) { this.Students.Add(student); } else { throw new ArgumentOutOfRangeException("The course is full. No more students can be added!"); } }
public void UniqueNumberTestStartValueMinusOne() { string name = "Maria Petrova"; int uniqueNumber = 9999; Student student = new Student(name, uniqueNumber); Assert.IsTrue(uniqueNumber >= 10000 && uniqueNumber <= 99999); }
public void UniqueNumberTestNegativeValue() { string name = "Maria Petrova"; int uniqueNumber = -55555; Student student = new Student(name, uniqueNumber); Assert.IsTrue(uniqueNumber >= 10000 && uniqueNumber <= 99999); }
public void CourseConstructorTestListStudents() { string name = "Javascript"; Student maria = new Student("Maria Petrova", 12345); IList<Student> students = new List<Student>(); Course course = new Course(name); course.AddStudent(maria); Assert.IsTrue(course.Students.Contains(maria)); }
public void TestConstructor() { Student student = new Student("Gosho"); Assert.AreEqual(student.Name, "Gosho"); Assert.IsTrue(student.Id >= 10000 && student.Id <= 99999); }
public void RemoveStudent(Student studentToRemove) { students.Remove(studentToRemove); }
public void TestNameExceptionWhenNull() { Student student = new Student(null); }
public void RemoveNonExistingStudentTest() { string name = "Javascript"; IList<Student> students = new List<Student>(); Course course = new Course(name); Student maria = new Student("Maria Petrova", 12345); course.RemoveStudent(maria); }
private bool FindStudent(Student student) { bool isFound = false; for (int i = 0; i < this.Students.Count; i++) { if (this.Students[i].UniqueNumber == student.UniqueNumber) { isFound = true; } } return isFound; }
public void NameTestEmptyString() { string name = string.Empty; int uniqueNumber = 12345; Student student = new Student(name, uniqueNumber); }
public void NameTestNullValue() { string name = null; int uniqueNumber = 12345; Student student = new Student(name, uniqueNumber); }
public void TestNameExceptionWhenEmpty() { Student student = new Student(""); }
public void ToStringTestTwoStudents() { string name = "Javascript"; Student maria = new Student("Maria Petrova", 12345); Student petar = new Student("Petar Marinov", 23445); IList<Student> students = new List<Student>(); Course javascript = new Course(name); javascript.AddStudent(maria); javascript.AddStudent(petar); string expected = "Course name Javascript; Student Maria Petrova, ID 12345; Student Petar Marinov, ID 23445; "; string actual; actual = javascript.ToString(); Assert.AreEqual(expected, actual); }
public void TestNameExceptionWhenTooShort() { Student student = new Student("I"); }
public void UniqueNumberTestIntMaxValue() { string name = "Maria Petrova"; int uniqueNumber = int.MaxValue; Student student = new Student(name, uniqueNumber); Assert.IsTrue(uniqueNumber >= 10000 && uniqueNumber <= 99999); }
public void AddStudent(Student newStudent) { students.Add(newStudent); }