Ejemplo n.º 1
0
        [InlineData("ACT", 1)] // Monitoring.Delivery.Types.ApprenticeshipContract
        public void InvalidItemRaisesValidationMessage(string famType, int dateOffset)
        {
            // arrange
            const string learnRefNumber = "123456789X";

            var testDate = DateTime.Parse("2017-12-30");

            var fam = new Mock <ILearningDeliveryFAM>();

            fam
            .SetupGet(x => x.LearnDelFAMType)
            .Returns(famType);
            fam
            .SetupGet(x => x.LearnDelFAMDateToNullable)
            .Returns(testDate.AddDays(dateOffset));

            var fams = new ILearningDeliveryFAM[] { fam.Object };

            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(x => x.AchDateNullable)
            .Returns(testDate);
            delivery
            .SetupGet(x => x.FundModel)
            .Returns(36);     // TypeOfFunding.ApprenticeshipsFrom1May2017
            delivery
            .SetupGet(x => x.LearningDeliveryFAMs)
            .Returns(fams);

            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.LearnDelFAMDateTo_05, learnRefNumber, 0, It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter("AchDate", AbstractRule.AsRequiredCultureDate(testDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("LearnDelFAMDateTo", AbstractRule.AsRequiredCultureDate(testDate.AddDays(dateOffset))))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new LearnDelFAMDateTo_05Rule(handler.Object);

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

            // assert
            handler.VerifyAll();
        }
Ejemplo n.º 2
0
        [InlineData("WPP", 1)] // Monitoring.Delivery.Types.WorkProgrammeParticipation
        public void ValidItemDoesNotRaiseValidationMessage(string famType, int dateOffset)
        {
            // arrange
            const string learnRefNumber = "123456789X";

            var testDate = DateTime.Parse("2017-12-30");

            var fam = new Mock <ILearningDeliveryFAM>();

            fam
            .SetupGet(x => x.LearnDelFAMType)
            .Returns(famType);
            fam
            .SetupGet(x => x.LearnDelFAMDateToNullable)
            .Returns(testDate.AddDays(dateOffset));

            var fams = new ILearningDeliveryFAM[] { fam.Object };

            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(x => x.AchDateNullable)
            .Returns(testDate);
            delivery
            .SetupGet(x => x.FundModel)
            .Returns(36);     // TypeOfFunding.ApprenticeshipsFrom1May2017
            delivery
            .SetupGet(x => x.LearningDeliveryFAMs)
            .Returns(fams);

            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 sut = new LearnDelFAMDateTo_05Rule(handler.Object);

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

            // assert
            handler.VerifyAll();
        }