public void Validate_NoErrors_FundModel()
        {
            var fileDataMock = new Mock <IFileData>();

            var learner = new MessageLearner()
            {
                ULN = 9999999999,
                LearningDelivery = new MessageLearnerLearningDelivery[]
                {
                    new MessageLearnerLearningDelivery()
                    {
                        FundModel                 = 100,
                        LearnStartDate            = new DateTime(2018, 1, 2),
                        LearnStartDateSpecified   = true,
                        LearnPlanEndDate          = new DateTime(2017, 1, 7),
                        LearnPlanEndDateSpecified = true,
                        LearnActEndDate           = new DateTime(2018, 1, 7),
                        LearnActEndDateSpecified  = true,
                    }
                }
            };

            fileDataMock.SetupGet(fd => fd.FilePreparationDate).Returns(new DateTime(2018, 1, 1));

            var rule = new ULN_06Rule(fileDataMock.Object, null);

            rule.Validate(learner);
        }
        public void Validate_Errors()
        {
            var fileDataMock = new Mock <IFileData>();
            var validationErrorHandlerMock = new Mock <IValidationErrorHandler <MessageLearner> >();

            var learner = new MessageLearner()
            {
                ULN = 9999999999,
                LearningDelivery = new MessageLearnerLearningDelivery[]
                {
                    new MessageLearnerLearningDelivery()
                    {
                        FundModel                 = 25,
                        LearnStartDate            = new DateTime(2018, 1, 2),
                        LearnStartDateSpecified   = true,
                        LearnPlanEndDate          = new DateTime(2017, 1, 7),
                        LearnPlanEndDateSpecified = true,
                        LearnActEndDate           = new DateTime(2018, 1, 7),
                        LearnActEndDateSpecified  = true,
                    }
                }
            };

            fileDataMock.SetupGet(fd => fd.FilePreparationDate).Returns(new DateTime(2018, 1, 1));

            Expression <Action <IValidationErrorHandler <MessageLearner> > > handle = veh => veh.Handle(learner, "ULN_06");

            validationErrorHandlerMock.Setup(handle);

            var rule = new ULN_06Rule(fileDataMock.Object, validationErrorHandlerMock.Object);

            rule.Validate(learner);

            validationErrorHandlerMock.Verify(handle, Times.Exactly(1));
        }
        public void Validate_NoErrors_FundModel()
        {
            var learner = new ILR.Tests.Model.TestLearner()
            {
                ULNNullable        = 9999999999,
                LearningDeliveries = new ILR.Tests.Model.TestLearningDelivery[]
                {
                    new ILR.Tests.Model.TestLearningDelivery()
                    {
                        FundModelNullable        = 100,
                        LearnStartDateNullable   = new DateTime(2018, 1, 2),
                        LearnPlanEndDateNullable = new DateTime(2017, 1, 7),
                        LearnActEndDateNullable  = new DateTime(2018, 1, 7),
                    }
                }
            };

            var fileDataMock       = new Mock <IFileDataService>();
            var validationDataMock = new Mock <IValidationDataService>();
            var learningDeliveryFAMQueryServiceMock = new Mock <ILearningDeliveryFAMQueryService>();

            fileDataMock.SetupGet(fd => fd.FilePreparationDate).Returns(new DateTime(2018, 1, 1));
            validationDataMock.SetupGet(vd => vd.AcademicYearJanuaryFirst).Returns(new DateTime(2018, 1, 1));
            learningDeliveryFAMQueryServiceMock.Setup(qs => qs.HasLearningDeliveryFAMCodeForType(It.IsAny <IEnumerable <ILearningDeliveryFAM> >(), "LDM", "034")).Returns(false);
            learningDeliveryFAMQueryServiceMock.Setup(qs => qs.HasLearningDeliveryFAMCodeForType(It.IsAny <IEnumerable <ILearningDeliveryFAM> >(), "ACT", "1")).Returns(false);

            var rule = new ULN_06Rule(fileDataMock.Object, validationDataMock.Object, learningDeliveryFAMQueryServiceMock.Object, null);

            rule.Validate(learner);
        }
Пример #4
0
        public void ValidItemDoesNotRaiseValidationMessage()
        {
            const string LearnRefNumber = "123456789X";

            var testStart = DateTime.Parse("2016-05-01");
            var testEnd   = DateTime.Parse("2017-05-01");

            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(y => y.FundModel)
            .Returns(99);
            delivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(testStart);
            delivery
            .SetupGet(y => y.LearnPlanEndDate)
            .Returns(testEnd);
            delivery
            .SetupGet(y => y.LearnActEndDateNullable)
            .Returns(DateTime.Today);

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

            var learner = new Mock <ILearner>();

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

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

            var academicYear = new Mock <IAcademicYearDataService>(MockBehavior.Strict);

            academicYear
            .Setup(x => x.JanuaryFirst())
            .Returns(TestNewYearDate);

            var dateTime = new Mock <IDateTimeQueryService>(MockBehavior.Strict);

            dateTime
            .Setup(x => x.DaysBetween(It.IsAny <DateTime>(), It.IsAny <DateTime>()))
            .ReturnsInOrder(4, 5, 61);

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

            fileData
            .Setup(x => x.FilePreparationDate())
            .Returns(TestPreparationDate);

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

            learningDeliveryFAMQS
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       delivery.Object.LearningDeliveryFAMs,
                       "LDM",
                       "034"))
            .Returns(false);
            learningDeliveryFAMQS
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       delivery.Object.LearningDeliveryFAMs,
                       "ACT",
                       "1"))
            .Returns(false);
            learningDeliveryFAMQS
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       delivery.Object.LearningDeliveryFAMs,
                       "ADL",
                       "1"))
            .Returns(true);

            var sut = new ULN_06Rule(handler.Object, academicYear.Object, dateTime.Object, fileData.Object, learningDeliveryFAMQS.Object);

            sut.Validate(learner.Object);

            handler.VerifyAll();
            academicYear.VerifyAll();
            dateTime.VerifyAll();
            fileData.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
        }