コード例 #1
0
        public async Task And_Given_Invalid_Hub_And_A_Slug_Then_The_Landing_Page_Is_Not_Returned(
            string hubName,
            string slugName,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] LandingPageController controller)
        {
            SetupMediator(new GetLandingPageQueryResult(), mockMediator, hubName, slugName);

            var controllerResult = await InstantiateController <NotFoundObjectResult>(controller, hubName, slugName);

            var actualResult = controllerResult.Value as NotFoundResponse;

            Assert.IsNotNull(actualResult);
            actualResult.Message.Should().Be($"Landing page not found for {hubName}/{slugName}");
        }
コード例 #2
0
        public async Task And_Given_A_Valid_Hub_And_A_Slug_Then_The_Landing_Page_Is_Returned(
            string hubName,
            string slugName,
            GetLandingPageQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] LandingPageController controller)
        {
            SetupMediator(mediatorResult, mockMediator, hubName, slugName);

            var controllerResult = await InstantiateController <OkObjectResult>(controller, hubName, slugName);

            var actualResult = controllerResult.Value as GetLandingPageResponse;

            Assert.IsNotNull(actualResult);
            actualResult.LandingPage.Should().BeEquivalentTo(mediatorResult.PageModel);
        }
        public async Task Then_The_Landing_Page_Is_Returned_From_The_Mediator_Query(
            string hubName,
            string slugName,
            GetPreviewLandingPageQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] LandingPageController controller)
        {
            mockMediator
            .Setup(x => x.Send(
                       It.Is <GetPreviewLandingPageQuery>(c => c.Hub.Equals(hubName) && c.Slug.Equals(slugName)), It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var actual = await controller.GetPreviewLandingPage(hubName, slugName) as OkObjectResult;

            Assert.IsNotNull(actual);
            var actualResult = actual.Value as GetLandingPageResponse;

            Assert.IsNotNull(actualResult);
            actualResult.LandingPage.Should().BeEquivalentTo(mediatorResult.PageModel);
        }
        public async Task Then_The_NotFound_Is_Returned_If_No_Result(
            string hubName,
            string slugName,
            GetPreviewLandingPageQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] LandingPageController controller)
        {
            mockMediator
            .Setup(x => x.Send(
                       It.Is <GetPreviewLandingPageQuery>(c => c.Hub.Equals(hubName) && c.Slug.Equals(slugName)), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetPreviewLandingPageQueryResult
            {
                PageModel = null
            });

            var actual = await controller.GetPreviewLandingPage(hubName, slugName) as NotFoundObjectResult;

            Assert.IsNotNull(actual);
            var actualResult = actual.Value as NotFoundResponse;

            Assert.IsNotNull(actualResult);
            actualResult.Message.Should().Be($"Preview landing page not found for {hubName}/{slugName}");
        }
コード例 #5
0
        private static async Task <T> InstantiateController <T>(LandingPageController controller, string hubName, string slugName)
        {
            var controllerResult = (T)await controller.GetLandingPageAsync(hubName, slugName, CancellationToken.None);

            return(controllerResult);
        }