Exemplo n.º 1
0
        public void GetSectorsForEmptyReview_when_sectors_section_returns_expected_result()
        {
            var startingPageId = Guid.NewGuid().ToString();

            var sectorsSection = new AssessorSection
            {
                LinkTitle      = "Sectors Section",
                SectionNumber  = RoatpWorkflowSectionIds.DeliveringApprenticeshipTraining.YourSectorsAndEmployees,
                SequenceNumber = RoatpWorkflowSequenceIds.DeliveringApprenticeshipTraining,
                Pages          = new List <Page>
                {
                    new Page {
                        PageId = startingPageId, DisplayType = SectionDisplayType.PagesWithSections, LinkTitle = "First Sector Starting Page", Active = true, Complete = true
                    },
                    new Page {
                        PageId = Guid.NewGuid().ToString(), DisplayType = SectionDisplayType.Questions, LinkTitle = "First Sector Question Page", Active = true, Complete = true
                    }
                }
            };

            var result = _assessorSectorService.GetSectorsForEmptyReview(sectorsSection);

            CollectionAssert.IsNotEmpty(result);
            Assert.AreEqual(result[0].PageId, startingPageId);
        }
        public List <AssessorSector> GetSectorsForEmptyReview(AssessorSection section)
        {
            var startingPages = GetStartingPagesFromAssessorSection(section);

            return(startingPages?.Select(page => new AssessorSector {
                Title = page.LinkTitle, PageId = page.PageId
            }).ToList());
        }
        private List <Page> GetStartingPagesFromAssessorSection(AssessorSection section)
        {
            var startingPages = new List <Page>();

            if (section != null && section.SequenceNumber == SectorsSequenceNumber && section.SectionNumber == SectorsSectionNumber)
            {
                startingPages = GetStartingPages(section.Pages);
            }

            return(startingPages);
        }
Exemplo n.º 4
0
        public void GetSectorsForEmptyReview_when_not_sectors_section_returns_no_sectors()
        {
            var managementHierarchySection = new AssessorSection
            {
                LinkTitle      = "Management Hierarchy Section",
                SectionNumber  = RoatpWorkflowSectionIds.DeliveringApprenticeshipTraining.ManagementHierarchy,
                SequenceNumber = RoatpWorkflowSequenceIds.DeliveringApprenticeshipTraining,
                Pages          = new List <Page>
                {
                    new Page {
                        PageId = Guid.NewGuid().ToString(), Active = true, Complete = true
                    },
                    new Page {
                        PageId = Guid.NewGuid().ToString(), Active = true, Complete = true
                    }
                }
            };

            var result = _assessorSectorService.GetSectorsForEmptyReview(managementHierarchySection);

            CollectionAssert.IsEmpty(result);
        }
        private List <AssessorPageReviewOutcome> GenerateSectorsReviewOutcomes(Guid applicationId, AssessorSection section, List <AssessorSector> selectedSectors, string assessorUserId, int assessorNumber)
        {
            var sectorReviewOutcomes = new List <AssessorPageReviewOutcome>();

            foreach (var sector in selectedSectors)
            {
                sectorReviewOutcomes.Add(new AssessorPageReviewOutcome
                {
                    ApplicationId  = applicationId,
                    SequenceNumber = section.SequenceNumber,
                    SectionNumber  = section.SectionNumber,
                    PageId         = sector.PageId,
                    UserId         = assessorUserId,
                    AssessorNumber = assessorNumber,
                    Status         = null,
                    Comment        = null
                });
            }

            return(sectorReviewOutcomes);
        }
        private List <AssessorPageReviewOutcome> GenerateSectionReviewOutcomes(Guid applicationId, AssessorSection section, string assessorUserId, int assessorNumber)
        {
            var sectionReviewOutcomes = new List <AssessorPageReviewOutcome>();

            if (section.Pages != null)
            {
                foreach (var page in section.Pages)
                {
                    sectionReviewOutcomes.Add(new AssessorPageReviewOutcome
                    {
                        ApplicationId  = applicationId,
                        SequenceNumber = section.SequenceNumber,
                        SectionNumber  = section.SectionNumber,
                        PageId         = page.PageId,
                        UserId         = assessorUserId,
                        AssessorNumber = assessorNumber,
                        Status         = null,
                        Comment        = null
                    });
                }
            }

            return(sectionReviewOutcomes);
        }
Exemplo n.º 7
0
        private async Task <List <ModeratorPageReviewOutcome> > GenerateSectionReviewOutcomes(Guid applicationId, AssessorSection section, string moderatorUserId)
        {
            var sectionReviewOutcomes = new List <ModeratorPageReviewOutcome>();

            if (section.Pages != null)
            {
                foreach (var page in section.Pages)
                {
                    sectionReviewOutcomes.Add(new ModeratorPageReviewOutcome
                    {
                        ApplicationId  = applicationId,
                        SequenceNumber = section.SequenceNumber,
                        SectionNumber  = section.SectionNumber,
                        PageId         = page.PageId,
                        UserId         = moderatorUserId,
                        Status         = null,
                        Comment        = null
                    });
                }

                if (section.SequenceNumber == RoatpWorkflowSequenceIds.DeliveringApprenticeshipTraining && section.SectionNumber == RoatpWorkflowSectionIds.DeliveringApprenticeshipTraining.ManagementHierarchy)
                {
                    // Sadly we have to cater for existing applications that never had this page as part of an Blind Assessor check
                    if (await ShouldGenerateManagementHierarchFinancialPage(applicationId))
                    {
                        // Inject page to show Financial information to Moderator
                        sectionReviewOutcomes.Add(new ModeratorPageReviewOutcome
                        {
                            ApplicationId  = applicationId,
                            SequenceNumber = section.SequenceNumber,
                            SectionNumber  = section.SectionNumber,
                            PageId         = RoatpWorkflowPageIds.DeliveringApprenticeshipTraining.ManagementHierarchy_Financial,
                            UserId         = moderatorUserId,
                            Status         = null,
                            Comment        = null
                        });
                    }
                }
            }

            return(sectionReviewOutcomes);
        }
        public void Arrange()
        {
            _applicationId    = Guid.NewGuid();
            _assessorUserId   = "TestUser";
            _assessorUserName = "******";
            _assessorNumber   = 1;

            _assessorSequenceService = new Mock <IAssessorSequenceService>();
            _mediator = new Mock <IMediator>();
            _assessorSectorService = new Mock <IAssessorSectorService>();

            var sectorsSection = new AssessorSection
            {
                LinkTitle      = "Sectors Section",
                SectionNumber  = RoatpWorkflowSectionIds.DeliveringApprenticeshipTraining.YourSectorsAndEmployees,
                SequenceNumber = RoatpWorkflowSequenceIds.DeliveringApprenticeshipTraining,
                Pages          = new List <Page>
                {
                    new Page {
                        PageId = Guid.NewGuid().ToString(), DisplayType = SectionDisplayType.PagesWithSections, LinkTitle = "First Sector Starting Page", Active = true, Complete = true
                    },
                    new Page {
                        PageId = Guid.NewGuid().ToString(), DisplayType = SectionDisplayType.Questions, LinkTitle = "First Sector Question Page", Active = true, Complete = true
                    }
                }
            };

            var managementHierarchySection = new AssessorSection
            {
                LinkTitle      = "Management Hierarchy Section",
                SectionNumber  = RoatpWorkflowSectionIds.DeliveringApprenticeshipTraining.ManagementHierarchy,
                SequenceNumber = RoatpWorkflowSequenceIds.DeliveringApprenticeshipTraining,
                Pages          = new List <Page>
                {
                    new Page {
                        PageId = Guid.NewGuid().ToString(), Active = true, Complete = true
                    },
                    new Page {
                        PageId = Guid.NewGuid().ToString(), Active = true, Complete = true
                    }
                }
            };

            _sequences = new List <AssessorSequence>
            {
                new AssessorSequence
                {
                    Id             = Guid.NewGuid(),
                    SequenceNumber = RoatpWorkflowSequenceIds.DeliveringApprenticeshipTraining,
                    SequenceTitle  = "Delivering Apprenticeship Training Sequence",
                    Sections       = new List <AssessorSection>
                    {
                        sectorsSection,
                        managementHierarchySection
                    }
                }
            };

            _assessorSequenceService.Setup(x => x.GetSequences(_applicationId)).ReturnsAsync(_sequences);

            _sectors = sectorsSection.Pages.Where(pg => pg.DisplayType == SectionDisplayType.PagesWithSections && pg.Active && pg.Complete)
                       .Select(pg => new AssessorSector {
                PageId = pg.PageId, Title = pg.LinkTitle
            })
                       .ToList();

            _assessorSectorService.Setup(x => x.GetSectorsForEmptyReview(sectorsSection)).Returns(_sectors);

            _assessorReviewCreationService = new AssessorReviewCreationService(_assessorSequenceService.Object, _assessorSectorService.Object, _mediator.Object);
        }
        private List <AssessorSequence> SetUpAsessorSequences()
        {
            var section2_3 = new AssessorSection
            {
                LinkTitle      = "Section 2.3",
                SequenceNumber = 2,
                SectionNumber  = 3,

                Pages = new List <Page>
                {
                    new Page
                    {
                        PageId    = "Page2.3.1", DisplayType = SectionDisplayType.Questions,
                        LinkTitle = "2.3 Starting Page",
                        Active    = true, Complete = true
                    },
                    new Page
                    {
                        PageId = "Page2.3.2", DisplayType = SectionDisplayType.Questions, LinkTitle = "2.3 page 2",
                        Active = true, Complete = true
                    }
                }
            };

            var section2_4 = new AssessorSection
            {
                LinkTitle      = "Section 2.4",
                SequenceNumber = 2,
                SectionNumber  = 4,
                Pages          = new List <Page>
                {
                    new Page {
                        PageId = "Page2.4.1", Active = true, Complete = true
                    },
                    new Page {
                        PageId = "Page2.4.2", Active = true, Complete = false
                    }
                }
            };

            var section1_2 = new AssessorSection
            {
                LinkTitle      = "Section 1.2",
                SequenceNumber = 1,
                SectionNumber  = 2,

                Pages = new List <Page>
                {
                    new Page
                    {
                        PageId    = _page121, DisplayType = SectionDisplayType.Questions,
                        LinkTitle = "1.2 Starting Page",
                        Active    = true, Complete = true
                    },
                    new Page
                    {
                        PageId = _page122, DisplayType = SectionDisplayType.Questions, LinkTitle = "1.2 page 2",
                        Active = true, Complete = true
                    },
                    new Page
                    {
                        PageId = "Page1.2.3", DisplayType = SectionDisplayType.Questions, LinkTitle = "1.2 page 3",
                        Active = true, Complete = true
                    }
                }
            };

            var sequences = new List <AssessorSequence>
            {
                new AssessorSequence
                {
                    Id             = Guid.NewGuid(),
                    SequenceNumber = 1,
                    SequenceTitle  = "Sequence 1",
                    Sections       = new List <AssessorSection>
                    {
                        section1_2
                    }
                },
                new AssessorSequence
                {
                    Id             = Guid.NewGuid(),
                    SequenceNumber = 2,
                    SequenceTitle  = "Sequence 2",
                    Sections       = new List <AssessorSection>
                    {
                        section2_3,
                        section2_4
                    }
                }
            };

            return(sequences);
        }