Esempio n. 1
0
        public void ValidItemDoesNotRaiseValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";
            const string learnAimRef    = "salddfkjeifdnase";

            var mockFAM = new Mock <ILearningDeliveryFAM>();

            mockFAM
            .SetupGet(x => x.LearnDelFAMType)
            .Returns(Monitoring.Delivery.Types.FullOrCoFunding);

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

            fams.Add(mockFAM.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(learnAimRef);
            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(DateTime.Parse("2017-08-01"));
            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(TypeOfFunding.AdultSkills);
            mockDelivery
            .SetupGet(y => y.LearningDeliveryFAMs)
            .Returns(fams.AsSafeReadOnlyList());

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

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            var sut = new LearnDelFAMType_63Rule(handler.Object, service.Object);

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

            // assert
            handler.VerifyAll();
            service.VerifyAll();
        }
Esempio n. 2
0
        public void InvalidItemRaisesValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";
            const string learnAimRef    = "salddfkjeifdnase";

            var mockFAM = new Mock <ILearningDeliveryFAM>();

            mockFAM
            .SetupGet(x => x.LearnDelFAMType)
            .Returns(Monitoring.Delivery.Types.ApprenticeshipContract);

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

            fams.Add(mockFAM.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(learnAimRef);
            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(DateTime.Parse("2017-08-01"));
            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(TypeOfFunding.AdultSkills);
            mockDelivery
            .SetupGet(y => y.LearningDeliveryFAMs)
            .Returns(fams.AsSafeReadOnlyList());

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

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            handler
            .Setup(x => x.Handle(
                       Moq.It.Is <string>(y => y == LearnDelFAMType_63Rule.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 == LearnDelFAMType_63Rule.MessagePropertyName),
                       Moq.It.IsAny <ILearningDelivery>()))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var service = new Mock <ILARSDataService>(MockBehavior.Strict);

            var sut = new LearnDelFAMType_63Rule(handler.Object, service.Object);

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

            // assert
            handler.VerifyAll();
            service.VerifyAll();
        }