public void ValidItemDoesNotRaiseAValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mock = new Mock <ILearner>();

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

            var mockHE = new Mock <ILearnerHE>();

            mock.SetupGet(x => x.LearnerHEEntity).Returns(mockHE.Object);

            var mockDelivery   = new Mock <ILearningDelivery>();
            var mockDeliveryHE = new Mock <ILearningDeliveryHE>();

            mockDelivery.SetupGet(x => x.LearningDeliveryHEEntity)
            .Returns(mockDeliveryHE.Object);

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

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

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

            var sut = new LearnerHE_02Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }
        public void InvalidItemRaisesValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mock = new Mock <ILearner>();

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

            var mockHE = new Mock <ILearnerHE>();

            mock.SetupGet(x => x.LearnerHEEntity).Returns(mockHE.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

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

            mock.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 == LearnerHE_02Rule.Name),
                                  Moq.It.Is <string>(y => y == LearnRefNumber),
                                  null,
                                  Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));

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

            var sut = new LearnerHE_02Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }