예제 #1
0
        public async Task SegmentServiceGetAllListReturnsSuccess()
        {
            // arrange
            var expectedResults = A.CollectionOfFake <HowToBecomeSegmentModel>(2);

            A.CallTo(() => repository.GetAllAsync()).Returns(expectedResults);

            // act
            var results = await howToBecomeSegmentService.GetAllAsync().ConfigureAwait(false);

            // assert
            A.CallTo(() => repository.GetAllAsync()).MustHaveHappenedOnceExactly();
            Assert.Equal(expectedResults, results);
        }
        public async Task <IActionResult> Index()
        {
            logService.LogInformation($"{IndexActionName} has been called");

            var viewModel = new IndexViewModel();
            var howToBecomeSegmentModels = await howToBecomeSegmentService.GetAllAsync().ConfigureAwait(false);

            if (howToBecomeSegmentModels != null)
            {
                viewModel.Documents = (from a in howToBecomeSegmentModels.OrderBy(o => o.CanonicalName)
                                       select mapper.Map <IndexDocumentViewModel>(a)).ToList();

                logService.LogInformation($"{IndexActionName} has succeeded");
            }
            else
            {
                logService.LogWarning($"{IndexActionName} has returned with no results");
            }

            return(View(viewModel));
        }