示例#1
0
        public void GetPage_ShouldReturnPageImmediately_IfOnlyOnePageFound()
        {
            // Arrange
            var behaviour = new BehaviourBuilder()
                            .WithBehaviourType(EBehaviourType.GoToPage)
                            .WithPageSlug("test-test")
                            .Build();

            var page = new PageBuilder()
                       .WithBehaviour(behaviour)
                       .WithPageSlug("success")
                       .Build();

            var formSchema = new FormSchemaBuilder()
                             .WithBaseUrl("baseUrl")
                             .WithName("form name")
                             .WithStartPageUrl("page1")
                             .WithPage(page)
                             .Build();

            // Act
            formSchema.GetPage(_mockPageHelper.Object, "success");

            // Assert
            _mockPageHelper.Verify(_ => _.CheckRenderConditionsValid(It.IsAny <List <Page> >()), Times.Never);
        }
示例#2
0
        public void GetPage_ShouldReturnPageWithMatchingConditions()
        {
            // Arrange
            var behaviour = new BehaviourBuilder()
                            .WithBehaviourType(EBehaviourType.GoToPage)
                            .WithPageSlug("test-test")
                            .Build();

            var page = new PageBuilder()
                       .WithBehaviour(behaviour)
                       .WithPageSlug("success")
                       .WithRenderConditions(new Condition
            {
                QuestionId      = "testRadio",
                ConditionType   = ECondition.EqualTo,
                ComparisonValue = "yes"
            })
                       .Build();

            var page2 = new PageBuilder()
                        .WithBehaviour(behaviour)
                        .WithPageSlug("success")
                        .WithRenderConditions(new Condition
            {
                QuestionId      = "testRadio",
                ConditionType   = ECondition.EqualTo,
                ComparisonValue = "no"
            })
                        .WithRenderConditions(new Condition
            {
                QuestionId     = "testInput",
                ConditionType  = ECondition.EqualTo,
                ComparisonDate = "test"
            })
                        .Build();

            var formSchema = new FormSchemaBuilder()
                             .WithBaseUrl("baseUrl")
                             .WithName("form name")
                             .WithStartPageUrl("page1")
                             .WithPage(page)
                             .WithPage(page2)
                             .Build();

            _mockPageHelper.Setup(_ => _.GetPageWithMatchingRenderConditions(It.IsAny <List <Page> >())).Returns(page);

            // Act
            var result = formSchema.GetPage(_mockPageHelper.Object, "success");

            // Assert
            Assert.Equal(page, result);
        }