public void Courses_ReturnsViewResult_Succesfully() { //Arrange // CourseService courseServiceStub = Substitute. CourseController controller = new CourseController(new CourseServiceStub(), null, null); //Act var response = controller.Courses(); //Assert Assert.IsType <ViewResult>(response); }
public void Courses_ReturnsViewResultWithCourseList_WhenCoursesExist() { //Arrange CourseController controller = new CourseController(new CourseServiceStub(), null, null); //Act var response = controller.Courses(); //Assert ViewResult viewResult = response as ViewResult; List <Course> actuals = Assert.IsAssignableFrom <List <Course> >(viewResult.ViewData.Model); Assert.Equal(2, actuals.Count); }
public void Courses_ReturnsViewResult_WithListOfCourses() { // Arrange var courseServiceMock = Substitute.For <CourseService>(); courseServiceMock.GetAllCourses().Returns(GetCoursesList()); var controller = new CourseController(courseServiceMock, null); // Act var result = controller.Courses(); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <List <Course> >(viewResult.ViewData.Model); Assert.Equal(2, model.Count); }
public void Courses_ReturnsViewResult_WithListOfCourses() { // Arrange var courseSericeMock = Substitute.For <CourseService>(); courseSericeMock.GetAllCourses().Returns(new List <Course>() { new Course(), new Course() }); var controller = new CourseController(courseSericeMock, null, null, null, null); //Act var result = controller.Courses(); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <IEnumerable <Course> >(viewResult.Model); }