Esempio n. 1
0
        public void ValidItemDoesNotRaiseAValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";
            const int    learnerULN     = 999999;
            const int    dAndP__ULN     = 999999;

            var dAndP = new Mock <ILearnerDestinationAndProgression>();

            dAndP
            .SetupGet(y => y.LearnRefNumber)
            .Returns(LearnRefNumber);
            dAndP
            .SetupGet(y => y.ULN)
            .Returns(dAndP__ULN);

            var learner = new Mock <ILearner>();

            learner
            .SetupGet(y => y.LearnRefNumber)
            .Returns(LearnRefNumber);
            learner
            .SetupGet(y => y.ULN)
            .Returns(learnerULN);

            var records = Collection.Empty <ILearnerDestinationAndProgression>();

            records.Add(dAndP.Object);

            var learners = Collection.Empty <ILearner>();

            learners.Add(learner.Object);

            var message = new Mock <IMessage>();

            message
            .SetupGet(y => y.Learners)
            .Returns(learners.AsSafeReadOnlyList());
            message
            .SetupGet(x => x.LearnerDestinationAndProgressions)
            .Returns(records.AsSafeReadOnlyList());

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

            var sut = new R85Rule(handler.Object);

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

            // assert
            handler.VerifyAll();
        }
Esempio n. 2
0
        public void InvalidItemRaisesValidationMessage()
        {
            const string LearnRefNumber = "123456789X";
            const long   learnerULN     = 999998;
            const long   dAndP__ULN     = 999999;

            var learner = new Mock <ILearner>();

            learner
            .SetupGet(y => y.LearnRefNumber)
            .Returns(LearnRefNumber);
            learner
            .SetupGet(y => y.ULN)
            .Returns(learnerULN);

            var learners = new List <ILearner>();

            learners.Add(learner.Object);

            var dAndP = new Mock <ILearnerDestinationAndProgression>();

            dAndP
            .SetupGet(y => y.LearnRefNumber)
            .Returns(LearnRefNumber);
            dAndP
            .SetupGet(y => y.ULN)
            .Returns(dAndP__ULN);

            var records = new List <ILearnerDestinationAndProgression>();

            records.Add(dAndP.Object);

            var message = new Mock <IMessage>();

            message
            .SetupGet(y => y.Learners)
            .Returns(learners);
            message
            .SetupGet(x => x.LearnerDestinationAndProgressions)
            .Returns(records);

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

            handler
            .Setup(x => x.Handle(R85Rule.Name, LearnRefNumber, null, Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter("ULN", learnerULN))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("LearnerDestinationandProgression.ULN", dAndP__ULN))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("LearnerDestinationandProgression.LearnRefNumber", LearnRefNumber))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new R85Rule(handler.Object);

            sut.Validate(message.Object);

            handler.VerifyAll();
        }