public async Task Then_questiontag_is_reset()
        {
            await Handler.Handle(new ResetPageAnswersRequest(ApplicationId, SectionId, "1"), CancellationToken.None);

            var getApplicationDataResponse = await GetApplicationDataHandler.Handle(new GetApplicationDataRequest(ApplicationId), CancellationToken.None);

            var applicationData = JObject.Parse(getApplicationDataResponse.Value);
            var questionTag     = applicationData["Q1"];

            questionTag.Should().NotBeNull();
            questionTag.Value <string>().Should().BeNullOrEmpty();
        }
示例#2
0
        public async Task Then_questiontag_is_reset(string questionId, bool tagShouldExist)
        {
            await Handler.Handle(new ResetSectionAnswersRequest(ApplicationId, SequenceNo, SectionNo), CancellationToken.None);

            var getApplicationDataResponse = await GetApplicationDataHandler.Handle(new GetApplicationDataRequest(ApplicationId), CancellationToken.None);

            var applicationData = JObject.Parse(getApplicationDataResponse.Value);
            var questionTag     = applicationData[questionId];

            if (tagShouldExist)
            {
                // active tags should still exists
                questionTag.Should().NotBeNull();
                questionTag.Value <string>().Should().BeNullOrEmpty();
            }
            else
            {
                questionTag.Should().BeNull();
            }
        }
        public async Task SetUp()
        {
            DataContext = DataContextHelpers.GetInMemoryDataContext();
            Handler     = new ResetPageAnswersHandler(DataContext, new NotRequiredProcessor(), new TagProcessingService(DataContext));
            GetApplicationDataHandler = new GetApplicationDataHandler(DataContext);
            GetPageHandler            = new GetPageHandler(DataContext);

            ApplicationId = Guid.NewGuid();
            SectionId     = Guid.NewGuid();
            await DataContext.ApplicationSections.AddAsync(new ApplicationSection()
            {
                ApplicationId = ApplicationId,
                Id            = SectionId,
                QnAData       = new QnAData()
                {
                    Pages = new List <Page>
                    {
                        new Page()
                        {
                            PageId    = "1",
                            Questions = new List <Question> {
                                new Question()
                                {
                                    QuestionId = "Q1", QuestionTag = "Q1", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers> {
                                new PageOfAnswers {
                                    Answers = new List <Answer> {
                                        new Answer {
                                            QuestionId = "Q1", Value = "Yes"
                                        }
                                    }
                                }
                            },
                            Next = new List <Next>
                            {
                                new Next()
                                {
                                    Action = "NextPage", ReturnId = "2", Conditions = new List <Condition>()
                                    {
                                        new Condition {
                                            QuestionId = "Q1", MustEqual = "Yes"
                                        }
                                    }
                                },
                                new Next()
                                {
                                    Action = "NextPage", ReturnId = "3", Conditions = new List <Condition>()
                                    {
                                        new Condition {
                                            QuestionId = "Q1", MustEqual = "No"
                                        }
                                    }
                                }
                            },
                            Feedback = new List <Feedback> {
                                new Feedback {
                                    IsCompleted = true
                                }
                            },
                            Active   = true,
                            Complete = true
                        },
                        new Page()
                        {
                            PageId    = "2",
                            Questions = new List <Question> {
                                new Question()
                                {
                                    QuestionId = "Q2", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            Next          = new List <Next>
                            {
                                new Next()
                                {
                                    Action = "ReturnToSequence", Conditions = new List <Condition>()
                                },
                            },
                            Active            = true,
                            ActivatedByPageId = "1"
                        },
                        new Page()
                        {
                            PageId    = "3",
                            Questions = new List <Question> {
                                new Question()
                                {
                                    QuestionId = "Q3", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            Next          = new List <Next>
                            {
                                new Next()
                                {
                                    Action = "ReturnToSequence", Conditions = new List <Condition>()
                                }
                            },
                            Active            = false,
                            ActivatedByPageId = "1"
                        }
                    }
                }
            });

            await DataContext.Applications.AddAsync(new Data.Entities.Application()
            {
                Id = ApplicationId, ApplicationData = "{ \"Q1\" : \"Yes\" }"
            });

            await DataContext.SaveChangesAsync();
        }