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

            var monitor = new Mock <IEmploymentStatusMonitoring>();

            monitor
            .SetupGet(y => y.ESMType)
            .Returns(candidate.Substring(0, 3));
            monitor
            .SetupGet(y => y.ESMCode)
            .Returns(int.Parse(candidate.Substring(3)));

            var monitorings = Collection.Empty <IEmploymentStatusMonitoring>();

            monitorings.Add(monitor.Object);

            var testDate = DateTime.Parse("2016-6-14");
            var status   = new Mock <ILearnerEmploymentStatus>();

            status
            .SetupGet(x => x.DateEmpStatApp)
            .Returns(testDate);
            status
            .SetupGet(x => x.EmpStat)
            .Returns(TypeOfEmploymentStatus.NotEmployedNotSeekingOrNotAvailable);
            status
            .SetupGet(x => x.EmploymentStatusMonitorings)
            .Returns(monitorings.AsSafeReadOnlyList());

            var statii = Collection.Empty <ILearnerEmploymentStatus>();

            statii.Add(status.Object);

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            mockLearner
            .SetupGet(y => y.LearnerEmploymentStatuses)
            .Returns(statii.AsSafeReadOnlyList());

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

            var sut = new ESMType_10Rule(handler.Object);

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

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

            var monitor = new Mock <IEmploymentStatusMonitoring>();

            monitor
            .SetupGet(y => y.ESMType)
            .Returns(candidate.Substring(0, 3));
            monitor
            .SetupGet(y => y.ESMCode)
            .Returns(int.Parse(candidate.Substring(3)));

            var monitorings = Collection.Empty <IEmploymentStatusMonitoring>();

            monitorings.Add(monitor.Object);

            var testDate = DateTime.Parse("2016-6-14");
            var status   = new Mock <ILearnerEmploymentStatus>();

            status
            .SetupGet(x => x.DateEmpStatApp)
            .Returns(testDate);
            status
            .SetupGet(x => x.EmpStat)
            .Returns(TypeOfEmploymentStatus.NotEmployedNotSeekingOrNotAvailable);
            status
            .SetupGet(x => x.EmploymentStatusMonitorings)
            .Returns(monitorings.AsSafeReadOnlyList());

            var statii = Collection.Empty <ILearnerEmploymentStatus>();

            statii.Add(status.Object);

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            mockLearner
            .SetupGet(y => y.LearnerEmploymentStatuses)
            .Returns(statii.AsSafeReadOnlyList());

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

            handler
            .Setup(x => x.Handle(
                       Moq.It.Is <string>(y => y == ESMType_10Rule.Name),
                       Moq.It.Is <string>(y => y == LearnRefNumber),
                       null,
                       Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == ESMType_10Rule.MessagePropertyName),
                       Monitoring.EmploymentStatus.Types.LengthOfEmployment))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == "EmpStat"),
                       TypeOfEmploymentStatus.NotEmployedNotSeekingOrNotAvailable))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == "DateEmpStatApp"),
                       testDate))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new ESMType_10Rule(handler.Object);

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

            // assert
            handler.VerifyAll();
        }