Example #1
0
        public async Task SegmentServiceGetByNameReturnsSuccess()
        {
            // arrange
            var expectedResult = A.Fake <JobProfileOverviewSegmentModel>();

            A.CallTo(() => repository.GetAsync(A <Expression <Func <JobProfileOverviewSegmentModel, bool> > > .Ignored)).Returns(expectedResult);

            // act
            var result = await jobProfileOverviewSegmentService.GetByNameAsync("article-name").ConfigureAwait(false);

            // assert
            A.CallTo(() => repository.GetAsync(A <Expression <Func <JobProfileOverviewSegmentModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly();
            Assert.Equal(expectedResult, result);
        }
        public async Task <IActionResult> Document(string article)
        {
            logService.LogInformation($"{DocumentActionName} has been called with: {article}");

            var model = await jobProfileOverviewSegmentService.GetByNameAsync(article).ConfigureAwait(false);

            if (model != null)
            {
                var viewModel = mapper.Map <BodyViewModel>(model);

                viewModel.Data.Breadcrumb = BuildBreadcrumb(model, SegmentRoutePrefix);

                logService.LogInformation($"{DocumentActionName} has succeeded for: {article}");

                return(View(nameof(Document), viewModel));
            }

            logService.LogWarning($"{DocumentActionName} has returned no content for: {article}");

            return(NoContent());
        }