public async Task ContentPageServiceGetByNameReturnsSuccess()
        {
            // arrange
            var expectedResult = A.Fake <JobCategory>();

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

            // act
            var result = await contentPageService.GetByCanonicalNameAsync(CanonicalName).ConfigureAwait(false);

            // assert
            A.CallTo(() => repository.GetAsync(A <Expression <Func <JobCategory, bool> > > .Ignored)).MustHaveHappenedOnceExactly();
            Assert.Equal(result, expectedResult);
        }
        private async Task <JobCategory?> GetContentPageAsync(string?article)
        {
            const string defaultArticleName = "home";
            var          articleName        = string.IsNullOrWhiteSpace(article) ? defaultArticleName : article;

            var contentPageModel = await jobCategoryPageContentService.GetByCanonicalNameAsync(articleName).ConfigureAwait(false);

            return(contentPageModel);
        }
Ejemplo n.º 3
0
        public async Task PagesControllerCallsContentPageServiceUsingPagesRouteForOkResult(string route, string article, string actionMethod)
        {
            // Arrange
            var controller     = BuildController(route);
            var expectedResult = new JobCategory()
            {
                Title = "Care Worker"
            };

            A.CallTo(() => fakeJobCategoryPageContentService.GetByCanonicalNameAsync(A <string> .Ignored)).Returns(expectedResult);

            // Act
            var result = await RunControllerAction(controller, article, actionMethod).ConfigureAwait(false);

            // Assert
            Assert.IsType <OkObjectResult>(result);
            A.CallTo(() => fakeJobCategoryPageContentService.GetByCanonicalNameAsync(A <string> .Ignored)).MustHaveHappenedOnceExactly();

            controller.Dispose();
        }