コード例 #1
0
        public void LARSConditionMet_True()
        {
            string learnAimRef  = "ZESF0002";
            string conRefNumber = "ESF7890";
            var    esfEligibilityRuleSectorSubjectAreaLevels = new IEsfEligibilityRuleSectorSubjectAreaLevel[]
            {
                new EsfEligibilityRuleSectorSubjectAreaLevel()
                {
                    TenderSpecReference   = "tt_2976",
                    LotReference          = "01",
                    SectorSubjectAreaCode = 13.2M,
                },
            };
            var learningDelivery = new Data.External.LARS.Model.LearningDelivery()
            {
                LearnAimRef            = learnAimRef,
                SectorSubjectAreaTier1 = 14.2M,
                SectorSubjectAreaTier2 = 15.2M
            };

            var fcsDataServiceMock  = new Mock <IFCSDataService>();
            var larsDataServiceMock = new Mock <ILARSDataService>();

            fcsDataServiceMock.Setup(m => m.GetEligibilityRuleSectorSubjectAreaLevelsFor(conRefNumber)).Returns(esfEligibilityRuleSectorSubjectAreaLevels);
            larsDataServiceMock.Setup(l => l.GetDeliveryFor(learnAimRef)).Returns(learningDelivery);

            NewRule(
                fCSDataService: fcsDataServiceMock.Object,
                lARSDataService: larsDataServiceMock.Object)
            .LARSConditionMet(conRefNumber, learnAimRef).Should().BeTrue();
        }
        public void LARSExclusionCondition_False_StartDateMisMatch()
        {
            var learnStartDate       = new DateTime(2020, 8, 1);
            var larsLearningDelivery = new Data.External.LARS.Model.LearningDelivery
            {
                LearnAimRef   = "AimRef",
                EffectiveFrom = new DateTime(2020, 9, 1)
            };

            var annualValues = new List <ILARSAnnualValue>
            {
                new Data.External.LARS.Model.AnnualValue
                {
                    LearnAimRef     = "AimRef",
                    EffectiveFrom   = new DateTime(2020, 8, 1),
                    BasicSkillsType = 20
                },
                new Data.External.LARS.Model.AnnualValue
                {
                    LearnAimRef     = "AimRef",
                    EffectiveFrom   = new DateTime(2020, 8, 1),
                    BasicSkillsType = 105
                }
            };

            var larsMock = new Mock <ILARSDataService>();

            larsMock.Setup(x => x.GetAnnualValuesFor(larsLearningDelivery.LearnAimRef)).Returns(annualValues);

            var dateTimeQSMock = new Mock <IDateTimeQueryService>();

            dateTimeQSMock.Setup(x => x.IsDateBetween(learnStartDate, larsLearningDelivery.EffectiveFrom, larsLearningDelivery.EffectiveTo ?? DateTime.MaxValue, true)).Returns(false);

            NewRule(larsDataService: larsMock.Object, dateTimeQueryService: dateTimeQSMock.Object).LARSExclusionCondition(larsLearningDelivery, learnStartDate).Should().BeFalse();
        }
        public void LarsCondition_True_NoCategories()
        {
            var larsDelivery = new Data.External.LARS.Model.LearningDelivery
            {
                LearnAimRef        = "LearnAimRef",
                NotionalNVQLevelv2 = "2"
            };

            NewRule().LarsCondition(larsDelivery).Should().BeTrue();
        }
        public void LarsCondition_True(string nvq)
        {
            var larsDelivery = new Data.External.LARS.Model.LearningDelivery
            {
                LearnAimRef        = "LearnAimRef",
                NotionalNVQLevelv2 = nvq,
            };

            NewRule().LarsCondition(larsDelivery).Should().BeTrue();
        }
コード例 #5
0
        public void Validate_NoError()
        {
            string learnAimRef  = "ZESF0002";
            string conRefNumber = "ESF7890";

            var testLearner = new TestLearner()
            {
                LearningDeliveries = new TestLearningDelivery[]
                {
                    new TestLearningDelivery()
                    {
                        LearnAimRef  = learnAimRef,
                        ConRefNumber = conRefNumber,
                        FundModel    = FundModels.AdultSkills
                    }
                }
            };

            var esfEligibilityRuleSectorSubjectAreaLevels = new IEsfEligibilityRuleSectorSubjectAreaLevel[]
            {
                new EsfEligibilityRuleSectorSubjectAreaLevel()
                {
                    TenderSpecReference   = "tt_2976",
                    LotReference          = "01",
                    SectorSubjectAreaCode = 13.2M,
                },
            };

            var learningDelivery = new Data.External.LARS.Model.LearningDelivery()
            {
                LearnAimRef            = learnAimRef,
                SectorSubjectAreaTier1 = 14.2M,
                SectorSubjectAreaTier2 = 15.2M
            };

            var fcsDataServiceMock  = new Mock <IFCSDataService>();
            var larsDataServiceMock = new Mock <ILARSDataService>();

            fcsDataServiceMock.Setup(m => m.GetEligibilityRuleSectorSubjectAreaLevelsFor(conRefNumber)).Returns(esfEligibilityRuleSectorSubjectAreaLevels);
            fcsDataServiceMock.Setup(m => m.GetEligibilityRuleSectorSubjectAreaLevelsFor("ESF223344")).Returns(new IEsfEligibilityRuleSectorSubjectAreaLevel[] { });
            larsDataServiceMock.Setup(l => l.GetDeliveryFor(learnAimRef)).Returns(learningDelivery);

            using (var validationErrorHandlerMock = BuildValidationErrorHandlerMockForNoError())
            {
                NewRule(
                    validationErrorHandler: validationErrorHandlerMock.Object,
                    fCSDataService: fcsDataServiceMock.Object,
                    lARSDataService: larsDataServiceMock.Object).Validate(testLearner);
            }
        }
コード例 #6
0
        private ProgType_19Rule NewRule(IValidationErrorHandler validationErrorHandler = null)
        {
            ILARSLearningDelivery larsLearningDelivery = new Data.External.LARS.Model.LearningDelivery()
            {
                LearnAimRefType = _larsLearnAimRefType
            };

            var larsDataServiceMock = new Mock <ILARSDataService>();

            larsDataServiceMock.Setup(x => x.GetDeliveryFor(_larsLearnAimReference))
            .Returns(larsLearningDelivery);

            larsDataServiceMock.Setup(x => x.GetDeliveryFor(_nonLarsLearnAimReference))
            .Returns((ILARSLearningDelivery)null);

            return(new ProgType_19Rule(validationErrorHandler, larsDataServiceMock.Object));
        }
        public void LarsCondition_False(string nvq, int categoryRef)
        {
            var larsDelivery = new Data.External.LARS.Model.LearningDelivery
            {
                LearnAimRef        = "LearnAimRef",
                NotionalNVQLevelv2 = nvq,
                Categories         = new List <Data.External.LARS.Model.LearningDeliveryCategory>
                {
                    new Data.External.LARS.Model.LearningDeliveryCategory
                    {
                        LearnAimRef = "LearnAimRef",
                        CategoryRef = categoryRef
                    }
                }
            };

            NewRule().LarsCondition(larsDelivery).Should().BeFalse();
        }
        public void LARSExclusionCondition_False_NullAnnualValue()
        {
            var learnStartDate       = new DateTime(2020, 8, 1);
            var larsLearningDelivery = new Data.External.LARS.Model.LearningDelivery
            {
                LearnAimRef   = "AimRef",
                EffectiveFrom = new DateTime(2020, 8, 1)
            };

            var larsMock = new Mock <ILARSDataService>();

            larsMock.Setup(x => x.GetAnnualValuesFor(larsLearningDelivery.LearnAimRef)).Returns(Array.Empty <ILARSAnnualValue>());

            var dateTimeQSMock = new Mock <IDateTimeQueryService>();

            dateTimeQSMock.Setup(x => x.IsDateBetween(learnStartDate, larsLearningDelivery.EffectiveFrom, larsLearningDelivery.EffectiveTo ?? DateTime.MaxValue, true)).Returns(true);

            NewRule(larsDataService: larsMock.Object, dateTimeQueryService: dateTimeQSMock.Object).LARSExclusionCondition(larsLearningDelivery, learnStartDate).Should().BeFalse();
        }
コード例 #9
0
        public void LARSConditionMet_False(string sectorSubjectArea1, string sectorSubjectArea2)
        {
            string learnAimRef  = ValidationConstants.ZESF0001;
            string conRefNumber = "ESF223344";

            var esfEligibilityRuleSectorSubjectAreaLevels = new IEsfEligibilityRuleSectorSubjectAreaLevel[]
            {
                new EsfEligibilityRuleSectorSubjectAreaLevel()
                {
                    TenderSpecReference   = "tt_2976",
                    LotReference          = "A1",
                    SectorSubjectAreaCode = 13.1M,
                },
                new EsfEligibilityRuleSectorSubjectAreaLevel()
                {
                    TenderSpecReference   = "tt_2978",
                    LotReference          = "A3",
                    SectorSubjectAreaCode = 15.1M,
                }
            };

            var learningDelivery = new Data.External.LARS.Model.LearningDelivery()
            {
                LearnAimRef            = learnAimRef,
                SectorSubjectAreaTier1 = string.IsNullOrEmpty(sectorSubjectArea1) ? (decimal?)null : decimal.Parse(sectorSubjectArea1),
                SectorSubjectAreaTier2 = string.IsNullOrEmpty(sectorSubjectArea2) ? (decimal?)null : decimal.Parse(sectorSubjectArea2)
            };

            var fcsDataServiceMock  = new Mock <IFCSDataService>();
            var larsDataServiceMock = new Mock <ILARSDataService>();

            fcsDataServiceMock.Setup(m => m.GetEligibilityRuleSectorSubjectAreaLevelsFor(conRefNumber)).Returns(esfEligibilityRuleSectorSubjectAreaLevels);
            larsDataServiceMock.Setup(l => l.GetDeliveryFor(learnAimRef)).Returns(learningDelivery);

            NewRule(
                fCSDataService: fcsDataServiceMock.Object,
                lARSDataService: larsDataServiceMock.Object)
            .LARSConditionMet(conRefNumber, learnAimRef).Should().BeFalse();
        }
コード例 #10
0
        public void ConditionMet_False_NullLars()
        {
            var learnAimRef      = "LearnAimRef";
            var dateOfBirth      = new DateTime(2000, 8, 1);
            var priorAttain      = 2;
            var learnStartDate   = new DateTime(2020, 8, 1);
            var fundModel        = 35;
            var learningDelivery = new TestLearningDelivery
            {
                ProgTypeNullable = 24,
                FundModel        = fundModel,
                LearnStartDate   = learnStartDate
            };

            var employmentStatuses   = It.IsAny <IEnumerable <ILearnerEmploymentStatus> >();
            var learningDeliveryFAMs = It.IsAny <IEnumerable <ILearningDeliveryFAM> >();

            var larsDelivery = new Data.External.LARS.Model.LearningDelivery
            {
                LearnAimRef        = learnAimRef,
                NotionalNVQLevelv2 = "2",
                EffectiveFrom      = new DateTime(2020, 8, 1),
                Categories         = new List <Data.External.LARS.Model.LearningDeliveryCategory>
                {
                    new Data.External.LARS.Model.LearningDeliveryCategory
                    {
                        LearnAimRef = learnAimRef,
                        CategoryRef = 35
                    }
                }
            };

            var larsMock = new Mock <ILARSDataService>();

            larsMock.Setup(x => x.GetDeliveryFor(learnAimRef)).Returns((ILARSLearningDelivery)null);

            NewRule(larsDataService: larsMock.Object).ConditionMet(dateOfBirth, priorAttain, employmentStatuses, learningDelivery).Should().BeFalse();
        }
        public void Validate_Error()
        {
            var dateOfBirth      = new DateTime(2000, 8, 1);
            var learnStartDate   = new DateTime(2020, 8, 1);
            var fundModel        = 35;
            var learningDelivery = new TestLearningDelivery
            {
                ProgTypeNullable = 24,
                FundModel        = fundModel,
                LearnStartDate   = learnStartDate
            };

            var employmentStatuses   = It.IsAny <IEnumerable <ILearnerEmploymentStatus> >();
            var learningDeliveryFAMs = It.IsAny <IEnumerable <ILearningDeliveryFAM> >();

            var learner = new TestLearner
            {
                DateOfBirthNullable = dateOfBirth,
                LearningDeliveries  = new List <TestLearningDelivery>
                {
                    learningDelivery
                }
            };

            var larsDelivery = new Data.External.LARS.Model.LearningDelivery
            {
                LearnAimRef        = "LearnAimRef",
                NotionalNVQLevelv2 = "2",
                EffectiveFrom      = new DateTime(2020, 8, 1),
                Categories         = new List <Data.External.LARS.Model.LearningDeliveryCategory>
                {
                    new Data.External.LARS.Model.LearningDeliveryCategory
                    {
                        LearnAimRef = "LearnAimRef",
                        CategoryRef = 35
                    }
                }
            };

            var annualValues = new List <ILARSAnnualValue>
            {
                new Data.External.LARS.Model.AnnualValue
                {
                    LearnAimRef     = "AimRef",
                    EffectiveFrom   = new DateTime(2020, 8, 1),
                    BasicSkillsType = 20
                },
                new Data.External.LARS.Model.AnnualValue
                {
                    LearnAimRef     = "AimRef",
                    EffectiveFrom   = new DateTime(2020, 8, 1),
                    BasicSkillsType = 105
                }
            };

            var fileDataServiceMock = new Mock <IFileDataService>();

            fileDataServiceMock.Setup(x => x.UKPRN()).Returns(1);

            var dd07Mock = new Mock <IDerivedData_07Rule>();

            dd07Mock.Setup(dd => dd.IsApprenticeship(learningDelivery.ProgTypeNullable)).Returns(false);

            var dd29Mock = new Mock <IDerivedData_29Rule>();

            dd29Mock.Setup(dd => dd.IsInflexibleElementOfTrainingAimLearningDelivery(learningDelivery)).Returns(false);

            var dd37Mock = new Mock <IDerivedData_37Rule>();

            dd37Mock.Setup(dd => dd.Derive(fundModel, learnStartDate, employmentStatuses, learningDeliveryFAMs)).Returns(false);

            var dd38Mock = new Mock <IDerivedData_38Rule>();

            dd38Mock.Setup(dd => dd.Derive(fundModel, learnStartDate, employmentStatuses)).Returns(false);

            var learningDeliveryFAMsQueryServiceMock = new Mock <ILearningDeliveryFAMQueryService>();

            learningDeliveryFAMsQueryServiceMock.Setup(x => x.HasLearningDeliveryFAMType(learningDeliveryFAMs, "RES")).Returns(false);
            learningDeliveryFAMsQueryServiceMock.Setup(lds => lds.HasAnyLearningDeliveryFAMCodesForType(learningDeliveryFAMs, "LDM", _ldmExclusions)).Returns(false);
            learningDeliveryFAMsQueryServiceMock.Setup(lds => lds.HasLearningDeliveryFAMCodeForType(learningDeliveryFAMs, "DAM", "023")).Returns(false);
            learningDeliveryFAMsQueryServiceMock.Setup(lds => lds.HasLearningDeliveryFAMCodeForType(learningDeliveryFAMs, "FFI", "1")).Returns(true);

            var dateTimeQSMock = new Mock <IDateTimeQueryService>();

            dateTimeQSMock.Setup(x => x.YearsBetween(dateOfBirth, learnStartDate)).Returns(20);
            dateTimeQSMock.Setup(x => x.IsDateBetween(learnStartDate, larsDelivery.EffectiveFrom, larsDelivery.EffectiveTo ?? DateTime.MaxValue, true)).Returns(true);

            var larsMock = new Mock <ILARSDataService>();

            larsMock.Setup(x => x.GetAnnualValuesFor(larsDelivery.LearnAimRef)).Returns(annualValues);

            using (var validationErrorHandlerMock = BuildValidationErrorHandlerMockForNoError())
            {
                NewRule(
                    validationErrorHandlerMock.Object,
                    fileDataServiceMock.Object,
                    dateTimeQSMock.Object,
                    larsMock.Object,
                    learningDeliveryFAMsQueryServiceMock.Object,
                    dd07Mock.Object,
                    dd29Mock.Object,
                    dd37Mock.Object,
                    dd38Mock.Object).Validate(learner);
            }
        }
        public void Excluded_False()
        {
            var learnStartDate   = new DateTime(2020, 8, 1);
            var fundModel        = 35;
            var learningDelivery = new TestLearningDelivery
            {
                ProgTypeNullable = 24,
                FundModel        = fundModel,
                LearnStartDate   = learnStartDate
            };

            var employmentStatuses   = It.IsAny <IEnumerable <ILearnerEmploymentStatus> >();
            var learningDeliveryFAMs = It.IsAny <IEnumerable <ILearningDeliveryFAM> >();

            var larsDelivery = new Data.External.LARS.Model.LearningDelivery
            {
                LearnAimRef        = "LearnAimRef",
                NotionalNVQLevelv2 = "2",
                EffectiveFrom      = new DateTime(2020, 8, 1),
                Categories         = new List <Data.External.LARS.Model.LearningDeliveryCategory>
                {
                    new Data.External.LARS.Model.LearningDeliveryCategory
                    {
                        LearnAimRef = "LearnAimRef",
                        CategoryRef = 35
                    }
                }
            };

            var annualValues = new List <ILARSAnnualValue>
            {
                new Data.External.LARS.Model.AnnualValue
                {
                    LearnAimRef     = "AimRef",
                    EffectiveFrom   = new DateTime(2020, 8, 1),
                    BasicSkillsType = 20
                },
                new Data.External.LARS.Model.AnnualValue
                {
                    LearnAimRef     = "AimRef",
                    EffectiveFrom   = new DateTime(2020, 8, 1),
                    BasicSkillsType = 105
                }
            };

            var dd07Mock = new Mock <IDerivedData_07Rule>();

            dd07Mock.Setup(dd => dd.IsApprenticeship(learningDelivery.ProgTypeNullable)).Returns(false);

            var dd29Mock = new Mock <IDerivedData_29Rule>();

            dd29Mock.Setup(dd => dd.IsInflexibleElementOfTrainingAimLearningDelivery(learningDelivery)).Returns(false);

            var dd37Mock = new Mock <IDerivedData_37Rule>();

            dd37Mock.Setup(dd => dd.Derive(fundModel, learnStartDate, employmentStatuses, learningDeliveryFAMs)).Returns(false);

            var dd38Mock = new Mock <IDerivedData_38Rule>();

            dd38Mock.Setup(dd => dd.Derive(fundModel, learnStartDate, employmentStatuses)).Returns(false);

            var learningDeliveryFAMsQueryServiceMock = new Mock <ILearningDeliveryFAMQueryService>();

            learningDeliveryFAMsQueryServiceMock.Setup(x => x.HasLearningDeliveryFAMType(learningDeliveryFAMs, "RES")).Returns(false);
            learningDeliveryFAMsQueryServiceMock.Setup(lds => lds.HasAnyLearningDeliveryFAMCodesForType(learningDeliveryFAMs, "LDM", _ldmExclusions)).Returns(false);
            learningDeliveryFAMsQueryServiceMock.Setup(lds => lds.HasLearningDeliveryFAMCodeForType(learningDeliveryFAMs, "DAM", "023")).Returns(false);

            var dateTimeQSMock = new Mock <IDateTimeQueryService>();

            dateTimeQSMock.Setup(x => x.IsDateBetween(learnStartDate, larsDelivery.EffectiveFrom, larsDelivery.EffectiveTo ?? DateTime.MaxValue, true)).Returns(false);

            var larsMock = new Mock <ILARSDataService>();

            larsMock.Setup(x => x.GetAnnualValuesFor(larsDelivery.LearnAimRef)).Returns(annualValues);

            NewRule(
                dd07: dd07Mock.Object,
                dd29: dd29Mock.Object,
                dd37: dd37Mock.Object,
                dd38: dd38Mock.Object,
                learningDeliveryFAMQueryService: learningDeliveryFAMsQueryServiceMock.Object,
                larsDataService: larsMock.Object,
                dateTimeQueryService: dateTimeQSMock.Object)
            .Excluded(learningDelivery, employmentStatuses, larsDelivery).Should().BeFalse();
        }