Ejemplo n.º 1
0
 public void TestAddStudentExceptionWhenAlreadyAdded()
 {
     Course course = new Course("Math");
     Student student = new Student("Pesho");
     course.AddStudent(student);
     course.AddStudent(student);
 }
Ejemplo n.º 2
0
 public void StudentConstructorTestUniqueNumber()
 {
     string name = "Maria Petrova";
     int uniqueNumber = 12345;
     Student student = new Student(name, uniqueNumber);
     Assert.AreEqual(student.UniqueNumber, 12345);
 }
Ejemplo n.º 3
0
 public void UniqueNumberTestEndValuePlus10000()
 {
     string name = "Maria Petrova";
     int uniqueNumber = 109999;
     Student student = new Student(name, uniqueNumber);
     Assert.IsTrue(uniqueNumber >= 10000 && uniqueNumber <= 99999);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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");
        }
Ejemplo n.º 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!");
            }
        }
Ejemplo n.º 14
0
 public void UniqueNumberTestStartValueMinusOne()
 {
     string name = "Maria Petrova";
     int uniqueNumber = 9999;
     Student student = new Student(name, uniqueNumber);
     Assert.IsTrue(uniqueNumber >= 10000 && uniqueNumber <= 99999);
 }
Ejemplo n.º 15
0
 public void UniqueNumberTestNegativeValue()
 {
     string name = "Maria Petrova";
     int uniqueNumber = -55555;
     Student student = new Student(name, uniqueNumber);
     Assert.IsTrue(uniqueNumber >= 10000 && uniqueNumber <= 99999);
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 19
0
 public void TestNameExceptionWhenNull()
 {
     Student student = new Student(null);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 22
0
 public void NameTestEmptyString()
 {
     string name = string.Empty;
     int uniqueNumber = 12345;
     Student student = new Student(name, uniqueNumber);
 }
Ejemplo n.º 23
0
 public void NameTestNullValue()
 {
     string name = null;
     int uniqueNumber = 12345;
     Student student = new Student(name, uniqueNumber);
 }
Ejemplo n.º 24
0
 public void TestNameExceptionWhenEmpty()
 {
     Student student = new Student("");
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 26
0
 public void TestNameExceptionWhenTooShort()
 {
     Student student = new Student("I");
 }
Ejemplo n.º 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);
 }