public async Task GetByIdReturnsSuccess() { // arrange var documentId = Guid.NewGuid(); var expectedResult = A.Fake <JobProfileSkillSegmentModel>(); A.CallTo(() => repository.GetAsync(A <Expression <Func <JobProfileSkillSegmentModel, bool> > > .Ignored)).Returns(expectedResult); // act var result = await skillSegmentService.GetByIdAsync(documentId).ConfigureAwait(false); // assert A.CallTo(() => repository.GetAsync(A <Expression <Func <JobProfileSkillSegmentModel, 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 skillSegmentService.GetByIdAsync(documentId).ConfigureAwait(false); if (model != null) { var viewModel = mapper.Map <BodyViewModel>(model); logService.LogInformation($"{BodyActionName} has succeeded for: {documentId}"); var apiModel = mapper.Map <WhatItTakesApiModel>(model.Data); return(this.NegotiateContentResult(viewModel, apiModel)); } logService.LogWarning($"{BodyActionName} has returned no content for: {documentId}"); return(NoContent()); }