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 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 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(); }