public void TestCourseAddStudentMethodIfStudentIsPassedToBeAdded()
 {
     var student = new Student("aaa", 12345);
     var myCourse = new Course("aa");
     myCourse.AddStudent(student);
     Assert.AreEqual(student.ID, myCourse.Students[0].ID);
 }
 public void AddStudent(Student student)
 {
     if (this.students.Count < 29)
     {
         this.students.Add(student);
     }
 }
Esempio n. 3
0
        public void InitStudent()
        {
            School mySchool = new School();
            Student pesho = new Student("Pesho", 10001, mySchool);

            Assert.IsTrue(pesho.Name == "Pesho");
            Assert.IsTrue(pesho.Number == 10001);
        }
 public void TestCourseRemoveStudentMethodIfInvalidStudentIsPassedToBeRemoved()
 {
     var validStudent = new Student("aaa", 12345);
     var invalidStudent = new Student("we", 12345);
     var myCourse = new Course("aa");
     myCourse.AddStudent(validStudent);
     myCourse.RemoveStudent(invalidStudent);
 }
 public void TestCourseRemoveStudentMethodIfValidStudentIsPassedToBeRemoved()
 {
     var student = new Student("aaa", 12345);
     var myCourse = new Course("aa");
     myCourse.AddStudent(student);
     myCourse.RemoveStudent(student);
     Assert.AreEqual(myCourse.Students.Count, 0);
 }
Esempio n. 6
0
        public void JoinCourseOfNull()
        {
            School mySchool = new School();

            Student pesho = new Student("Pesho", 10000, mySchool);

            pesho.JointCourse(null);
        }
Esempio n. 7
0
 private void MakeSureStudentNumberIsUnique(Student student)
 {
     for (int numIndex = 0; numIndex < this.studentsNumbers.Count; numIndex++)
     {
         if (this.studentsNumbers[numIndex] == student.Number)
         {
             throw new ArgumentException("The student is already part of the school!");
         }
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Add Student to the list 
 /// </summary>
 /// <param name="student">Student object</param>
 public void AddStudent(Student student)
 {
     if (!this.Students.ContainsKey(student.ClassNumber))
     {
         this.Students.Add(student.ClassNumber, student);
     }
     else
     {
         throw new ArgumentException("Provided Student's ClassNumber is not unique!");
     }
 }
Esempio n. 9
0
        // This is kind of a helper method for ensuaring that every student has an unique number.
        public void AddStudent(Student student)
        {
            if (student == null)
            {
                throw new ArgumentNullException("Student can not be null!");
            }

            MakeSureStudentNumberIsUnique(student);

            this.studentsNumbers.Add(student.Number);
        }
Esempio n. 10
0
 public void AddStudent(Student student)
 {
     if (MaxStudents != this.students.Count)
     {
         this.students.Add(student);
     }
     else
     {
         throw new ArgumentOutOfRangeException("There can not be more than 30 students in the course!");
     }
 }
Esempio n. 11
0
 public void RemoveStudent(Student student)
 {
     if (this.students.Contains(student))
     {
         this.students.Remove(student);
     }
     else
     {
         throw new ArgumentException("The student is already in the course!");
     }
 }
        public void TestCourseToHaveLessThan30Students()
        {
            var student = new Student("aaa", 12345);
            var myCourse = new Course("aa");
            for (int i = 0; i < 32; i++)
            {
                myCourse.AddStudent(student);
            }

            var expectedNumberOfStudentsInTheCourse = MaximalNumberOfStudentsInCourse;
            Assert.AreEqual(expectedNumberOfStudentsInTheCourse, myCourse.Students.Count);
        }
Esempio n. 13
0
        public void JoinCourse()
        {
            School mySchool = new School();

            Course math = new Course();

            Student pesho = new Student("Pesho", 10000, mySchool);

            pesho.JointCourse(math);

            Assert.IsTrue(math.Students.Count == 1);
        }
Esempio n. 14
0
        public static void Main()
        {
            // Create & loads Teacher & Disciplines
            Teacher teacherOne = new Teacher("Goshko", "Goshkov");
            Discipline disciplineOne = new Discipline("Mathematica", 4, 10);
            Discipline disciplineTwo = new Discipline("Phisics", 10, 6);
            teacherOne.AddDiscipline(disciplineOne);
            teacherOne.AddDiscipline(disciplineTwo);

            // Create & loads students
            Student studentOne = new Student("Petarcho", "Petarchov", 1);
            Student studentTwo = new Student("Yordancho", "Yordanov", 2);
            Student studentThree = new Student("Zuyo", "Zuev", 1);
            Student studentFour = new Student("Suzi", "Suzankovichkova", 2);

            // Create & loads class with students and teachers
            Class classOne = new Class("Class One");
            try
            {
                classOne.AddStudent(studentOne);
                classOne.AddStudent(studentTwo);
                classOne.AddTeacher(teacherOne);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }

            Teacher teacherTwo = new Teacher("Petunia", "Petunkova", new Discipline("Rocket Science", 1000, 6000));
            Class classTwo = new Class("Class Two");
            try
            {
                classTwo.AddStudent(studentThree);
                classTwo.AddStudent(studentFour);
                classTwo.AddTeacher(teacherOne);
                classTwo.AddTeacher(teacherTwo);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }

            // Create & loads school and add class
            School school = new School();
            school.AddClass(classOne);
            school.AddClass(classTwo);
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("School details:");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(school.ToString());
        }
Esempio n. 15
0
        public void RemoveStudent(Student student)
        {
            bool isRemovedStudent = false;
            for (int i = 0; i < this.Students.Count; i++)
            {
                if (this.students[i].ID == student.ID && this.students[i].Name == student.Name)
                {
                    isRemovedStudent = true;
                    this.students.RemoveAt(i);
                }
            }

            if (isRemovedStudent == false)
            {
                throw new ArgumentOutOfRangeException("Invalid student!");
            }
        }
 public void TestCorrectIDtoBeRecordedAsID()
 {
     var student = new Student("aaa", 12345);
     var expectedID = 12345;
     Assert.AreEqual(expectedID, student.ID);
 }
 public void TestCorrectID99999toBeRecordedAsID()
 {
     int idNumber = 99999;
     var student = new Student("aaa", idNumber);
     Assert.IsTrue(idNumber >= 10000 && idNumber <= 99999);
 }
Esempio n. 18
0
        public void LeaveCourseOfNull()
        {
            School mySchool = new School();

            Student pesho = new Student("Pesho", 99999, mySchool);

            pesho.LeaveCourse(null);
        }
Esempio n. 19
0
 public void InitStudentWithTooSmallNumber()
 {
     School mySchool = new School();
     Student pesho = new Student("Pesho", 9999, mySchool);
 }
 public void TestStudentIDEqualTo9999ToThrowArgumentException()
 {
     var student = new Student("aaa", 9999);
 }
 public void TestStudentNameEqualToNullToThrowArgumentException()
 {
     var student = new Student(null, 1111);
 }
Esempio n. 22
0
 public void InitStudentWithNullName()
 {
     School mySchool = new School();
     Student pesho = new Student(null, 19345, mySchool);
 }
Esempio n. 23
0
 public void InitStudentWithoutSchool()
 {
     Student pesho = new Student("Pesho", 19345, null);
 }
 public void TestStudentBlankNameToThrowArgumentException()
 {
     var student = new Student(string.Empty, 11111);
 }
 public void TestStudentIDEqualTo100000ToThrowArgumentException()
 {
     var student = new Student("aaa", 100000);
 }
Esempio n. 26
0
 public void InitStudentWithEmptyName()
 {
     School mySchool = new School();
     Student pesho = new Student("", 19345, mySchool);
 }
 public void TestStudentIDIntMinValueToThrowArgumentException()
 {
     var id = int.MinValue;
     var student = new Student("aaa", id);
 }
Esempio n. 28
0
 public void InitStudentWithTooBigNumber()
 {
     School mySchool = new School();
     Student pesho = new Student("Pesho", 100000, mySchool);
 }
 public void TestStudentNameToBeEqualToTestString()
 {
     var student = new Student("Aaaa", 11111);
     var expectedName = "Aaaa";
     Assert.AreEqual(expectedName, student.Name);
 }
Esempio n. 30
0
 /// <summary>
 /// Removes Student from the list.
 /// If Student instance (student with that ClassNumber) is not found no change is applied.
 /// </summary>
 /// <param name="student">Student object</param>
 public void RemoveStudent(Student student)
 {
     if (student != null)
     {
         if (this.Students.ContainsKey(student.ClassNumber))
         {
             this.Students.Remove(student.ClassNumber);
         }
     }
     else
     {
         throw new ArgumentNullException("student", "Student instance cannot be null!");
     }
 }