Beispiel #1
0
        // GET: DeltaReport
        public async Task <ActionResult> Index()
        {
            var deltaReports = await deltaReportService.GetSummaryAsync().ConfigureAwait(false);

            var viewModels = mapper.Map <List <DeltaReportSummaryItemViewModel> >(deltaReports);

            logger.LogInformation($"Retrieved {viewModels.Count} delta reports");
            return(View(viewModels));
        }
Beispiel #2
0
        public async Task DeltaReportControllerIndexHtmlReturnsSuccess()
        {
            // Arrange
            const int resultsCount    = 2;
            var       expectedResults = A.CollectionOfFake <DeltaReportSummaryItemModel>(resultsCount);

            using var controller = BuildPagesController();

            A.CallTo(() => fakeDeltaReportService.GetSummaryAsync()).Returns(expectedResults);
            A.CallTo(() => fakeMapper.Map <List <DeltaReportSummaryItemViewModel> >(A <List <DeltaReportSummaryItemModel> > .Ignored)).Returns(A.Fake <List <DeltaReportSummaryItemViewModel> >());

            // Act
            var result = await controller.Index().ConfigureAwait(false);

            // Assert
            A.CallTo(() => fakeDeltaReportService.GetSummaryAsync()).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeMapper.Map <List <DeltaReportSummaryItemViewModel> >(A <List <DeltaReportSummaryItemModel> > .Ignored)).MustHaveHappenedOnceExactly();

            var viewResult = Assert.IsType <ViewResult>(result);
            var viewModels = Assert.IsAssignableFrom <List <DeltaReportSummaryItemViewModel> >(viewResult.ViewData.Model);

            A.Equals(resultsCount, viewModels !.Count);
        }