public List<Course> GetCourseList()
        {
            var service = new CourseService(new CourseRepository());
            var errors = new List<string>();

            //// we could log the errors here if there are any...
            return service.GetCourseList(ref errors);
        }
 /// <summary>
 /// Get a list of available courses
 /// </summary>
 /// <param name="errors">error list</param>
 /// <returns>list of courses</returns>
 public List<Course> GetCourseList(ref List<string> errors)
 {
     var service = new CourseService(new CourseRepository());
     return service.GetCourseList(ref errors);
 }
Exemple #3
0
        public void GetCourseListTest()
        {
            //// Arrange
            var errors = new List<string>();

            Mock<ICourseRepository> mockRepository = new Mock<ICourseRepository>();
            CourseService courseservice = new CourseService(mockRepository.Object);

            List<Course> crl = new List<Course>();
            crl.Add(new Course { CourseId = 99, Title = "T", Description = "Test" });

            mockRepository.Setup(x => x.GetCourseList(ref errors)).Returns(crl);

            //// Act
            Course temp = courseservice.GetCourseList(ref errors)[0];

            //// Assert
            Assert.AreEqual(0, errors.Count);
            Assert.AreEqual(99, temp.CourseId);
        }