Ejemplo n.º 1
0
        public void ValidItemDoesNotRaiseValidationMessage(int funding, int?progType)
        {
            // arrange
            const string learnAimRef = "salddfkjeifdnase";

            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(funding);
            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(progType);

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

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            var validity = new Mock <ILARSValidity>();

            validity
            .SetupGet(x => x.ValidityCategory)
            .Returns(TypeOfLARSValidity.Any);
            validity
            .SetupGet(x => x.StartDate)
            .Returns(DateTime.Parse("2016-04-03"));

            var larsValidities = Collection.Empty <ILARSValidity>();

            larsValidities.Add(validity.Object);

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

            service
            .Setup(x => x.GetValiditiesFor(learnAimRef))
            .Returns(larsValidities.AsSafeReadOnlyList());

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

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

            // assert
            handler.VerifyAll();
            service.VerifyAll();
        }
Ejemplo n.º 2
0
        public void ValidItemThroughExclusionDoesNotRaiseValidationMessage(string famType)
        {
            // arrange
            var mockFAM = new Mock <ILearningDeliveryFAM>();

            mockFAM
            .SetupGet(y => y.LearnDelFAMType)
            .Returns(famType);

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

            fams.Add(mockFAM.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            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.LearningDeliveries)
            .Returns(deliveries.AsSafeReadOnlyList());

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

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

            // assert
            handler.VerifyAll();
            service.VerifyAll();
        }
Ejemplo n.º 3
0
        public void InvalidItemRaisesValidationMessage(int funding, int?progType)
        {
            // arrange
            const string LearnRefNumber = "123456789X";
            const string learnAimRef    = "salddfkjeifdnase";

            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(funding);
            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(progType);

            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 == LearnAimRef_38Rule.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 == LearnAimRef_38Rule.MessagePropertyName),
                       Moq.It.IsAny <ILearningDelivery>()))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var larsValidities = Collection.Empty <ILARSValidity>();

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

            service
            .Setup(x => x.GetValiditiesFor(learnAimRef))
            .Returns(larsValidities.AsSafeReadOnlyList());

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

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

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