Esempio n. 1
0
        public async Task JobProfileServiceGetByNameReturnsSuccess()
        {
            // arrange
            Guid documentId     = Guid.NewGuid();
            var  expectedResult = A.Fake <JobProfileModel>();

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

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

            // assert
            A.CallTo(() => repository.GetAsync(A <Expression <Func <JobProfileModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly();
            A.Equals(result, expectedResult);
        }
Esempio n. 2
0
        public async Task <IActionResult> Document(string article)
        {
            //AOP: These should be coded as an Aspect
            logService.LogInformation($"{nameof(Document)} has been called with: {article}");

            var jobProfileModel = await jobProfileService.GetByNameAsync(article).ConfigureAwait(false);

            if (jobProfileModel is null)
            {
                logService.LogWarning($"{nameof(Document)} has returned not found: {article}");
                return(NotFound());
            }

            var viewModel = mapper.Map <DocumentViewModel>(jobProfileModel);

            viewModel.Breadcrumb = BuildBreadcrumb(jobProfileModel);
            logService.LogInformation($"{nameof(Document)} has succeeded for: {article}");
            return(this.NegotiateContentResult(viewModel));
        }