public void ValidItemDoesNotRaiseValidationMessage_NoEligibility() { // arrange const string LearnRefNumber = "123456789X"; const string AimRefNumber = "ZESF0001"; 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>(); var fcsData = new Mock <IFCSDataService>(); fcsData .Setup(x => x.GetEligibilityRuleSectorSubjectAreaLevelsFor(ContractRefNumber)) .Returns(new IEsfEligibilityRuleSectorSubjectAreaLevel[] { }); var larsItem = new Mock <ILARSLearningDelivery>(); larsItem .SetupGet(x => x.NotionalNVQLevelv2) .Returns("2"); larsItem .SetupGet(x => x.SectorSubjectAreaTier1) .Returns(1m); larsItem .SetupGet(x => x.SectorSubjectAreaTier2) .Returns(2m); var larsData = new Mock <ILARSDataService>(); larsData .Setup(x => x.GetDeliveryFor(deliveries[0].LearnAimRef)) .Returns(larsItem.Object); var sut = new LearnAimRef_73Rule(handler.Object, fcsData.Object, larsData.Object); // act sut.Validate(mockLearner.Object); // assert handler.VerifyAll(); fcsData.VerifyAll(); larsData.VerifyAll(); }
public void ValidItemDoesNotRaiseValidationMessage(string notional, string min, string max, decimal area, decimal tier1, decimal tier2) { // 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(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); larsItem .SetupGet(x => x.SectorSubjectAreaTier1) .Returns(tier1); larsItem .SetupGet(x => x.SectorSubjectAreaTier2) .Returns(tier2); var larsData = new Mock <ILARSDataService>(MockBehavior.Strict); larsData .Setup(x => x.GetDeliveryFor(AimRefNumber)) .Returns(larsItem.Object); var sut = new LearnAimRef_73Rule(handler.Object, commonOps.Object, fcsData.Object, larsData.Object); // act sut.Validate(mockLearner.Object); // assert handler.VerifyAll(); commonOps.VerifyAll(); fcsData.VerifyAll(); larsData.VerifyAll(); }
[InlineData("2", "2", "3", 1.2, 1.1, 1.0)] // fails @ tier2 level public void InvalidItemRaisesValidationMessage(string notional, string min, string max, decimal area, decimal tier1, decimal tier2) { // 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_73, 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.SectorSubjectAreaCode) .Returns(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); larsItem .SetupGet(x => x.SectorSubjectAreaTier1) .Returns(tier1); larsItem .SetupGet(x => x.SectorSubjectAreaTier2) .Returns(tier2); var larsData = new Mock <ILARSDataService>(MockBehavior.Strict); larsData .Setup(x => x.GetDeliveryFor(AimRefNumber)) .Returns(larsItem.Object); var sut = new LearnAimRef_73Rule(handler.Object, fcsData.Object, larsData.Object); // act sut.Validate(mockLearner.Object); // assert handler.VerifyAll(); fcsData.VerifyAll(); larsData.VerifyAll(); }