Exemple #1
0
        public void Validate_NoErrors()
        {
            var fileDataServiceMock                 = new Mock <IFileDataService>();
            var validationDataServiceMock           = new Mock <IValidationDataService>();
            var validationErrorHandlerMock          = new Mock <IValidationErrorHandler>();
            var learningDeliveryFAMQueryServiceMock = new Mock <ILearningDeliveryFAMQueryService>();

            var messageLearner = new TestLearner()
            {
                ULNNullable        = 1,
                LearningDeliveries = new TestLearningDelivery[]
                {
                    new TestLearningDelivery()
                    {
                        FundModelNullable = 2,
                    }
                }
            };

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

            var rule = new ULN_03Rule(fileDataServiceMock.Object, validationDataServiceMock.Object, learningDeliveryFAMQueryServiceMock.Object, validationErrorHandlerMock.Object);

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

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

            var messageLearner = new MessageLearner()
            {
                ULN = 9999999999,
                LearningDelivery = new MessageLearnerLearningDelivery[]
                {
                    new MessageLearnerLearningDelivery()
                    {
                        FundModel = 25,
                    },
                    new MessageLearnerLearningDelivery()
                    {
                        FundModel = 36,
                    }
                }
            };

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

            validationErrorHandlerMock.Setup(handle);

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

            rule.Validate(messageLearner);

            validationErrorHandlerMock.Verify(handle, Times.Exactly(2));
        }
        public void Validate_NoErrors()
        {
            var fileDataMock = new Mock <IFileData>();
            var validationErrorHandlerMock = new Mock <IValidationErrorHandler <MessageLearner> >();

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

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

            var messageLearner = new MessageLearner()
            {
                ULN = 1,
                LearningDelivery = new MessageLearnerLearningDelivery[]
                {
                    new MessageLearnerLearningDelivery()
                    {
                        FundModel = 2,
                    }
                }
            };

            rule.Validate(messageLearner);
        }
Exemple #4
0
        public void Validate_Errors()
        {
            var messageLearner = new ILR.Tests.Model.TestLearner()
            {
                ULNNullable        = 9999999999,
                LearningDeliveries = new ILR.Tests.Model.TestLearningDelivery[]
                {
                    new ILR.Tests.Model.TestLearningDelivery()
                    {
                        FundModelNullable = 25,
                    },
                    new TestLearningDelivery()
                    {
                        FundModelNullable = 36,
                    }
                }
            };

            var fileDataServiceMock                 = new Mock <IFileDataService>();
            var validationDataServiceMock           = new Mock <IValidationDataService>();
            var validationErrorHandlerMock          = new Mock <IValidationErrorHandler>();
            var learningDeliveryFAMQueryServiceMock = new Mock <ILearningDeliveryFAMQueryService>();

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

            Expression <Action <IValidationErrorHandler> > handle = veh => veh.Handle("ULN_03", null, null, null);

            validationErrorHandlerMock.Setup(handle);

            var rule = new ULN_03Rule(fileDataServiceMock.Object, validationDataServiceMock.Object, learningDeliveryFAMQueryServiceMock.Object, validationErrorHandlerMock.Object);

            rule.Validate(messageLearner);

            validationErrorHandlerMock.Verify(handle, Times.Exactly(2));
        }