public async Task SetUp()
        {
            QnaDataContext = DataContextHelpers.GetInMemoryDataContext();

            NotRequiredProcessor = new NotRequiredProcessor();
            TagProcessingService = new TagProcessingService(QnaDataContext);
            SetAnswersBase       = new SetAnswersBase(QnaDataContext, NotRequiredProcessor, TagProcessingService, null);

            ApplicationId = Guid.NewGuid();

            ApplicationDataJson = JsonConvert.SerializeObject(new
            {
                OrgType = "OrgType1"
            });

            await QnaDataContext.Applications.AddAsync(new Data.Entities.Application {
                Id = ApplicationId, ApplicationData = ApplicationDataJson
            });

            await QnaDataContext.SaveChangesAsync();

            NextAction = new Next {
                Action = "NextPage", ReturnId = "2"
            };
        }
        public async Task Subsequent_nextAction_further_down_the_branch_is_returned()
        {
            var pageThreeNextAction = new Next
            {
                Action   = "NextPage",
                ReturnId = "4"
            };

            var section = new ApplicationSection
            {
                ApplicationId = ApplicationId,
                QnAData       = new QnAData {
                    Pages = new List <Page>
                    {
                        new Page
                        {
                            PageId = "2",
                            NotRequiredConditions = new List <NotRequiredCondition> {
                                new NotRequiredCondition()
                                {
                                    Field = "OrgType", IsOneOf = new string[] { "OrgType1", "OrgType2" }
                                }
                            },
                            Next = new List <Next> {
                                new Next {
                                    Action   = "NextPage",
                                    ReturnId = "3"
                                }
                            }
                        },
                        new Page
                        {
                            PageId = "3",
                            NotRequiredConditions = new List <NotRequiredCondition> {
                                new NotRequiredCondition()
                                {
                                    Field = "OrgType", IsOneOf = new string[] { "OrgType1" }
                                }
                            },
                            Next = new List <Next> {
                                pageThreeNextAction
                            }
                        },
                        new Page
                        {
                            PageId = "4",
                            NotRequiredConditions = null
                        }
                    }
                }
            };

            var applicationData = JObject.Parse(ApplicationDataJson);
            var nextActionAfterFindingNextAction = SetAnswersBase.FindNextRequiredAction(section, NextAction, applicationData);

            nextActionAfterFindingNextAction.Should().BeEquivalentTo(pageThreeNextAction);
        }
        public void And_one_of_the_nextactions_has_condition_null_Then_that_action_is_returned()
        {
            var actionWithNoCondition = new Next
            {
                Action     = "NextPage",
                ReturnId   = "3",
                Conditions = null
            };

            var section = new ApplicationSection
            {
                ApplicationId = ApplicationId,
                QnAData       = new QnAData {
                    Pages = new List <Page>
                    {
                        new Page
                        {
                            PageId = "2",
                            NotRequiredConditions = new List <NotRequiredCondition> {
                                new NotRequiredCondition()
                                {
                                    Field = "OrgType", IsOneOf = new string[] { "OrgType1", "OrgType2" }
                                }
                            },
                            Next = new List <Next>
                            {
                                new Next
                                {
                                    Action     = "NextPage",
                                    ReturnId   = "12",
                                    Conditions = new List <Condition>()
                                },
                                actionWithNoCondition,
                                new Next
                                {
                                    Action     = "NextPage",
                                    ReturnId   = "14",
                                    Conditions = new List <Condition>()
                                }
                            }
                        },
                        new Page
                        {
                            PageId = "3",
                            NotRequiredConditions = null
                        }
                    }
                }
            };

            var applicationData = JObject.Parse(ApplicationDataJson);
            var nextActionAfterFindingNextAction = SetAnswersBase.FindNextRequiredAction(section, NextAction, applicationData);

            nextActionAfterFindingNextAction.Should().BeEquivalentTo(actionWithNoCondition);
        }
        public void Then_the_page_is_marked_as_not_required()
        {
            var section = new ApplicationSection
            {
                ApplicationId = ApplicationId,
                QnAData       = new QnAData
                {
                    Pages = new List <Page>
                    {
                        new Page
                        {
                            PageId = "2",
                            NotRequiredConditions = new List <NotRequiredCondition> {
                                new NotRequiredCondition()
                                {
                                    Field = "OrgType", IsOneOf = new string[] { "OrgType1", "OrgType2" }
                                }
                            },
                            Next = new List <Next>
                            {
                                new Next
                                {
                                    Action     = "NextPage",
                                    ReturnId   = "12",
                                    Conditions = new List <Condition>()
                                }
                            }
                        },
                        new Page
                        {
                            PageId = "3",
                            NotRequiredConditions = null
                        }
                    }
                }
            };

            var applicationData = JObject.Parse(ApplicationDataJson);

            SetAnswersBase.FindNextRequiredAction(section, NextAction, applicationData);
            Assert.IsTrue(section.QnAData.Pages.First().NotRequired);
        }
Exemplo n.º 5
0
        public async Task For_empty_NotRequiredConditions_then_the_same_nextAction_is_returned()
        {
            var section = new ApplicationSection
            {
                ApplicationId = ApplicationId,
                QnAData       = new QnAData {
                    Pages = new List <Page>
                    {
                        new Page
                        {
                            PageId = "2",
                            NotRequiredConditions = new List <NotRequiredCondition>()
                        }
                    }
                }
            };

            var applicationData = JObject.Parse(ApplicationDataJson);
            var nextActionAfterFindingNextAction = SetAnswersBase.FindNextRequiredAction(section, NextAction, applicationData);

            nextActionAfterFindingNextAction.Should().BeEquivalentTo(NextAction);
        }