Exemple #1
0
 private static void SetupMediator(GetHubQueryResult <Domain.Content.Hub> mediatorResult, Mock <IMediator> mockMediator, bool preview)
 {
     mockMediator.Setup(o => o.Send(It.Is <GetHubQuery>(r =>
                                                        r.Hub == HubName &&
                                                        r.Preview == preview), It.IsAny <CancellationToken>()))
     .ReturnsAsync(mediatorResult);
 }
Exemple #2
0
        public async Task And_Given_Valid_Hub_Then_The_Page_Is_Returned(
            GetHubQueryResult <Domain.Content.Hub> mediatorResult, [Frozen] Mock <IMediator> mockMediator,
            [Greedy] HubController controller)
        {
            SetupMediator(mediatorResult, mockMediator, false);

            var controllerResult = await InstantiateController <ViewResult>(controller);

            controllerResult.AssertThatTheObjectResultIsValid();
            controllerResult.AssertThatTheObjectValueIsValid <Page <Domain.Content.Hub> >();
            controllerResult.AssertThatTheReturnedViewIsCorrect("~/Views/Hubs/" + HubName + "Hub.cshtml");
        }
Exemple #3
0
        public async Task And_Is_Preview_Then_Given_Valid_Hub_Then_The_Page_Is_Returned(
            GetHubQueryResult <Domain.Content.Hub> mediatorResult, [Frozen] Mock <IMediator> mockMediator,
            [Greedy] HubController controller)
        {
            SetupMediator(mediatorResult, mockMediator, true);

            var controllerResult = await InstantiateController <ViewResult>(controller, true);

            controllerResult.AssertThatTheObjectResultIsValid();
            controllerResult.AssertThatTheObjectValueIsValid <Page <Domain.Content.Hub> >();
            controllerResult.AssertThatTheReturnedViewIsCorrect("~/Views/Hubs/" + HubName + "Hub.cshtml");
            mockMediator.Verify(o => o.Send(It.IsAny <GetSiteMapQuery>(), It.IsAny <CancellationToken>()), Times.Never);
        }
        public async Task And_Given_A_Valid_Hub_Then_The_Hub_Is_Returned(
            string hubName,
            GetHubQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] HubController controller)
        {
            SetupMediator(mediatorResult, mockMediator, hubName);

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

            var actualResult = controllerResult.Value as GetHubResponse;

            Assert.IsNotNull(actualResult);
            actualResult.Hub.Should().BeEquivalentTo(mediatorResult.PageModel);
        }
        public async Task And_Given_Invalid_Hub_And_A_Slug_Then_The_Article_Is_Not_Returned(
            string hubName,
            GetHubQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] HubController controller)
        {
            mediatorResult.PageModel = null;

            SetupMediator(new GetHubQueryResult(), mockMediator, hubName);

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

            var actualResult = controllerResult.Value as NotFoundResponse;

            Assert.IsNotNull(actualResult);
            actualResult.Message.Should().Be($"Hub not found for {hubName}");
        }
 private static void SetupMediator(GetHubQueryResult mediatorResult, Mock <IMediator> mockMediator, string hubName)
 {
     mockMediator
     .Setup(mediator => mediator.Send(It.Is <GetHubQuery>(c => c.Hub.Equals(hubName)), It.IsAny <CancellationToken>()))
     .ReturnsAsync(mediatorResult);
 }