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