Beispiel #1
0
        public void IsAdultEducationBudgetsMeetsExpectation(string famType, string famCode, bool expectation)
        {
            var fam = new Mock <ILearningDeliveryFAM>();

            fam
            .SetupGet(y => y.LearnDelFAMType)
            .Returns(famType);
            fam
            .SetupGet(y => y.LearnDelFAMCode)
            .Returns(famCode);

            var fams = new List <ILearningDeliveryFAM>
            {
                fam.Object
            };

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearningDeliveryFAMs)
            .Returns(fams);

            var learningDeliveryFAMQS = new Mock <ILearningDeliveryFAMQueryService>(MockBehavior.Strict);

            learningDeliveryFAMQS
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       mockDelivery.Object.LearningDeliveryFAMs,
                       "LDM",
                       "357"))
            .Returns(expectation);

            var handler        = new Mock <IValidationErrorHandler>(MockBehavior.Strict);
            var fcsDataService = new Mock <IFCSDataService>(MockBehavior.Strict);
            var fileData       = new Mock <IFileDataService>(MockBehavior.Strict);

            fileData
            .Setup(x => x.UKPRN())
            .Returns(TestProviderID);

            var result = new UKPRN_19Rule(handler.Object, fileData.Object, learningDeliveryFAMQS.Object, fcsDataService.Object).IsAdultEducationBudgets(mockDelivery.Object);

            Assert.Equal(expectation, result);
        }
Beispiel #2
0
        public void HasFundingRelationshipMeetsExpectation(string candidate, bool expectation)
        {
            var thresholdDate = DateTime.Parse("2017-05-01");

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

            var fileData = new Mock <IFileDataService>(MockBehavior.Strict);

            fileData
            .Setup(x => x.UKPRN())
            .Returns(TestProviderID);

            var allocation = new Mock <IFcsContractAllocation>(MockBehavior.Strict);

            allocation
            .SetupGet(x => x.FundingStreamPeriodCode)
            .Returns(candidate);
            allocation
            .SetupGet(x => x.StartDate)
            .Returns(thresholdDate);

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

            fcsData
            .Setup(x => x.GetContractAllocationsFor(TestProviderID))
            .Returns(new IFcsContractAllocation[] { allocation.Object });

            var sut = new UKPRN_19Rule(handler.Object, fileData.Object, learningDeliveryFAMQS.Object, fcsData.Object);

            var result = sut.HasDisQualifyingFundingRelationship(x => true);

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
            fileData.VerifyAll();
            fcsData.VerifyAll();
        }
Beispiel #3
0
        public void ValidItemMultipleContractsDoesNotRaiseValidationMessage(string candidate)
        {
            const string LearnRefNumber = "123456789X";
            var          thresholdDate  = DateTime.Parse("2017-05-01");

            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(thresholdDate.AddDays(-1));
            delivery
            .SetupGet(y => y.FundModel)
            .Returns(35);

            var deliveries = new ILearningDelivery[] { delivery.Object };

            var learner = new Mock <ILearner>();

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

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

            var fileData = new Mock <IFileDataService>(MockBehavior.Strict);

            fileData
            .Setup(x => x.UKPRN())
            .Returns(TestProviderID);

            var allocation = new Mock <IFcsContractAllocation>(MockBehavior.Strict);

            allocation
            .SetupGet(x => x.FundingStreamPeriodCode)
            .Returns(candidate);
            allocation
            .SetupGet(x => x.StopNewStartsFromDate)
            .Returns(thresholdDate.AddDays(-1));
            allocation
            .SetupGet(x => x.StartDate)
            .Returns(thresholdDate);

            var allocation2 = new Mock <IFcsContractAllocation>(MockBehavior.Strict);

            allocation2
            .SetupGet(x => x.FundingStreamPeriodCode)
            .Returns(candidate);
            allocation2
            .SetupGet(x => x.StopNewStartsFromDate)
            .Returns((DateTime?)null);
            allocation2
            .SetupGet(x => x.StartDate)
            .Returns(thresholdDate.AddDays(1));

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

            fcsData
            .Setup(x => x.GetContractAllocationsFor(TestProviderID))
            .Returns(new IFcsContractAllocation[] { allocation.Object, allocation2.Object });

            var learningDeliveryFamqs = new Mock <ILearningDeliveryFAMQueryService>(MockBehavior.Strict);

            learningDeliveryFamqs
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       delivery.Object.LearningDeliveryFAMs,
                       "SOF",
                       "105"))
            .Returns(true);
            learningDeliveryFamqs
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       delivery.Object.LearningDeliveryFAMs,
                       "LDM",
                       "357"))
            .Returns(true);

            learningDeliveryFamqs
            .Setup(x => x.HasLearningDeliveryFAMType(
                       delivery.Object.LearningDeliveryFAMs,
                       "RES"))
            .Returns(false);

            var sut = new UKPRN_19Rule(handler.Object, fileData.Object, learningDeliveryFamqs.Object, fcsData.Object);

            sut.Validate(learner.Object);

            handler.VerifyAll();
            learningDeliveryFamqs.VerifyAll();
            fileData.VerifyAll();
            fcsData.VerifyAll();
        }
Beispiel #4
0
        public void InvalidItemRaisesValidationMessage(string candidate)
        {
            const string LearnRefNumber = "123456789X";
            var          thresholdDate  = DateTime.Parse("2017-05-01");

            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(thresholdDate);
            delivery
            .SetupGet(y => y.FundModel)
            .Returns(35);
            delivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(7);

            var deliveries = new ILearningDelivery[] { delivery.Object };

            var learner = new Mock <ILearner>();

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

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

            handler
            .Setup(x => x.Handle(RuleNameConstants.UKPRN_19, LearnRefNumber, 0, It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter("UKPRN", TestProviderID))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("FundModel", 35))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("LearnStartDate", AbstractRule.AsRequiredCultureDate(thresholdDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("LearnDelFAMType", "LDM"))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("LearnDelFAMCode", "357"))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var fileData = new Mock <IFileDataService>(MockBehavior.Strict);

            fileData
            .Setup(x => x.UKPRN())
            .Returns(TestProviderID);

            var allocation = new Mock <IFcsContractAllocation>(MockBehavior.Strict);

            allocation
            .SetupGet(x => x.FundingStreamPeriodCode)
            .Returns(candidate);
            allocation
            .SetupGet(x => x.StopNewStartsFromDate)
            .Returns(thresholdDate);
            allocation
            .SetupGet(x => x.StartDate)
            .Returns(thresholdDate);

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

            fcsData
            .Setup(x => x.GetContractAllocationsFor(TestProviderID))
            .Returns(new IFcsContractAllocation[] { allocation.Object });

            var learningDeliveryFamqs = new Mock <ILearningDeliveryFAMQueryService>(MockBehavior.Strict);

            learningDeliveryFamqs
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       delivery.Object.LearningDeliveryFAMs,
                       "SOF",
                       "105"))
            .Returns(true);
            learningDeliveryFamqs
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       delivery.Object.LearningDeliveryFAMs,
                       "LDM",
                       "357"))
            .Returns(true);

            learningDeliveryFamqs
            .Setup(x => x.HasLearningDeliveryFAMType(
                       delivery.Object.LearningDeliveryFAMs,
                       "RES"))
            .Returns(false);

            var sut = new UKPRN_19Rule(handler.Object, fileData.Object, learningDeliveryFamqs.Object, fcsData.Object);

            sut.Validate(learner.Object);

            handler.VerifyAll();
            learningDeliveryFamqs.VerifyAll();
            fileData.VerifyAll();
            fcsData.VerifyAll();
        }