Esempio n. 1
0
        public void AssignPreReqErrorTest2()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<ICourseRepository>();
            var courseService = new CourseService(mockRepository.Object);
            int? nullInt = null;
            //// Act
            courseService.AssignPreReq(1, (int)nullInt, ref errors);

            //// Assert course object not null
            Assert.AreEqual(1, errors.Count);
        }
Esempio n. 2
0
        public string AssignPreReq(int cId, int pr_Id)
        {
            var errors = new List<string>();
            var repository = new CourseRepository(this.entities);
            var service = new CourseService(repository);
            service.AssignPreReq(cId, pr_Id, ref errors);

            if (errors.Count == 0)
            {
                return "ok";
            }

            return "error";
        }
Esempio n. 3
0
        public void AssignPreReqPassTest()
        {
            //// Arranage
            string courseName1 = "Test5";
            string courseName2 = "Test6";
            string courseName3 = "Test7";
            var errors1 = new List<string>();
            var errors2 = new List<string>();
            var mockRepository = new Mock<ICourseRepository>();
            var courseService = new CourseService(mockRepository.Object);
            var course1 = new Course { Title = courseName1 };
            var course2 = new Course { Title = courseName2 };
            var course3 = new Course { Title = courseName3 };
            courseService.InsertCourse(course1, ref errors1);
            courseService.InsertCourse(course2, ref errors1);
            courseService.InsertCourse(course3, ref errors1);

            //// Act
            courseService.AssignPreReq(1, 2, ref errors2);

            //// Assert
            Assert.AreEqual(0, errors2.Count);
        }