Пример #1
0
        public void GetLARSLearningDeliveryForMeetsExepctation(string candidate)
        {
            // arrange
            var mockItem = new Mock <ILearningDelivery>();

            mockItem
            .SetupGet(x => x.LearnAimRef)
            .Returns(candidate);

            var mockReturn = new Mock <ILARSLearningDelivery>();

            var handler   = new Mock <IValidationErrorHandler>(MockBehavior.Strict);
            var commonOps = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict);
            var fcsData   = new Mock <IFCSDataService>(MockBehavior.Strict);
            var larsData  = new Mock <ILARSDataService>(MockBehavior.Strict);

            larsData
            .Setup(x => x.GetDeliveryFor(candidate))
            .Returns(mockReturn.Object);

            var sut = new LearnAimRef_72Rule(handler.Object, commonOps.Object, fcsData.Object, larsData.Object);

            // act
            var result = sut.GetLARSLearningDeliveryFor(mockItem.Object);

            // assert
            Assert.Equal(mockReturn.Object, result);

            handler.VerifyAll();
            commonOps.VerifyAll();
            fcsData.VerifyAll();
            larsData.VerifyAll();
        }
Пример #2
0
        public void GetSubjectAreaLevelsForMeetsExpectation(string candidate)
        {
            // arrange
            var mockItem = new Mock <ILearningDelivery>();

            mockItem
            .SetupGet(x => x.ConRefNumber)
            .Returns(candidate);

            var handler   = new Mock <IValidationErrorHandler>(MockBehavior.Strict);
            var commonOps = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict);
            var fcsData   = new Mock <IFCSDataService>(MockBehavior.Strict);

            fcsData
            .Setup(x => x.GetEligibilityRuleSectorSubjectAreaLevelsFor(candidate))
            .Returns(new IEsfEligibilityRuleSectorSubjectAreaLevel[] { });

            var larsData = new Mock <ILARSDataService>(MockBehavior.Strict);

            var sut = new LearnAimRef_72Rule(handler.Object, commonOps.Object, fcsData.Object, larsData.Object);

            // act
            var result = sut.GetSubjectAreaLevelsFor(mockItem.Object);

            // assert
            Assert.Empty(result);

            handler.VerifyAll();
            commonOps.VerifyAll();
            fcsData.VerifyAll();
            larsData.VerifyAll();
        }
Пример #3
0
        public void ValidItemDoesNotRaiseValidationMessage(string notional, string min, string max, double?area)
        {
            // arrange
            const string LearnRefNumber    = "123456789X";
            const string AimRefNumber      = "shonkyAimRef";
            const string ContractRefNumber = "shonkyRefNumber";

            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(y => y.FundModel)
            .Returns(70);     // TypeOfFunding.EuropeanSocialFund
            delivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(AimRefNumber);
            delivery
            .SetupGet(y => y.ConRefNumber)
            .Returns(ContractRefNumber);

            var deliveries = new List <ILearningDelivery> {
                delivery.Object
            };

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            mockLearner
            .SetupGet(x => x.LearningDeliveries)
            .Returns(deliveries);

            var handler   = new Mock <IValidationErrorHandler>(MockBehavior.Strict);
            var commonOps = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict);

            commonOps
            .Setup(x => x.HasQualifyingFunding(delivery.Object, 70))     // TypeOfFunding.EuropeanSocialFund
            .Returns(true);

            var eligibilityItem = new Mock <IEsfEligibilityRuleSectorSubjectAreaLevel>();

            eligibilityItem
            .SetupGet(x => x.SectorSubjectAreaCode)
            .Returns((decimal?)area);
            eligibilityItem
            .SetupGet(x => x.MinLevelCode)
            .Returns(min);
            eligibilityItem
            .SetupGet(x => x.MaxLevelCode)
            .Returns(max);
            var fcsData = new Mock <IFCSDataService>(MockBehavior.Strict);

            fcsData
            .Setup(x => x.GetEligibilityRuleSectorSubjectAreaLevelsFor(ContractRefNumber))
            .Returns(new IEsfEligibilityRuleSectorSubjectAreaLevel[] { eligibilityItem.Object });

            var larsItem = new Mock <ILARSLearningDelivery>();

            larsItem
            .SetupGet(x => x.NotionalNVQLevelv2)
            .Returns(notional);
            var larsData = new Mock <ILARSDataService>(MockBehavior.Strict);

            larsData
            .Setup(x => x.GetDeliveryFor(AimRefNumber))
            .Returns(larsItem.Object);

            var sut = new LearnAimRef_72Rule(handler.Object, commonOps.Object, fcsData.Object, larsData.Object);

            // act
            sut.Validate(mockLearner.Object);

            // assert
            handler.VerifyAll();
            commonOps.VerifyAll();
            fcsData.VerifyAll();
            larsData.VerifyAll();
        }
        [InlineData("H", "2", "3")] // fails @ max level
        public void InvalidItemRaisesValidationMessage(string notional, string min, string max)
        {
            // arrange
            const string LearnRefNumber    = "123456789X";
            const string AimRefNumber      = "shonkyAimRef";
            const string ContractRefNumber = "shonkyRefNumber";

            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(y => y.FundModel)
            .Returns(70);     // TypeOfFunding.EuropeanSocialFund
            delivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(AimRefNumber);
            delivery
            .SetupGet(y => y.ConRefNumber)
            .Returns(ContractRefNumber);

            var deliveries = new List <ILearningDelivery> {
                delivery.Object
            };

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            mockLearner
            .SetupGet(x => x.LearningDeliveries)
            .Returns(deliveries);

            var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict);

            handler
            .Setup(x => x.Handle(RuleNameConstants.LearnAimRef_72, LearnRefNumber, 0, It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter("FundModel", 70))     // TypeOfFunding.EuropeanSocialFund
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("ConRefNumber", ContractRefNumber))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var eligibilityItem = new Mock <IEsfEligibilityRuleSectorSubjectAreaLevel>();

            eligibilityItem
            .SetupGet(x => x.MinLevelCode)
            .Returns(min);
            eligibilityItem
            .SetupGet(x => x.MaxLevelCode)
            .Returns(max);

            var fcsData = new Mock <IFCSDataService>(MockBehavior.Strict);

            fcsData
            .Setup(x => x.GetEligibilityRuleSectorSubjectAreaLevelsFor(ContractRefNumber))
            .Returns(new IEsfEligibilityRuleSectorSubjectAreaLevel[] { eligibilityItem.Object });

            var larsItem = new Mock <ILARSLearningDelivery>();

            larsItem
            .SetupGet(x => x.NotionalNVQLevelv2)
            .Returns(notional);

            var larsData = new Mock <ILARSDataService>(MockBehavior.Strict);

            larsData
            .Setup(x => x.GetDeliveryFor(AimRefNumber))
            .Returns(larsItem.Object);

            var sut = new LearnAimRef_72Rule(handler.Object, fcsData.Object, larsData.Object);

            // act
            sut.Validate(mockLearner.Object);

            // assert
            handler.VerifyAll();
            fcsData.VerifyAll();
            larsData.VerifyAll();
        }