public async Task SegmentServiceGetByIdReturnsSuccess() { // arrange var documentId = Guid.NewGuid(); var expectedResult = A.Fake <JobProfileOverviewSegmentModel>(); A.CallTo(() => repository.GetAsync(A <Expression <Func <JobProfileOverviewSegmentModel, bool> > > .Ignored)).Returns(expectedResult); // act var result = await jobProfileOverviewSegmentService.GetByIdAsync(documentId).ConfigureAwait(false); // assert A.CallTo(() => repository.GetAsync(A <Expression <Func <JobProfileOverviewSegmentModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly(); Assert.Equal(expectedResult, result); }
public async Task <IActionResult> Body(Guid documentId) { logService.LogInformation($"{BodyActionName} has been called with: {documentId}"); var model = await jobProfileOverviewSegmentService.GetByIdAsync(documentId).ConfigureAwait(false); if (model != null) { var viewModel = mapper.Map <BodyViewModel>(model); viewModel.Data.Breadcrumb = BuildBreadcrumb(model, JobProfileRoutePrefix); logService.LogInformation($"{BodyActionName} has succeeded for: {documentId}"); var apiModel = mapper.Map <OverviewApiModel>(model.Data); apiModel.Url = model.CanonicalName; return(this.NegotiateContentResult(viewModel, apiModel)); } logService.LogWarning($"{BodyActionName} has returned no content for: {documentId}"); return(NoContent()); }