示例#1
0
        public void ValidItemDoesNotRaiseAValidationMessage()
        {
            const string LearnRefNumber = "123456789X";

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.CompStatus)
            .Returns(CompletionState.HasWithdrawn);
            mockDelivery
            .SetupGet(x => x.WithdrawReasonNullable)
            .Returns(ReasonForWithdrawal.TransferredDueToMerger);

            var deliveries = new List <ILearningDelivery>
            {
                mockDelivery.Object
            };

            var mockLearner = new Mock <ILearner>();

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

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

            var sut = new WithdrawReason_03Rule(mockHandler.Object);

            sut.Validate(mockLearner.Object);

            mockHandler.VerifyAll();
        }
示例#2
0
        public void InvalidItemRaisesValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.CompStatus)
            .Returns(CompletionState.HasWithdrawn);

            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 mockHandler = new Mock <IValidationErrorHandler>(MockBehavior.Strict);

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

            var sut = new WithdrawReason_03Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }
示例#3
0
        public void InvalidItemRaisesValidationMessage()
        {
            const string LearnRefNumber = "123456789X";

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.CompStatus)
            .Returns(3);
            mockDelivery
            .SetupGet(x => x.AimSeqNumber)
            .Returns(0);

            var deliveries = new List <ILearningDelivery>
            {
                mockDelivery.Object
            };

            var mockLearner = new Mock <ILearner>();

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

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

            mockHandler
            .Setup(x => x.Handle(RuleNameConstants.WithdrawReason_03, LearnRefNumber, 0, Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter("CompStatus", "3"))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new WithdrawReason_03Rule(mockHandler.Object);

            sut.Validate(mockLearner.Object);

            mockHandler.VerifyAll();
        }