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_02Rule.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"),
                       Moq.It.Is <int?>(y => y == progType)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == "AimType"),
                       Moq.It.Is <int>(y => y == aimType)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new ProgType_02Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }
        [InlineData(TypeOfAim.CoreAim16To19ExcludingApprenticeships, 7, 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_02Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }
示例#3
0
        public void ValidItemDoesNotRaiseAValidationMessage(int aimType, int aimSeqNumber, int?progType)
        {
            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 = new List <ILearningDelivery>
            {
                mockDelivery.Object
            };

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

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

            var sut = new ProgType_02Rule(mockHandler.Object);

            sut.Validate(mockLearner.Object);

            mockHandler.VerifyAll();
        }