Exemple #1
0
        public void InvalidItemRaisesValidationMessage(int aimType, int aimSeqNumber, int?progType)
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.AimType)
            .Returns(aimType);
            mockDelivery
            .SetupGet(x => x.AimSeqNumber)
            .Returns(aimSeqNumber);
            mockDelivery
            .SetupGet(x => x.ProgTypeNullable)
            .Returns(progType);

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

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

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

            mockHandler.Setup(x => x.Handle(
                                  Moq.It.Is <string>(y => y == ProgType_01Rule.Name),
                                  Moq.It.Is <string>(y => y == LearnRefNumber),
                                  aimSeqNumber,
                                  Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));

            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == ProgType_01Rule.MessagePropertyName),
                       Moq.It.Is <object>(y => y == mockDelivery.Object)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new ProgType_01Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }
Exemple #2
0
        [InlineData(TypeOfAim.CoreAim16To19ExcludingApprenticeships, 6, null)] // valid because it's 'out of scope'
        public void ValidItemDoesNotRaiseAValidationMessage(int aimType, int aimSeqNumber, int?progType)
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.AimType)
            .Returns(aimType);
            mockDelivery
            .SetupGet(x => x.AimSeqNumber)
            .Returns(aimSeqNumber);
            mockDelivery
            .SetupGet(x => x.ProgTypeNullable)
            .Returns(progType);

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

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

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

            var sut = new ProgType_01Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }