public void InvalidItemRaisesValidationMessage() { const string LearnRefNumber = "123456789X"; var mockDelivery = new Mock <ILearningDelivery>(); mockDelivery .SetupGet(x => x.CompStatus) .Returns(3); mockDelivery .SetupGet(x => x.WithdrawReasonNullable) .Returns(48); mockDelivery .SetupGet(x => x.LearnAimRef) .Returns("ZWRKX001"); var deliveries = new 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_06, LearnRefNumber, 0, It.IsAny <IEnumerable <IErrorMessageParameter> >())); mockHandler .Setup(x => x.BuildErrorMessageParameter("LearnAimRef", "ZWRKX001")) .Returns(new Mock <IErrorMessageParameter>().Object); mockHandler .Setup(x => x.BuildErrorMessageParameter("WithdrawReason", 48)) .Returns(new Mock <IErrorMessageParameter>().Object); var sut = new WithdrawReason_06Rule(mockHandler.Object); sut.Validate(mockLearner.Object); mockHandler.VerifyAll(); }
public void ValidItemDoesNotRaiseAValidationMessage() { const string LearnRefNumber = "123456789X"; var mockDelivery = new Mock <ILearningDelivery>(); mockDelivery .SetupGet(x => x.CompStatus) .Returns(3); mockDelivery .SetupGet(x => x.WithdrawReasonNullable) .Returns(48); mockDelivery .SetupGet(x => x.LearnAimRef) .Returns("ZWRKX002"); var deliveries = new 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_06Rule(mockHandler.Object); sut.Validate(mockLearner.Object); mockHandler.VerifyAll(); }