Ejemplo n.º 1
0
 public SetAnswersBase(QnaDataContext dataContext, INotRequiredProcessor notRequiredProcessor, ITagProcessingService tagProcessingService, IAnswerValidator answerValidator)
 {
     _dataContext          = dataContext;
     _notRequiredProcessor = notRequiredProcessor;
     _tagProcessingService = tagProcessingService;
     _answerValidator      = answerValidator;
 }
Ejemplo n.º 2
0
 public StorageMigrationController(QnaDataContext dataContext, IOptions <FileStorageConfig> fileStorageConfig, IEncryptionService encryptionService, ILogger <StorageMigrationController> log)
 {
     _dataContext       = dataContext;
     _fileStorageConfig = fileStorageConfig;
     _encryptionService = encryptionService;
     _log = log;
 }
        public async Task SetUp()
        {
            var dbContextOptions = new DbContextOptionsBuilder <QnaDataContext>()
                                   .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                   .Options;

            var context = new QnaDataContext(dbContextOptions);

            ApplicationId = Guid.NewGuid();

            context.ApplicationSequences.AddRange(new[]
            {
                new ApplicationSequence {
                    ApplicationId = ApplicationId, IsActive = false, SequenceNo = 1
                },
                new ApplicationSequence {
                    ApplicationId = ApplicationId, IsActive = true, SequenceNo = 2
                },
                new ApplicationSequence {
                    ApplicationId = Guid.NewGuid(), IsActive = true, SequenceNo = 1
                }
            });


            await context.Applications.AddAsync(new Data.Entities.Application()
            {
                Id = ApplicationId
            });

            await context.SaveChangesAsync();

            var mapper = new Mapper(new MapperConfiguration(config => { config.AddMaps(AppDomain.CurrentDomain.GetAssemblies()); }));

            Handler = new GetCurrentSequenceHandler(context, mapper);
        }
        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 SetUp()
        {
            var dbContextOptions = new DbContextOptionsBuilder <QnaDataContext>()
                                   .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                   .Options;

            var context = new QnaDataContext(dbContextOptions);

            ApplicationId = Guid.NewGuid();

            context.Applications.Add(new Data.Entities.Application {
                Id = ApplicationId, ApplicationData = "{}"
            });

            context.ApplicationSequences.AddRange(new[]
            {
                new ApplicationSequence {
                    ApplicationId = ApplicationId, IsActive = false, SequenceNo = 1
                },
                new ApplicationSequence {
                    ApplicationId = ApplicationId, IsActive = true, SequenceNo = 2
                }
            });

            context.ApplicationSections.AddRange(new[]
            {
                new ApplicationSection {
                    ApplicationId = ApplicationId, SequenceNo = 1, SectionNo = 1, QnAData = new QnAData {
                        Pages = new List <Page>()
                    }
                },
                new ApplicationSection {
                    ApplicationId = ApplicationId, SequenceNo = 1, SectionNo = 2, QnAData = new QnAData {
                        Pages = new List <Page>()
                    }
                },
                new ApplicationSection {
                    ApplicationId = ApplicationId, SequenceNo = 2, SectionNo = 1, QnAData = new QnAData {
                        Pages = new List <Page>()
                    }
                }
            });

            await context.SaveChangesAsync();

            var mapper = new Mapper(new MapperConfiguration(config => { config.AddMaps(AppDomain.CurrentDomain.GetAssemblies()); }));

            Handler = new GetSectionsHandler(context, mapper, new NotRequiredProcessor());
        }
Ejemplo n.º 6
0
        public async Task Then_only_live_workflows_are_returned()
        {
            var dbContextOptions = new DbContextOptionsBuilder <QnaDataContext>()
                                   .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                                   .Options;

            var context = new QnaDataContext(dbContextOptions);

            var projectId = Guid.NewGuid();

            context.Workflows.AddRange(new []
            {
                new Workflow()
                {
                    Id = Guid.NewGuid(), Status = WorkflowStatus.Live, ProjectId = projectId
                },
                new Workflow()
                {
                    Id = Guid.NewGuid(), ProjectId = projectId
                },
                new Workflow()
                {
                    Id = Guid.NewGuid(), Status = WorkflowStatus.Live, ProjectId = projectId
                },
            });

            await context.SaveChangesAsync();

            var mapper = new Mapper(new MapperConfiguration(config => { config.AddMaps(AppDomain.CurrentDomain.GetAssemblies()); }));

            var handler = new GetWorkflowsHandler(context, mapper);

            var results = await handler.Handle(new GetWorkflowsRequest(projectId), CancellationToken.None);

            results.Value.Should().BeOfType <List <Workflow> >();
            results.Value.Count.Should().Be(2);
        }
        public async Task SetUp()
        {
            _dataContext = DataContextHelpers.GetInMemoryDataContext();

            _applicationId = Guid.NewGuid();
            _sectionId     = Guid.NewGuid();

            _feedbackId = Guid.NewGuid();
            var section = new ApplicationSection
            {
                ApplicationId = _applicationId,
                Id            = _sectionId,
                QnAData       = new QnAData
                {
                    Pages = new List <Page>
                    {
                        new Page
                        {
                            PageId   = "1",
                            Feedback = new List <Feedback>
                            {
                                new Feedback
                                {
                                    Id = _feedbackId
                                }
                            }
                        }
                    }
                }
            };

            await _dataContext.ApplicationSections.AddAsync(section);

            await _dataContext.SaveChangesAsync();

            _handler = new UpsertFeedbackHandler(_dataContext);
        }
Ejemplo n.º 8
0
 public ResetSectionAnswersHandler(QnaDataContext dataContext, IMediator mediator, INotRequiredProcessor notRequiredProcessor, ITagProcessingService tagProcessingService)
     : base(dataContext, notRequiredProcessor, tagProcessingService, null)
 {
     _mediator = mediator;
 }
 public DeleteFeedbackHandler(QnaDataContext dataContext)
 {
     _dataContext = dataContext;
 }
 public CompleteFeedbackWithinSequenceHandler(QnaDataContext dataContext)
 {
     _dataContext = dataContext;
 }
 public CreateWorkflowSequenceHandler(QnaDataContext dataContext)
 {
     _dataContext = dataContext;
 }
 public GetPageHandler(QnaDataContext dataContext)
 {
     _dataContext = dataContext;
 }
Ejemplo n.º 13
0
 public RemovePageAnswerHandler(QnaDataContext dataContext) : base(dataContext)
 {
     _dataContext = dataContext;
 }
 public UpsertWorkflowSequenceHandler(QnaDataContext dataContext)
 {
     _dataContext = dataContext;
 }
        public async Task SetUp()
        {
            DataContext = DataContextHelpers.GetInMemoryDataContext();
            var validator = Substitute.For <IAnswerValidator>();

            NotRequiredProcessor = new NotRequiredProcessor();
            TagProcessingService = new TagProcessingService(DataContext);

            validator.Validate(Arg.Any <List <Answer> >(), Arg.Any <Page>()).Returns(new List <KeyValuePair <string, string> >());

            Handler = new SetPageAnswersHandler(DataContext, validator, NotRequiredProcessor, TagProcessingService);

            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", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            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 = "4", Conditions = new List <Condition>()
                                    {
                                        new Condition {
                                            QuestionId = "Q1", MustEqual = "No"
                                        }
                                    }
                                }
                            },
                            Active = 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 = "NextPage", ReturnId = "3", Conditions = new List <Condition>()
                                    {
                                        new Condition {
                                            QuestionId = "Q2", MustEqual = "Yes"
                                        }
                                    }
                                },
                                new Next()
                                {
                                    Action = "NextPage", ReturnId = "5", Conditions = new List <Condition>()
                                    {
                                        new  Condition {
                                            QuestionId = "Q2", MustEqual = "No"
                                        }
                                    }
                                }
                            },
                            Active            = false,
                            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 = "NextPage", ReturnId = "7"
                                }
                            },
                            Active            = false,
                            ActivatedByPageId = "2"
                        },
                        new Page()
                        {
                            PageId    = "4",
                            Questions = new List <Question> {
                                new Question()
                                {
                                    QuestionId = "Q4", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            Next          = new List <Next>
                            {
                                new Next()
                                {
                                    Action = "NextPage", ReturnId = "6"
                                }
                            },
                            Active            = false,
                            ActivatedByPageId = "1"
                        },
                        new Page()
                        {
                            PageId    = "5",
                            Questions = new List <Question> {
                                new Question()
                                {
                                    QuestionId = "Q5", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            Next          = new List <Next>
                            {
                                new Next()
                                {
                                    Action = "NextPage", ReturnId = "7"
                                }
                            },
                            Active            = false,
                            ActivatedByPageId = "2"
                        },
                        new Page()
                        {
                            PageId    = "6",
                            Questions = new List <Question> {
                                new Question()
                                {
                                    QuestionId = "Q6", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            Next          = new List <Next>
                            {
                                new Next()
                                {
                                    Action = "NextPage", ReturnId = "8"
                                }
                            },
                            Active            = false,
                            ActivatedByPageId = "1"
                        },
                        new Page()
                        {
                            PageId    = "7",
                            Questions = new List <Question> {
                                new Question()
                                {
                                    QuestionId = "Q7", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            Next          = new List <Next>
                            {
                                new Next()
                                {
                                    Action = "NextPage", ReturnId = "8"
                                }
                            },
                            Active            = false,
                            ActivatedByPageId = "1"
                        },
                        new Page()
                        {
                            PageId    = "8",
                            Questions = new List <Question> {
                                new Question()
                                {
                                    QuestionId = "Q8", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            Next          = new List <Next>
                            {
                                new Next()
                                {
                                    Action = "NextPage", ReturnId = "9"
                                }
                            },
                            Active = true
                        },
                        new Page()
                        {
                            PageId    = "9",
                            Questions = new List <Question> {
                                new Question()
                                {
                                    QuestionId = "Q9", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            Next          = new List <Next>
                            {
                                new Next()
                                {
                                    Action = "NextPage", ReturnId = "10"
                                }
                            },
                            Active = true
                        },
                        new Page()
                        {
                            PageId    = "10",
                            Questions = new List <Question> {
                                new Question()
                                {
                                    QuestionId = "Q10", Input = new Input()
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            Next          = new List <Next>
                            {
                                new Next()
                                {
                                    Action = "ReturnToSequence", ReturnId = "1"
                                }
                            },
                            Active = true
                        }
                    }
                }
            });

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

            await DataContext.SaveChangesAsync();
        }
        public async Task SetUp()
        {
            DataContext = DataContextHelpers.GetInMemoryDataContext();

            var applicationDataValidator = Substitute.For <IApplicationDataValidator>();

            applicationDataValidator.IsValid("", "").ReturnsForAnyArgs(true);
            var logger = Substitute.For <ILogger <StartApplicationHandler> >();

            Handler = new StartApplicationHandler(DataContext, applicationDataValidator, logger);

            WorkflowId = Guid.NewGuid();

            var projectId = Guid.NewGuid();
            await DataContext.Workflows.AddAsync(
                new Workflow()
            {
                Type = "EPAO", Status = WorkflowStatus.Live, Id = WorkflowId, ProjectId = projectId
            });

            var workflowSections = new[]
            {
                new WorkflowSection {
                    Id = Guid.NewGuid(), Title = "Section 1", QnAData = new QnAData()
                    {
                        Pages = new List <Page>()
                        {
                            new Page()
                            {
                                Title = "[PageTitleToken1]"
                            },
                            new Page()
                            {
                                Title = "[PageTitleToken2]"
                            }
                        }
                    }
                },
                new WorkflowSection {
                    Id = Guid.NewGuid(), Title = "Section 2", QnAData = new QnAData()
                    {
                        Pages = new List <Page>()
                    }
                },
                new WorkflowSection {
                    Id = Guid.NewGuid(), Title = "Section 3", QnAData = new QnAData()
                    {
                        Pages = new List <Page>()
                    }
                },
                new WorkflowSection {
                    Id = Guid.NewGuid(), Title = "Section 4", QnAData = new QnAData()
                    {
                        Pages = new List <Page>()
                    }
                },
                new WorkflowSection {
                    Id = Guid.NewGuid(), Title = "Invalid section", QnAData = new QnAData()
                    {
                        Pages = new List <Page>()
                    }
                }
            };

            await DataContext.WorkflowSections.AddRangeAsync(workflowSections);

            await DataContext.WorkflowSequences.AddRangeAsync(new[]
            {
                new WorkflowSequence {
                    WorkflowId = WorkflowId, SectionId = workflowSections[0].Id, SectionNo = 1, SequenceNo = 1, IsActive = true
                },
                new WorkflowSequence {
                    WorkflowId = WorkflowId, SectionId = workflowSections[1].Id, SectionNo = 2, SequenceNo = 1, IsActive = true
                },
                new WorkflowSequence {
                    WorkflowId = WorkflowId, SectionId = workflowSections[2].Id, SectionNo = 3, SequenceNo = 1, IsActive = true
                },
                new WorkflowSequence {
                    WorkflowId = WorkflowId, SectionId = workflowSections[3].Id, SectionNo = 4, SequenceNo = 2, IsActive = false
                },
                new WorkflowSequence {
                    WorkflowId = Guid.NewGuid()
                },
                new WorkflowSequence {
                    WorkflowId = Guid.NewGuid()
                },
            });

            await DataContext.Projects.AddAsync(new Project { Id = projectId, ApplicationDataSchema = "" });

            await DataContext.SaveChangesAsync();
        }
Ejemplo n.º 17
0
 public UpsertWorkflowSectionHandler(QnaDataContext dataContext)
 {
     _dataContext = dataContext;
 }
 public StartApplicationHandler(QnaDataContext dataContext, IApplicationDataValidator applicationDataValidator, ILogger <StartApplicationHandler> logger)
 {
     _dataContext = dataContext;
     _applicationDataValidator = applicationDataValidator;
     _logger = logger;
 }
 public SubmitPageOfFilesHandler(QnaDataContext dataContext, IOptions <FileStorageConfig> fileStorageConfig, IEncryptionService encryptionService, IAnswerValidator answerValidator, IFileContentValidator fileContentValidator, INotRequiredProcessor notRequiredProcessor, ITagProcessingService tagProcessingService) : base(dataContext, notRequiredProcessor, tagProcessingService, answerValidator)
 {
     _fileStorageConfig    = fileStorageConfig;
     _encryptionService    = encryptionService;
     _fileContentValidator = fileContentValidator;
 }
 public UpsertFeedbackHandler(QnaDataContext dataContext)
 {
     _dataContext = dataContext;
 }
        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();
        }
Ejemplo n.º 22
0
 public GetWorkflowsHandler(QnaDataContext dataContext, IMapper mapper)
 {
     _dataContext = dataContext;
     _mapper      = mapper;
 }
Ejemplo n.º 23
0
 public GetSequencesHandler(QnaDataContext dataContext, IMapper mapper)
 {
     _dataContext = dataContext;
     _mapper      = mapper;
 }
Ejemplo n.º 24
0
 public ResetPageAnswersHandler(QnaDataContext dataContext, INotRequiredProcessor notRequiredProcessor, ITagProcessingService tagProcessingService) : base(dataContext, notRequiredProcessor, tagProcessingService, null)
 {
 }
 public GetSectionHandler(QnaDataContext dataContext, IMapper mapper, INotRequiredProcessor notRequiredProcessor)
 {
     _dataContext          = dataContext;
     _mapper               = mapper;
     _notRequiredProcessor = notRequiredProcessor;
 }
 public GetWorkflowSectionsHandler(QnaDataContext dataContext)
 {
     _dataContext = dataContext;
 }
 public CreateWorkflowSectionHandler(QnaDataContext dataContext)
 {
     _dataContext = dataContext;
 }
Ejemplo n.º 28
0
 public SkipPageBySectionNoHandler(QnaDataContext dataContext, INotRequiredProcessor notRequiredProcessor, ITagProcessingService tagProcessingService) : base(dataContext, notRequiredProcessor, tagProcessingService, null)
 {
 }
 public CanUpdatePageBySectionNoHandler(QnaDataContext dataContext)
 {
     _dataContext = dataContext;
 }
        public async Task SetUp()
        {
            DataContext          = DataContextHelpers.GetInMemoryDataContext();
            NotRequiredProcessor = new NotRequiredProcessor();
            TagProcessingService = new TagProcessingService(DataContext);
            var fileStorageConfig = GetFileStorageConfig();

            var encryptionService = Substitute.For <IEncryptionService>();

            encryptionService.Encrypt(Arg.Any <Stream>()).Returns(callinfo => callinfo.ArgAt <Stream>(0)); // Don't Encrypt stream
            encryptionService.Decrypt(Arg.Any <Stream>()).Returns(callinfo => callinfo.ArgAt <Stream>(0)); // Don't Decrypt stream

            var validator = Substitute.For <IAnswerValidator>();

            validator.Validate(Arg.Any <List <Answer> >(), Arg.Any <Page>()).Returns(new List <KeyValuePair <string, string> >());

            var fileContentValidator = Substitute.For <IFileContentValidator>();

            fileContentValidator.Validate(Arg.Any <IFormFileCollection>()).Returns(new List <KeyValuePair <string, string> >());

            Handler = new SubmitPageOfFilesHandler(DataContext, fileStorageConfig, encryptionService, validator, fileContentValidator, NotRequiredProcessor, TagProcessingService);

            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", Input = new Input {
                                        Type = "FileUpload"
                                    }
                                }
                            },
                            PageOfAnswers = new List <PageOfAnswers>(),
                            Next          = new List <Next> {
                                new Next {
                                }
                            },
                            Active = true
                        }
                    }
                }
            });

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

            await DataContext.SaveChangesAsync();
        }