예제 #1
0
 public void TestAddStudentExceptionWhenAlreadyAdded()
 {
     Course course = new Course("Math");
     Student student = new Student("Pesho");
     course.AddStudent(student);
     course.AddStudent(student);
 }
예제 #2
0
 public void StudentConstructorTestUniqueNumber()
 {
     string name = "Maria Petrova";
     int uniqueNumber = 12345;
     Student student = new Student(name, uniqueNumber);
     Assert.AreEqual(student.UniqueNumber, 12345);
 }
예제 #3
0
 public void UniqueNumberTestEndValuePlus10000()
 {
     string name = "Maria Petrova";
     int uniqueNumber = 109999;
     Student student = new Student(name, uniqueNumber);
     Assert.IsTrue(uniqueNumber >= 10000 && uniqueNumber <= 99999);
 }
예제 #4
0
 public void TestRemoveStudentExceptionWhenNotExisting()
 {
     Course course = new Course("Math");
     Student studentOne = new Student("Pesho");
     Student studentTwo = new Student("Gosho");
     course.AddStudent(studentOne);
     course.RemoveStudent(studentTwo);
 }
예제 #5
0
 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);
 }
예제 #6
0
 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);
 }
예제 #7
0
 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);
 }
예제 #8
0
        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);
        }
예제 #9
0
 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);
 }
예제 #10
0
        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;
                }
            }
        }
예제 #11
0
 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);
 }
예제 #12
0
        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");
        }
예제 #13
0
        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!");
            }
        }
예제 #14
0
 public void UniqueNumberTestStartValueMinusOne()
 {
     string name = "Maria Petrova";
     int uniqueNumber = 9999;
     Student student = new Student(name, uniqueNumber);
     Assert.IsTrue(uniqueNumber >= 10000 && uniqueNumber <= 99999);
 }
예제 #15
0
 public void UniqueNumberTestNegativeValue()
 {
     string name = "Maria Petrova";
     int uniqueNumber = -55555;
     Student student = new Student(name, uniqueNumber);
     Assert.IsTrue(uniqueNumber >= 10000 && uniqueNumber <= 99999);
 }
예제 #16
0
 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));
 }
예제 #17
0
 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);
 }
예제 #19
0
 public void TestNameExceptionWhenNull()
 {
     Student student = new Student(null);
 }
예제 #20
0
 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);
 }
예제 #21
0
        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;
        }
예제 #22
0
 public void NameTestEmptyString()
 {
     string name = string.Empty;
     int uniqueNumber = 12345;
     Student student = new Student(name, uniqueNumber);
 }
예제 #23
0
 public void NameTestNullValue()
 {
     string name = null;
     int uniqueNumber = 12345;
     Student student = new Student(name, uniqueNumber);
 }
예제 #24
0
 public void TestNameExceptionWhenEmpty()
 {
     Student student = new Student("");
 }
예제 #25
0
 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);
 }
예제 #26
0
 public void TestNameExceptionWhenTooShort()
 {
     Student student = new Student("I");
 }
예제 #27
0
 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);
 }