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 status = new Mock <ILearnerEmploymentStatus>();

            status
            .SetupGet(x => x.EmpStat)
            .Returns(TypeOfEmploymentStatus.InPaidEmployment);
            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_05Rule(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 status = new Mock <ILearnerEmploymentStatus>();

            status
            .SetupGet(x => x.EmpStat)
            .Returns(TypeOfEmploymentStatus.InPaidEmployment);
            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_05Rule.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_05Rule.MessagePropertyName),
                       Monitoring.EmploymentStatus.Types.LengthOfUnemployment))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PropertyNameConstants.EmpStat),
                       TypeOfEmploymentStatus.InPaidEmployment))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new ESMType_05Rule(handler.Object);

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

            // assert
            handler.VerifyAll();
        }