public void ValidItemDoesNotRaiseValidationMessage() { // arrange const string learnRefNumber = "123456789X"; const string learnAimRef = "salddfkjeifdnase"; var testDate = DateTime.Parse("2016-08-01"); var mockDelivery = new Mock <ILearningDelivery>(); mockDelivery .SetupGet(y => y.LearnAimRef) .Returns(learnAimRef); mockDelivery .SetupGet(y => y.LearnStartDate) .Returns(testDate); mockDelivery .SetupGet(y => y.FundModel) .Returns(TypeOfFunding.AdultSkills); var deliveries = Collection.Empty <ILearningDelivery>(); deliveries.Add(mockDelivery.Object); var mockLearner = new Mock <ILearner>(); mockLearner .SetupGet(x => x.LearnRefNumber) .Returns(learnRefNumber); mockLearner .SetupGet(x => x.LearningDeliveries) .Returns(deliveries.AsSafeReadOnlyList()); var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); // it's this value that triggers the rule var mockCategory = new Mock <ILARSLearningCategory>(); mockCategory .SetupGet(x => x.CategoryRef) .Returns(TypeOfLARSCategory.OnlyForLegalEntitlementAtLevel3); var larsCategories = Collection.Empty <ILARSLearningCategory>(); larsCategories.Add(mockCategory.Object); var mockLars = new Mock <ILARSLearningDelivery>(); mockLars .SetupGet(x => x.NotionalNVQLevelv2) .Returns(LARSNotionalNVQLevelV2.Level3); var service = new Mock <ILARSDataService>(MockBehavior.Strict); service .Setup(x => x.GetDeliveryFor(learnAimRef)) .Returns(mockLars.Object); service .Setup(x => x.GetCategoriesFor(learnAimRef)) .Returns(larsCategories.AsSafeReadOnlyList()); var commonChecks = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict); commonChecks .Setup(x => x.IsRestart(mockDelivery.Object)) .Returns(false); commonChecks .Setup(x => x.IsLearnerInCustody(mockDelivery.Object)) .Returns(false); commonChecks .Setup(x => x.IsSteelWorkerRedundancyTraining(mockDelivery.Object)) .Returns(false); commonChecks .Setup(x => x.InApprenticeship(mockDelivery.Object)) .Returns(false); commonChecks .Setup(x => x.HasQualifyingFunding(mockDelivery.Object, TypeOfFunding.AdultSkills)) .Returns(true); commonChecks .Setup(x => x.HasQualifyingStart(mockDelivery.Object, LearnAimRef_78Rule.FirstViableDate, LearnAimRef_78Rule.LastViableDate)) .Returns(true); var fileData = new Mock <IFileDataService>(MockBehavior.Strict); fileData .Setup(x => x.UKPRN()) .Returns(1004); var orgData = new Mock <IOrganisationDataService>(MockBehavior.Strict); orgData .Setup(x => x.LegalOrgTypeMatchForUkprn(1004, "USDC")) .Returns(false); var sut = new LearnAimRef_78Rule(handler.Object, service.Object, commonChecks.Object, fileData.Object, orgData.Object); // act sut.Validate(mockLearner.Object); // assert handler.VerifyAll(); service.VerifyAll(); commonChecks.VerifyAll(); fileData.VerifyAll(); orgData.VerifyAll(); }
public void ValidItemDoesNotRaiseValidationMessage() { const string learnRefNumber = "123456789X"; const string learnAimRef = "salddfkjeifdnase"; var testDate = DateTime.Parse("2016-08-01"); var mockDelivery = new Mock <ILearningDelivery>(); mockDelivery .SetupGet(y => y.LearnAimRef) .Returns(learnAimRef); mockDelivery .SetupGet(y => y.LearnStartDate) .Returns(testDate); mockDelivery .SetupGet(y => y.FundModel) .Returns(FundModels.AdultSkills); var deliveries = new List <ILearningDelivery>(); deliveries.Add(mockDelivery.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 mockCategory = new Mock <ILARSLearningCategory>(); mockCategory .SetupGet(x => x.CategoryRef) .Returns(LARSConstants.Categories.OnlyForLegalEntitlementAtLevel3); var larsCategories = new List <ILARSLearningCategory>(); larsCategories.Add(mockCategory.Object); var mockLars = new Mock <ILARSLearningDelivery>(); mockLars .SetupGet(x => x.NotionalNVQLevelv2) .Returns(LARSConstants.NotionalNVQLevelV2Strings.Level3); var service = new Mock <ILARSDataService>(MockBehavior.Strict); service .Setup(x => x.GetDeliveryFor(learnAimRef)) .Returns(mockLars.Object); service .Setup(x => x.GetCategoriesFor(learnAimRef)) .Returns(larsCategories); var learningDeliveryFAMQS = new Mock <ILearningDeliveryFAMQueryService>(MockBehavior.Strict); learningDeliveryFAMQS .Setup(x => x.HasLearningDeliveryFAMCodeForType( mockDelivery.Object.LearningDeliveryFAMs, "LDM", "347")) .Returns(false); learningDeliveryFAMQS .Setup(x => x.HasLearningDeliveryFAMCodeForType( mockDelivery.Object.LearningDeliveryFAMs, "LDM", "034")) .Returns(false); learningDeliveryFAMQS .Setup(x => x.HasLearningDeliveryFAMType( mockDelivery.Object.LearningDeliveryFAMs, "RES")) .Returns(false); var fileData = new Mock <IFileDataService>(MockBehavior.Strict); fileData .Setup(x => x.UKPRN()) .Returns(1004); var orgData = new Mock <IOrganisationDataService>(MockBehavior.Strict); orgData .Setup(x => x.LegalOrgTypeMatchForUkprn(1004, "USDC")) .Returns(false); var dd07 = new Mock <IDerivedData_07Rule>(MockBehavior.Strict); dd07 .Setup(dd => dd.IsApprenticeship(mockDelivery.Object.ProgTypeNullable)).Returns(false); var dateTimeQS = new Mock <IDateTimeQueryService>(MockBehavior.Strict); dateTimeQS .Setup(x => x.IsDateBetween(mockDelivery.Object.LearnStartDate, LearnAimRef_78Rule.FirstViableDate, LearnAimRef_78Rule.LastViableDate, true)) .Returns(true); var sut = new LearnAimRef_78Rule(handler.Object, service.Object, learningDeliveryFAMQS.Object, fileData.Object, orgData.Object, dd07.Object, dateTimeQS.Object); sut.Validate(mockLearner.Object); handler.VerifyAll(); service.VerifyAll(); learningDeliveryFAMQS.VerifyAll(); fileData.VerifyAll(); orgData.VerifyAll(); dd07.VerifyAll(); }