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

            var testDate = DateTime.Parse("2013-08-01");

            var status = new Mock <ILearnerEmploymentStatus>();

            var employmentStatuses = new ILearnerEmploymentStatus[] { status.Object };

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(testDate);
            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(25);
            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(25);

            var deliveries = new ILearningDelivery[] { mockDelivery.Object };

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            mockLearner
            .SetupGet(x => x.LearningDeliveries)
            .Returns(deliveries);
            mockLearner
            .SetupGet(y => y.LearnerEmploymentStatuses)
            .Returns(employmentStatuses);

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

            var dateTimeQS = new Mock <IDateTimeQueryService>(MockBehavior.Strict);

            dateTimeQS
            .Setup(x => x.IsDateBetween(mockDelivery.Object.LearnStartDate, EmpStat_06Rule.FirstViableDate, EmpStat_06Rule.LastViableDate, true))
            .Returns(true);

            var lEmpQS = new Mock <ILearnerEmploymentStatusQueryService>(MockBehavior.Strict);

            lEmpQS
            .Setup(x => x.LearnerEmploymentStatusForDate(employmentStatuses, testDate))
            .Returns(status.Object);

            var sut = new EmpStat_06Rule(handler.Object, dateTimeQS.Object, lEmpQS.Object);

            sut.Validate(mockLearner.Object);

            handler.VerifyAll();
            dateTimeQS.VerifyAll();
        }
        public void ValidItemDoesNotRaiseValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var testDate = DateTime.Parse("2013-08-01");

            var status = new Mock <ILearnerEmploymentStatus>();

            var statii = new ILearnerEmploymentStatus[] { status.Object };

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(testDate);

            var deliveries = new ILearningDelivery[] { mockDelivery.Object };

            var mockLearner = new Mock <ILearner>();

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

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

            var commonOps = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict);

            commonOps
            .Setup(x => x.GetEmploymentStatusOn(testDate, statii))
            .Returns(status.Object);
            commonOps
            .Setup(x => x.HasQualifyingFunding(mockDelivery.Object, 25, 82))
            .Returns(true);
            commonOps
            .Setup(x => x.HasQualifyingStart(mockDelivery.Object, DateTime.Parse("2013-08-01"), DateTime.Parse("2014-07-31")))
            .Returns(true);
            commonOps
            .Setup(x => x.IsTraineeship(mockDelivery.Object))
            .Returns(false);

            var sut = new EmpStat_06Rule(handler.Object, commonOps.Object);

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

            // assert
            handler.VerifyAll();
            commonOps.VerifyAll();
        }
        public void HasQualifyingFundingMeetsExpectation(int fundModel, bool expectation)
        {
            var mockItem = new Mock <ILearningDelivery>();

            mockItem
            .Setup(x => x.FundModel)
            .Returns(fundModel);

            var handler    = new Mock <IValidationErrorHandler>(MockBehavior.Strict);
            var dateTimeQS = new Mock <IDateTimeQueryService>(MockBehavior.Strict);
            var lEmpQS     = new Mock <ILearnerEmploymentStatusQueryService>(MockBehavior.Strict);

            var sut = new EmpStat_06Rule(handler.Object, dateTimeQS.Object, lEmpQS.Object);

            var result = sut.HasQualifyingFunding(mockItem.Object);

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            dateTimeQS.VerifyAll();
        }
        public void IsExcludedMeetsExpectation(int?progType, bool expectation)
        {
            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(progType);

            var handler    = new Mock <IValidationErrorHandler>(MockBehavior.Strict);
            var dateTimeQS = new Mock <IDateTimeQueryService>(MockBehavior.Strict);
            var lEmpQS     = new Mock <ILearnerEmploymentStatusQueryService>(MockBehavior.Strict);

            var sut = new EmpStat_06Rule(handler.Object, dateTimeQS.Object, lEmpQS.Object);

            var result = sut.IsExcluded(mockDelivery.Object);

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            dateTimeQS.VerifyAll();
        }
        public void HasQualifyingStartMeetsExpectation(bool expectation)
        {
            var mockItem = new Mock <ILearningDelivery>();

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

            dateTimeQS
            .Setup(x => x.IsDateBetween(mockItem.Object.LearnStartDate, DateTime.Parse("2013-08-01"), DateTime.Parse("2014-07-31"), true))
            .Returns(expectation);

            var lEmpQS = new Mock <ILearnerEmploymentStatusQueryService>(MockBehavior.Strict);

            var sut    = new EmpStat_06Rule(handler.Object, dateTimeQS.Object, lEmpQS.Object);
            var result = sut.HasQualifyingStart(mockItem.Object);

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            dateTimeQS.VerifyAll();
        }
        public void HasQualifyingStartMeetsExpectation(bool expectation)
        {
            // arrange
            var mockItem = new Mock <ILearningDelivery>();

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

            commonOps
            .Setup(x => x.HasQualifyingStart(mockItem.Object, DateTime.Parse("2013-08-01"), DateTime.Parse("2014-07-31")))
            .Returns(expectation);

            var sut = new EmpStat_06Rule(handler.Object, commonOps.Object);

            // act
            var result = sut.HasQualifyingStart(mockItem.Object);

            // assert
            Assert.Equal(expectation, result);

            handler.VerifyAll();
            commonOps.VerifyAll();
        }
        public void IsExcludedMeetsExpectation(bool expectation)
        {
            // arrange
            var mockItem = new Mock <ILearningDelivery>();

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

            commonOps
            .Setup(x => x.IsTraineeship(mockItem.Object))
            .Returns(expectation);

            var sut = new EmpStat_06Rule(handler.Object, commonOps.Object);

            // act
            var result = sut.IsExcluded(mockItem.Object);

            // assert
            Assert.Equal(expectation, result);

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

            var testDate = DateTime.Parse("2013-08-01");

            var status = new Mock <ILearnerEmploymentStatus>();

            var statii = new ILearnerEmploymentStatus[] { status.Object };

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(testDate);

            var deliveries = new ILearningDelivery[] { mockDelivery.Object };

            var mockLearner = new Mock <ILearner>();

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

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

            handler
            .Setup(x => x.Handle("EmpStat_06", LearnRefNumber, 0, It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter("DateEmpStatApp", null))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("PlanLearnHours", null))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("PlanEEPHours", null))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("LearnStartDate", AbstractRule.AsRequiredCultureDate(testDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var commonOps = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict);

            commonOps
            .Setup(x => x.GetEmploymentStatusOn(testDate, statii))
            .Returns((ILearnerEmploymentStatus)null);
            commonOps
            .Setup(x => x.HasQualifyingFunding(mockDelivery.Object, 25, 82))
            .Returns(true);
            commonOps
            .Setup(x => x.HasQualifyingStart(mockDelivery.Object, DateTime.Parse("2013-08-01"), DateTime.Parse("2014-07-31")))
            .Returns(true);
            commonOps
            .Setup(x => x.IsTraineeship(mockDelivery.Object))
            .Returns(false);

            var sut = new EmpStat_06Rule(handler.Object, commonOps.Object);

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

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

            var testDate = DateTime.Parse("2013-08-01");

            var status = new Mock <ILearnerEmploymentStatus>();

            var employmentStatuses = new ILearnerEmploymentStatus[] { status.Object };

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(testDate);
            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(25);
            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(25);

            var deliveries = new ILearningDelivery[] { mockDelivery.Object };

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            mockLearner
            .SetupGet(x => x.LearningDeliveries)
            .Returns(deliveries);
            mockLearner
            .SetupGet(y => y.LearnerEmploymentStatuses)
            .Returns(employmentStatuses);

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

            handler
            .Setup(x => x.Handle("EmpStat_06", LearnRefNumber, 0, It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter("DateEmpStatApp", null))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("PlanLearnHours", null))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("PlanEEPHours", null))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter("LearnStartDate", AbstractRule.AsRequiredCultureDate(testDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var dateTimeQS = new Mock <IDateTimeQueryService>(MockBehavior.Strict);

            dateTimeQS
            .Setup(x => x.IsDateBetween(mockDelivery.Object.LearnStartDate, EmpStat_06Rule.FirstViableDate, EmpStat_06Rule.LastViableDate, true))
            .Returns(true);

            var lEmpQS = new Mock <ILearnerEmploymentStatusQueryService>(MockBehavior.Strict);

            lEmpQS
            .Setup(x => x.LearnerEmploymentStatusForDate(employmentStatuses, testDate))
            .Returns((ILearnerEmploymentStatus)null);

            var sut = new EmpStat_06Rule(handler.Object, dateTimeQS.Object, lEmpQS.Object);

            sut.Validate(mockLearner.Object);

            handler.VerifyAll();
            dateTimeQS.VerifyAll();
        }