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

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

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

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

            var howToBecomeSegmentModel = await howToBecomeSegmentService.GetByNameAsync(article).ConfigureAwait(false);

            if (howToBecomeSegmentModel != null)
            {
                var viewModel = mapper.Map <DocumentViewModel>(howToBecomeSegmentModel);

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

                return(View(viewModel));
            }

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

            return(NoContent());
        }