public async Task PagesControllerCallsContentPageServiceUsingPagesRouteForOkResult(string route, int soc, string actionMethod) { // Arrange var controller = BuildController(route); var expectedResult = new JobGroupModel() { Title = "A title", }; var expectedResults = new List <JobGroupModel> { expectedResult }; var expectedViewModel = new DocumentViewModel { Title = "A title", Head = A.Dummy <HeadViewModel>(), }; A.CallTo(() => FakeJobGroupDocumentService.GetAllAsync(A <string> .Ignored)).Returns(expectedResults); A.CallTo(() => FakeJobGroupDocumentService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).Returns(expectedResult); A.CallTo(() => FakeMapper.Map <DocumentViewModel>(A <JobGroupModel> .Ignored)).Returns(expectedViewModel); // Act var result = await RunControllerAction(controller, soc, actionMethod).ConfigureAwait(false); // Assert Assert.IsType <OkObjectResult>(result); A.CallTo(() => FakeJobGroupDocumentService.GetAllAsync(A <string> .Ignored)).MustHaveHappenedOnceOrLess(); A.CallTo(() => FakeJobGroupDocumentService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceOrLess(); controller.Dispose(); }
public async Task ApiControllerGetDetailByIdReturnsSuccess() { // Arrange var getDetailResponse = new JobGroupModel { Id = Guid.NewGuid(), Soc = 1, Title = "A title 1", }; var controller = BuildApiController(); A.CallTo(() => FakeJobGroupDocumentService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).Returns(getDetailResponse); // Act var result = await controller.Get(Guid.NewGuid()).ConfigureAwait(false); // Assert A.CallTo(() => FakeJobGroupDocumentService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); Assert.Equal(getDetailResponse, result); }