public async Task DeltaReportControllerSocIndexHtmlReturnsSuccess() { // Arrange var expectedResult = A.Fake <DeltaReportModel>(); using var controller = BuildPagesController(); var expectedViewModel = new DeltaReportViewModel { Id = Guid.NewGuid(), SocImportedCount = 11, SocUnchangedCount = 5, SocAdditionCount = 2, SocUpdateCount = 1, SocDeletionCount = 3, }; A.CallTo(() => fakeDeltaReportService.GetDetailAsync(A <Guid> .Ignored)).Returns(expectedResult); A.CallTo(() => fakeMapper.Map <DeltaReportViewModel>(A <DeltaReportModel> .Ignored)).Returns(expectedViewModel); // Act var result = await controller.SocIndex(expectedViewModel.Id.Value).ConfigureAwait(false); // Assert A.CallTo(() => fakeDeltaReportService.GetDetailAsync(A <Guid> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => fakeMapper.Map <DeltaReportViewModel>(A <DeltaReportModel> .Ignored)).MustHaveHappenedOnceExactly(); var viewResult = Assert.IsType <ViewResult>(result); _ = Assert.IsAssignableFrom <DeltaReportViewModel>(viewResult.ViewData.Model); var viewModel = viewResult.ViewData.Model as DeltaReportViewModel; Assert.Equal(expectedViewModel, viewModel); }
// GET: DeltaReport/SocIndex/guid public async Task <ActionResult> SocIndex(Guid id) { var deltaReport = await deltaReportService.GetDetailAsync(id).ConfigureAwait(false); if (deltaReport != null) { var viewModel = mapper.Map <DeltaReportViewModel>(deltaReport); logger.LogInformation($"Retrieved Delta report for: {id}"); return(View(viewModel)); } logger.LogWarning($"Delta report not found for: {id}"); return(NotFound()); }