public void When_Perform_Post_Request_To_EditSchool_Return_Error_Response() { // Arrange var error = "error"; var editSchoolModel = new EditSchoolModel { City = "city" }; var apiResult = new OdsApiResult { ErrorMessage = error }; _mockMapper.Setup(x => x.Map <School>(It.IsAny <EditSchoolModel>())) .Returns(new School()); _mockOdsApiFacade.Setup(x => x.EditSchool(It.IsAny <School>())).Returns(apiResult); _mockOdsApiFacadeFactory.Setup(x => x.Create()) .Returns(Task.FromResult(_mockOdsApiFacade.Object)); _controller = new EducationOrganizationsController(_mockOdsApiFacadeFactory.Object, _mockMapper.Object, _mockInstanceContext.Object); // Act var result = _controller.EditSchool(editSchoolModel).Result as ContentResult; // Assert result.ShouldNotBeNull(); result.Content.ShouldContain(error); }
public void When_Perform_Post_Request_To_EditSchool_Return_Success_Response() { // Arrange var editSchoolModel = new EditSchoolModel { City = "city" }; _mockMapper.Setup(x => x.Map <School>(It.IsAny <EditSchoolModel>())) .Returns(new School()); _mockOdsApiFacade.Setup(x => x.EditSchool(It.IsAny <School>())).Returns(new OdsApiResult()); _mockOdsApiFacadeFactory.Setup(x => x.Create()) .Returns(Task.FromResult(_mockOdsApiFacade.Object)); _controller = new EducationOrganizationsController(_mockOdsApiFacadeFactory.Object, _mockMapper.Object, _mockInstanceContext.Object, _tabDisplayService.Object, _inferExtensionDetails); // Act var result = _controller.EditSchool(editSchoolModel).Result as ContentResult; // Assert result.ShouldNotBeNull(); result.Content.ShouldContain("School Updated"); }