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

            var todayDate         = DateTime.Parse("2018-09-28");
            var empStartDate      = DateTime.Parse(empStart);
            var nextYearStartDate = DateTime.Parse(nextYearStart);

            var mockStatus = new Mock <ILearnerEmploymentStatus>();

            mockStatus
            .SetupGet(y => y.DateEmpStatApp)
            .Returns(empStartDate);

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

            statii.Add(mockStatus.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            handler
            .Setup(x => x.Handle(
                       Moq.It.Is <string>(y => y == DateEmpStatApp_01Rule.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 == "DateEmpStatApp"),
                       empStartDate))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var yearData = new Mock <IAcademicYearDataService>(MockBehavior.Strict);

            yearData
            .SetupGet(x => x.Today)
            .Returns(todayDate);
            yearData
            .Setup(x => x.GetAcademicYearOfLearningDate(todayDate, AcademicYearDates.NextYearCommencement))
            .Returns(nextYearStartDate);

            var sut = new DateEmpStatApp_01Rule(handler.Object, yearData.Object);

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

            // assert
            handler.VerifyAll();
            yearData.VerifyAll();
        }
        public void InvalidItemRaisesValidationMessage(string empStart, string yearEnd)
        {
            const string LearnRefNumber = "123456789X";

            var empStartDate = DateTime.Parse(empStart);
            var yearEndDate  = DateTime.Parse(yearEnd);

            var mockStatus = new Mock <ILearnerEmploymentStatus>();

            mockStatus
            .SetupGet(y => y.DateEmpStatApp)
            .Returns(empStartDate);

            var statii = new List <ILearnerEmploymentStatus>();

            statii.Add(mockStatus.Object);

            var learner = new Mock <ILearner>();

            learner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            learner
            .SetupGet(x => x.LearnerEmploymentStatuses)
            .Returns(statii);

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

            handler
            .Setup(x => x.Handle("DateEmpStatApp_01", LearnRefNumber, null, Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter("DateEmpStatApp", AbstractRule.AsRequiredCultureDate(empStartDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var yearData = new Mock <IAcademicYearDataService>(MockBehavior.Strict);

            yearData
            .Setup(x => x.End())
            .Returns(yearEndDate);

            var sut = new DateEmpStatApp_01Rule(handler.Object, yearData.Object);

            sut.Validate(learner.Object);

            handler.VerifyAll();
            yearData.VerifyAll();
        }
        public void ValidItemDoesNotRaiseValidationMessage(string empStart, string yearEnd)
        {
            const string LearnRefNumber = "123456789X";

            var empStartDate = DateTime.Parse(empStart);
            var yearEndDate  = DateTime.Parse(yearEnd);

            var mockStatus = new Mock <ILearnerEmploymentStatus>();

            mockStatus
            .SetupGet(y => y.DateEmpStatApp)
            .Returns(empStartDate);

            var statii = new List <ILearnerEmploymentStatus>();

            statii.Add(mockStatus.Object);

            var learner = new Mock <ILearner>();

            learner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            learner
            .SetupGet(x => x.LearnerEmploymentStatuses)
            .Returns(statii);

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

            yearData
            .Setup(x => x.End())
            .Returns(yearEndDate);

            var sut = new DateEmpStatApp_01Rule(handler.Object, yearData.Object);

            sut.Validate(learner.Object);

            handler.VerifyAll();
            yearData.VerifyAll();
        }