public void ValidItemDoesNotRaiseValidationMessage(string candidate) { const string LearnRefNumber = "123456789X"; const int AimSeqNumber = 1; var testDate = DateTime.Parse("2018-07-31"); var deliveries = new List <ILearningDelivery>(); var mockDelivery = new Mock <ILearningDelivery>(); mockDelivery .SetupGet(x => x.LearnStartDate) .Returns(testDate); mockDelivery .SetupGet(x => x.AimSeqNumber) .Returns(AimSeqNumber); deliveries.Add(mockDelivery.Object); mockDelivery .SetupGet(x => x.AimType) .Returns(1); mockDelivery .SetupGet(x => x.ProgTypeNullable) .Returns(24); deliveries.Add(mockDelivery.Object); var esmType = candidate.Substring(0, 3); var esmCode = int.Parse(candidate.Substring(3)); var monitors = new List <IEmploymentStatusMonitoring>(); var mockItem = new Mock <IEmploymentStatusMonitoring>(MockBehavior.Strict); mockItem .SetupGet(y => y.ESMType) .Returns(esmType); mockItem .SetupGet(y => y.ESMCode) .Returns(esmCode); monitors.Add(mockItem.Object); var mockStatus = new Mock <ILearnerEmploymentStatus>(); mockStatus .SetupGet(y => y.DateEmpStatApp) .Returns(testDate); mockStatus .SetupGet(y => y.EmpStat) .Returns(EmploymentStatusEmpStats.InPaidEmployment); mockStatus .SetupGet(y => y.EmploymentStatusMonitorings) .Returns(monitors); var mockLearner = new Mock <ILearner>(); mockLearner .SetupGet(x => x.LearnRefNumber) .Returns(LearnRefNumber); mockLearner .SetupGet(x => x.LearningDeliveries) .Returns(deliveries); var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); var dateTimeQS = new Mock <IDateTimeQueryService>(MockBehavior.Strict); dateTimeQS .Setup(x => x.IsDateBetween(mockDelivery.Object.LearnStartDate, EmpStat_19Rule.NewCodeMonitoringThresholdDate, DateTime.MaxValue, true)) .Returns(true); var lEmpQS = new Mock <ILearnerEmploymentStatusQueryService>(MockBehavior.Strict); lEmpQS .Setup(x => x.LearnerEmploymentStatusForDate(It.IsAny <IReadOnlyCollection <ILearnerEmploymentStatus> >(), testDate)) .Returns(mockStatus.Object); var sut = new EmpStat_19Rule(handler.Object, dateTimeQS.Object, lEmpQS.Object); sut.Validate(mockLearner.Object); handler.VerifyAll(); dateTimeQS.VerifyAll(); }
[InlineData("LOU5")] // Monitoring.EmploymentStatus.UnemployedFor36MPlus public void ValidItemDoesNotRaiseValidationMessage(string candidate) { // arrange const string LearnRefNumber = "123456789X"; const int AimSeqNumber = 1; var testDate = DateTime.Parse("2018-07-31"); var deliveries = Collection.Empty <ILearningDelivery>(); var mockDelivery = new Mock <ILearningDelivery>(); mockDelivery .SetupGet(x => x.LearnStartDate) .Returns(testDate); mockDelivery .SetupGet(x => x.AimSeqNumber) .Returns(AimSeqNumber); deliveries.Add(mockDelivery.Object); var esmType = candidate.Substring(0, 3); var esmCode = int.Parse(candidate.Substring(3)); var monitors = Collection.Empty <IEmploymentStatusMonitoring>(); var mockItem = new Mock <IEmploymentStatusMonitoring>(MockBehavior.Strict); mockItem .SetupGet(y => y.ESMType) .Returns(esmType); mockItem .SetupGet(y => y.ESMCode) .Returns(esmCode); monitors.Add(mockItem.Object); var mockStatus = new Mock <ILearnerEmploymentStatus>(); mockStatus .SetupGet(y => y.DateEmpStatApp) .Returns(testDate); mockStatus .SetupGet(y => y.EmpStat) .Returns(TypeOfEmploymentStatus.InPaidEmployment); mockStatus .SetupGet(y => y.EmploymentStatusMonitorings) .Returns(monitors.AsSafeReadOnlyList()); var mockLearner = new Mock <ILearner>(); mockLearner .SetupGet(x => x.LearnRefNumber) .Returns(LearnRefNumber); mockLearner .SetupGet(x => x.LearningDeliveries) .Returns(deliveries.AsSafeReadOnlyList()); var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); var commonchecks = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict); commonchecks .Setup(x => x.IsTraineeship(mockDelivery.Object)) .Returns(true); commonchecks .Setup(x => x.InAProgramme(mockDelivery.Object)) .Returns(true); commonchecks .Setup(x => x.HasQualifyingStart(mockDelivery.Object, EmpStat_19Rule.NewCodeMonitoringThresholdDate, null)) .Returns(true); commonchecks .Setup(x => x.GetEmploymentStatusOn(testDate, Moq.It.IsAny <IReadOnlyCollection <ILearnerEmploymentStatus> >())) .Returns(mockStatus.Object); var sut = new EmpStat_19Rule(handler.Object, commonchecks.Object); // act sut.Validate(mockLearner.Object); // assert handler.VerifyAll(); commonchecks.VerifyAll(); }