public void Validate_NoErrors_FundModel()
        {
            var learner = new TestLearner()
            {
                ULNNullable        = 9999999999,
                LearningDeliveries = new TestLearningDelivery[]
                {
                    new 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);

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

            rule.Validate(learner);
        }
Пример #2
0
        public void ValidItemDoesNotRaiseValidationMessage()
        {
            const string LearnRefNumber = "123456789X";
            var          mockFam        = new Mock <ILearningDeliveryFAM>();

            mockFam
            .SetupGet(y => y.LearnDelFAMType)
            .Returns(Monitoring.Delivery.Types.SourceOfFunding);
            mockFam
            .SetupGet(y => y.LearnDelFAMCode)
            .Returns("1");

            var fams = new List <ILearningDeliveryFAM>();

            fams.Add(mockFam.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(FundModels.NotFundedByESFA);
            mockDelivery
            .SetupGet(y => y.LearningDeliveryFAMs)
            .Returns(fams);
            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(DateTime.Parse("2019-03-02"));
            mockDelivery
            .SetupGet(x => x.LearnPlanEndDate)
            .Returns(DateTime.Parse("2019-05-02"));

            var deliveries = new List <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            mockLearner
            .SetupGet(y => y.ULN)
            .Returns(9999999999);
            mockLearner
            .SetupGet(y => y.LearningDeliveries)
            .Returns(deliveries);

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

            fileData
            .Setup(xc => xc.FilePreparationDate())
            .Returns(DateTime.Parse("2019-01-02"));

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

            yearService
            .Setup(xc => xc.JanuaryFirst())
            .Returns(DateTime.Parse("2019-01-01"));

            var sut = new ULN_11Rule(handler.Object, fileData.Object, yearService.Object);

            sut.Validate(mockLearner.Object);

            handler.VerifyAll();
            fileData.VerifyAll();
            yearService.VerifyAll();
        }
Пример #3
0
        public void InvalidItemRaisesValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";
            var          mockFam        = new Mock <ILearningDeliveryFAM>();

            mockFam
            .SetupGet(y => y.LearnDelFAMType)
            .Returns(Monitoring.Delivery.Types.SourceOfFunding);
            mockFam
            .SetupGet(y => y.LearnDelFAMCode)
            .Returns("1");

            var fams = Collection.Empty <ILearningDeliveryFAM>();

            fams.Add(mockFam.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(TypeOfFunding.NotFundedByESFA);
            mockDelivery
            .SetupGet(y => y.LearningDeliveryFAMs)
            .Returns(fams.AsSafeReadOnlyList());
            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(DateTime.Parse("2019-04-02"));
            mockDelivery
            .SetupGet(x => x.LearnPlanEndDate)
            .Returns(DateTime.Parse("2019-05-02"));

            var deliveries = Collection.Empty <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            mockLearner
            .SetupGet(y => y.ULN)
            .Returns(9999999999);
            mockLearner
            .SetupGet(y => y.LearningDeliveries)
            .Returns(deliveries.AsSafeReadOnlyList());

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

            handler
            .Setup(x => x.Handle(
                       Moq.It.Is <string>(y => y == ULN_11Rule.Name),
                       Moq.It.Is <string>(y => y == LearnRefNumber),
                       0,
                       Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == ULN_11Rule.MessagePropertyName),
                       Moq.It.IsAny <ILearningDelivery>()))
            .Returns(new Mock <IErrorMessageParameter>().Object);

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

            fileData
            .Setup(xc => xc.FilePreparationDate())
            .Returns(DateTime.Parse("2019-01-02"));

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

            yearService
            .Setup(xc => xc.JanuaryFirst())
            .Returns(DateTime.Parse("2019-01-01"));

            var sut = new ULN_11Rule(handler.Object, fileData.Object, yearService.Object);

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

            // assert
            handler.VerifyAll();
            fileData.VerifyAll();
            yearService.VerifyAll();
        }