public IHttpActionResult GetCourses() { try { List <CourseDTO> courses = catalog.GetAllCourses().ToList(); return(Ok(courses)); } catch (ArgumentNullException ex) { var message = $"Courses collection is empty. {ex.Message}"; return(BadRequest(message)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void GetAllCoursesTest() { var sut = new CatalogBll(this.catalog.Object, this.converter.Object); var actual = sut.GetAllCourses(); this.catalog.Verify( cat => cat.GetAllCourses(), Times.AtLeastOnce()); Assert.That(actual, Is.All.InstanceOf(typeof(CourseDTO))); Assert.AreEqual(courses.Count, actual.Count()); }