public void InvalidItemRaisesValidationMessage(string startDate, string endDate)
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mockLearner = new Mock <ILearner>();

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

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(DateTime.Parse(startDate));
            mockDelivery
            .SetupGet(y => y.LearnPlanEndDate)
            .Returns(DateTime.Parse(endDate));
            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(TypeOfLearningProgramme.Traineeship);
            mockDelivery
            .SetupGet(y => y.AimType)
            .Returns(TypeOfAim.ProgrammeAim);

            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_07Rule.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 == ProgType_07Rule.MessagePropertyName),
                       Moq.It.IsAny <ILearningDelivery>()))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new ProgType_07Rule(mockHandler.Object);

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

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

            var mockLearner = new Mock <ILearner>();

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

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(DateTime.Parse(startDate));
            mockDelivery
            .SetupGet(y => y.LearnPlanEndDate)
            .Returns(DateTime.Parse(endDate));
            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(TypeOfLearningProgramme.Traineeship);
            mockDelivery
            .SetupGet(y => y.AimType)
            .Returns(TypeOfAim.ProgrammeAim);

            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_07Rule(mockHandler.Object);

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

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

            var testStartDate = DateTime.Parse(startDate);
            var testEndDate   = DateTime.Parse(endDate);

            var mockLearner = new Mock <ILearner>();

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

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(testStartDate);
            mockDelivery
            .SetupGet(y => y.LearnPlanEndDate)
            .Returns(testEndDate);
            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(ProgTypes.Traineeship);
            mockDelivery
            .SetupGet(y => y.AimType)
            .Returns(AimTypes.ProgrammeAim);

            var deliveries = new List <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

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

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

            mockHandler.Setup(x => x.Handle(
                                  Moq.It.Is <string>(y => y == ProgType_07Rule.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 == "LearnPlanEndDate"),
                       Moq.It.Is <DateTime>(y => y == testEndDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == "LearnStartDate"),
                       Moq.It.Is <DateTime>(y => y == testStartDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new ProgType_07Rule(mockHandler.Object);

            sut.Validate(mockLearner.Object);

            mockHandler.VerifyAll();
        }