RemoveCourse() public method

public RemoveCourse ( Course course ) : void
course Course
return void
示例#1
0
        public void TestSeveralCoursesWithSameName()
        {
            School.School s  = new School.School("bar");
            Course        c  = new Course("Math");
            Course        c1 = new Course("alpha");
            Course        c2 = new Course("beta");
            Course        c3 = new Course("gama");
            Course        c4 = new Course("Math");
            Course        c5 = new Course("Math");

            s.AddCourse(c);
            s.AddCourse(c1);
            s.AddCourse(c2);
            s.AddCourse(c3);
            s.AddCourse(c4);
            s.AddCourse(c5);

            Course removed = s.RemoveCourse("Math");

            bool result = removed == c;

            result = result && s.Courses[0] == c1 &&
                     s.Courses[1] == c2 && s.Courses[2] == c3 &&
                     s.Courses[3] == c4 && s.Courses[4] == c5;

            Assert.IsTrue(result);
        }
示例#2
0
        public void TestRemoveCourse2()
        {
            School school = new School("Telerik");
            Course course = new Course("JavaScript");

            school.AddCourse(course);
            school.RemoveCourse(new Course("Web"));
            Assert.AreEqual(0, school.Courses.Count, "Course was not removed successfully.");
        }
示例#3
0
 public void RemoveCourseFromSchool()
 {
     var school = new School("Telerik Academy");
     var javascript = new Course("Javascript");
     var html = new Course("HTML");
     school.AddCourse(javascript);
     school.AddCourse(html);
     school.RemoveCourse(html);
     string expected = school.ToString();
     string actual = "Course number: 1\nCourse name: Javascript\n";
     Assert.AreEqual(expected, actual);
 }
        public void TestRemoveCourseWithNullValue()
        {
            List<Course> courses = new List<Course>()
            {
                new Course("HTML", this.students),
                new Course("CSS", this.students),
                new Course("C#", this.students),
                new Course("JS", this.students),
            };

            School.School tu = new School.School("TU", courses);
            tu.RemoveCourse(null);
        }
示例#5
0
        public void TestRemoveCourse()
        {
            School.School s = new School.School("foo");
            Course c1 = new Course("Math");
            Course c2 = new Course("Biology");

            s.AddCourse(c1);
            s.AddCourse(c2);

            Course removed = s.RemoveCourse("Math");

            Assert.AreEqual(removed, c1);
        }
        public void TestRemoveCourseWithNullValue()
        {
            List <Course> courses = new List <Course>()
            {
                new Course("HTML", this.students),
                new Course("CSS", this.students),
                new Course("C#", this.students),
                new Course("JS", this.students),
            };

            School.School tu = new School.School("TU", courses);
            tu.RemoveCourse(null);
        }
示例#7
0
        public void TestRemoveCourse()
        {
            School.School s  = new School.School("foo");
            Course        c1 = new Course("Math");
            Course        c2 = new Course("Biology");

            s.AddCourse(c1);
            s.AddCourse(c2);

            Course removed = s.RemoveCourse("Math");

            Assert.AreEqual(removed, c1);
        }
        public void TestRemoveCourseWithNonexistingCourse()
        {
            List <Course> courses = new List <Course>()
            {
                new Course("HTML", this.students),
                new Course("CSS", this.students),
                new Course("C#", this.students),
                new Course("JS", this.students),
            };

            School.School tu   = new School.School("TU", courses);
            Course        algo = new Course("Algorithms", students);

            tu.RemoveCourse(algo);
        }
        public void TestRemoveCourseWithValidCourse()
        {  
            List<Course> courses = new List<Course>()
            {
                new Course("HTML", this.students),
                new Course("CSS", this.students),
                new Course("C#", this.students),
                new Course("JS", this.students),
            };

            School.School tu = new School.School("TU", courses);
            Course js = new Course("JS Part 2", students);
            
            tu.AddCourse(js);
            tu.RemoveCourse(js);

            Assert.IsFalse(tu.Courses.Contains(js));
        }
示例#10
0
        public void TestRemoveCourseWithValidCourse()
        {
            List <Course> courses = new List <Course>()
            {
                new Course("HTML", this.students),
                new Course("CSS", this.students),
                new Course("C#", this.students),
                new Course("JS", this.students),
            };

            School.School tu = new School.School("TU", courses);
            Course        js = new Course("JS Part 2", students);

            tu.AddCourse(js);
            tu.RemoveCourse(js);

            Assert.IsFalse(tu.Courses.Contains(js));
        }
示例#11
0
        public void TestRemoveMissingStudent()
        {
            School.School s  = new School.School("bar");
            Course        c  = new Course("Math");
            Course        c1 = new Course("alpha");
            Course        c2 = new Course("beta");

            s.AddCourse(c);
            s.AddCourse(c1);
            s.AddCourse(c2);

            Course removed = s.RemoveCourse("omega");
            bool   result  = removed == null;

            result = result && s.Courses[0] == c &&
                     s.Courses[1] == c1 && s.Courses[2] == c2;

            Assert.IsTrue(result);
        }
        public void TestRemoveCourseWithNonexistingCourse()
        {
            List<Course> courses = new List<Course>()
            {
                new Course("HTML", this.students),
                new Course("CSS", this.students),
                new Course("C#", this.students),
                new Course("JS", this.students),
            };

            School.School tu = new School.School("TU", courses);
            Course algo = new Course("Algorithms", students);
            tu.RemoveCourse(algo);
        }
示例#13
0
        public void TestSeveralCoursesWithSameName()
        {
            School.School s = new School.School("bar");
            Course c = new Course("Math");
            Course c1 = new Course("alpha");
            Course c2 = new Course("beta");
            Course c3 = new Course("gama");
            Course c4 = new Course("Math");
            Course c5 = new Course("Math");

            s.AddCourse(c);
            s.AddCourse(c1);
            s.AddCourse(c2);
            s.AddCourse(c3);
            s.AddCourse(c4);
            s.AddCourse(c5);

            Course removed = s.RemoveCourse("Math");

            bool result = removed == c;
            result = result && s.Courses[0] == c1 &&
                s.Courses[1] == c2 && s.Courses[2] == c3
                && s.Courses[3] == c4 && s.Courses[4] == c5;

            Assert.IsTrue(result);
        }
示例#14
0
        public void TestRemoveMissingStudent()
        {
            School.School s = new School.School("bar");
            Course c = new Course("Math");
            Course c1 = new Course("alpha");
            Course c2 = new Course("beta");

            s.AddCourse(c);
            s.AddCourse(c1);
            s.AddCourse(c2);

            Course removed = s.RemoveCourse("omega");
            bool result = removed == null;
            result = result && s.Courses[0] == c &&
                s.Courses[1] == c1 && s.Courses[2] == c2;

            Assert.IsTrue(result);
        }