public void GetLiveJobProfilesTest(bool jobProfilesAvailable)
        {
            //Arrange
            var dummyJobProfile = A.Dummy <JobProfileOverloadForWhatItTakes>();

            // Dummies and fakes
            A.CallTo(() => fakeWitConverter.ConvertFrom(A <DynamicContent> ._)).Returns(dummyJobProfile);
            A.CallTo(() => fakeRepository.GetMany(A <Expression <Func <DynamicContent, bool> > > ._)).Returns(jobProfilesAvailable ? new EnumerableQuery <DynamicContent>(new List <DynamicContent> {
                new DynamicContent()
            }) : Enumerable.Empty <DynamicContent>().AsQueryable());
            var jobProfileRepository = new JobProfileRepository(fakeRepository, fakeJobProfileConverter, fakeDynamicContentExtensions, fakeSocSkillRepo, fakeWitConverter, fakeJobProfileSearchConverter);

            // Act
            jobProfileRepository.GetLiveJobProfiles();

            // Assert
            if (jobProfilesAvailable)
            {
                A.CallTo(() => fakeWitConverter.ConvertFrom(A <DynamicContent> ._)).MustHaveHappened();
            }
            else
            {
                A.CallTo(() => fakeWitConverter.ConvertFrom(A <DynamicContent> ._)).MustNotHaveHappened();
            }

            A.CallTo(() => fakeRepository.GetMany(A <Expression <Func <DynamicContent, bool> > > .That.Matches(m => LinqExpressionsTestHelper.IsExpressionEqual(m, item => item.Status == ContentLifecycleStatus.Live && item.Visible)))).MustHaveHappened();
        }
        public void GetSocSkillMatricesTest(bool skillsAvailable)
        {
            //Arrange
            var dummySkill          = A.Dummy <SocSkillMatrix>();
            var dummyDynamicContent = A.Dummy <DynamicContent>();

            // Dummies and fakes
            A.CallTo(() => fakeSocSkillConverter.ConvertFrom(dummyDynamicContent)).Returns(dummySkill);
            A.CallTo(() => fakeSocMatrixRepository.GetMany(A <Expression <Func <DynamicContent, bool> > > ._)).Returns(new EnumerableQuery <DynamicContent>(new List <DynamicContent> {
                skillsAvailable?dummyDynamicContent: null
            }));

            var socSkillMatrixRepository = new SocSkillMatrixRepository(fakeFrameworkSkillRepository, fakeSocMatrixRepository, fakeDynamicContentExtensions, fakeSocCodeRepository, fakeSocSkillConverter);

            // Act
            socSkillMatrixRepository.GetSocSkillMatrices();

            // Assert

            // Needs investigation as fake convertor not registering call made to it when there is a soc skill available.
            //if (skillsAvailable)
            //{
            //    A.CallTo(() => fakeFrameworkSkillConverter.ConvertFrom(A<DynamicContent>._)).MustHaveHappened();
            //}
            //else
            //{
            //    A.CallTo(() => fakeFrameworkSkillConverter.ConvertFrom(A<DynamicContent>._)).MustNotHaveHappened();
            //}
            A.CallTo(() => fakeSocMatrixRepository.GetMany(A <Expression <Func <DynamicContent, bool> > > .That.Matches(m => LinqExpressionsTestHelper.IsExpressionEqual(m, item => item.Visible && item.Status == ContentLifecycleStatus.Live)))).MustHaveHappened();
        }
示例#3
0
        public void GetAllFiltersTest()
        {
            //Assign
            SetupCalls();
            var psfRepo = new PreSearchFiltersRepository <PreSearchFilter>(fakeRepository, fakeModuleConverter);

            //Act
            var result = psfRepo.GetAllFilters();

            //Assert
            A.CallTo(() => fakeRepository.GetMany(A <Expression <Func <DynamicContent, bool> > > .That.Matches(m => LinqExpressionsTestHelper.IsExpressionEqual(m, item => item.Visible && item.Status == ContentLifecycleStatus.Live)))).MustHaveHappened();
            result.FirstOrDefault()?.Description.Should().Contain(nameof(PreSearchFilter.Description));
        }
        public void GetJobProfileApprenticeshipVacancyReport()
        {
            //Arrange
            SetupCalls();
            var jobProfileReportRepository = new JobProfileReportRepository(fakeJobProfileRepository, fakeJobProfileApprenticeshipVacancyReportConverter, fakeApprenticeVacancyRepository, fakeApprenticeVacancyConverter, fakeDynamicContentExtensions);

            // Act
            jobProfileReportRepository.GetJobProfileApprenticeshipVacancyReport();

            // Assert
            A.CallTo(() => fakeJobProfileRepository.GetMany(A <Expression <Func <DynamicContent, bool> > > .That.Matches(m => LinqExpressionsTestHelper.IsExpressionEqual(m, item => item.Status == ContentLifecycleStatus.Master)))).MustHaveHappened();
            A.CallTo(() => fakeApprenticeVacancyRepository.GetMany(A <Expression <Func <DynamicContent, bool> > > .That.Matches(m => LinqExpressionsTestHelper.IsExpressionEqual(m, item => item.Status == ContentLifecycleStatus.Master)))).MustHaveHappened();
            A.CallTo(() => fakeDynamicContentExtensions.SetRelatedDataSourceContext(A <IQueryable <DynamicContent> > ._)).MustHaveHappened();
        }
        public IEnumerable <T> GetAllFilters()
        {
            IEnumerable <DynamicContent> filterItems = repository.GetMany(item => item.Visible && item.Status == ContentLifecycleStatus.Live);

            var filters = filterItems?.Select(item => converter.ConvertFrom(item));

            return(filters.Where(f => f != null));
        }
        public void GetSocCodesTest(bool validSoc)
        {
            //Assign
            var fakeRepo            = GetTestJobProfileSocCodeRepository();
            var dummyDynamicContent = A.Dummy <DynamicContent>();

            // Setup Fakes
            A.CallTo(() => fakeRepository.GetMany(A <Expression <Func <DynamicContent, bool> > > ._)).Returns(validSoc
                ? new EnumerableQuery <DynamicContent>(new List <DynamicContent> {
                dummyDynamicContent
            })
                : Enumerable.Empty <DynamicContent>().AsQueryable());

            //Act
            fakeRepo.GetSocCodes();

            //Assert
            A.CallTo(() => fakeRepository.GetMany(A <Expression <Func <DynamicContent, bool> > > .That.Matches(m => LinqExpressionsTestHelper.IsExpressionEqual(m, item => item.Visible && item.Status == ContentLifecycleStatus.Live)))).MustHaveHappened();
        }
        public IEnumerable <SocSkillMatrix> GetSocSkillMatrices()
        {
            var socSkillMatrices = socMatrixRepository.GetMany(item => item.Visible && item.Status == ContentLifecycleStatus.Live).ToList();

            if (socSkillMatrices.Any())
            {
                return(socSkillMatrices.Select(item => socSkillConverter.ConvertFrom(item)));
            }

            return(Enumerable.Empty <SocSkillMatrix>());
        }
        public IQueryable <SocCode> GetSocCodes()
        {
            var socCodes = repository.GetMany(item => item.Visible && item.Status == ContentLifecycleStatus.Live);

            if (socCodes.Any())
            {
                return(socCodes.Select(item => socCodeConverter.ConvertFrom(item)));
            }

            return(Enumerable.Empty <SocCode>().AsQueryable());
        }
        public IQueryable <FrameworkSkill> GetFrameworkSkills()
        {
            var socSkillMatrices = frameworkSkillRepository.GetMany(item => item.Visible && item.Status == ContentLifecycleStatus.Live);

            if (socSkillMatrices.Any())
            {
                return(socSkillMatrices.Select(item => frameworkSkillConverter.ConvertFrom(item)));
            }

            return(Enumerable.Empty <FrameworkSkill>().AsQueryable());
        }
        public IEnumerable <JobProfileOverloadForWhatItTakes> GetLiveJobProfiles()
        {
            var jobProfiles = repository.GetMany(item => item.Status == ContentLifecycleStatus.Live && item.Visible).ToList();

            if (jobProfiles.Any())
            {
                var jobProfileOverloadForWhatItTakesList = new List <JobProfileOverloadForWhatItTakes>();
                foreach (var jobProfile in jobProfiles)
                {
                    jobProfileOverloadForWhatItTakesList.Add(converterForWITOnly.ConvertFrom(jobProfile));
                }

                return(jobProfileOverloadForWhatItTakesList);
            }

            return(Enumerable.Empty <JobProfileOverloadForWhatItTakes>());
        }
        public IEnumerable <JobProfileApprenticeshipVacancyReport> GetJobProfileApprenticeshipVacancyReport()
        {
            var allJobProfiles = jobProfileRepository.GetMany(x => x.Status == ContentLifecycleStatus.Master);

            dynamicContentExtensions.SetRelatedDataSourceContext(allJobProfiles);

            var allApprenticeVacancies = apprenticeVacancyRepository.GetMany(x => x.Status == ContentLifecycleStatus.Master);

            dynamicContentExtensions.SetRelatedDataSourceContext(allApprenticeVacancies);

            //CodeReview: Why ToList()
            // To avoid Connection reader error, as the process can be long running sitefinity suggest we store list in memory
            // https://knowledgebase.progress.com/articles/Article/invalid-attempt-to-call-isdbnull-when-reader-is-closed-exception
            var apprenticeships = allApprenticeVacancies.Select(a => apprenticeVacancyConverter.ConvertFrom(a)).ToList();
            var profiles        = allJobProfiles.Select(j => jobProfileApprenticeshipVacancyReportConverter.ConvertFrom(j)).ToList();

            profiles.Where(p => p.SocCode != null).ToList().ForEach(p => p.ApprenticeshipVacancies = apprenticeships.Where(av => av.SocCode != null && av.SocCode.Id == p.SocCode.Id));

            return(profiles);
        }