Пример #1
0
        public void IsOutsideQualifyingPeriodMeetsExpectation(string candidate, string yearStart, bool expectation)
        {
            var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict);

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

            academicYear
            .Setup(x => x.JanuaryFirst())
            .Returns(DateTime.Parse(yearStart));

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

            var fileData = new Mock <IFileDataService>(MockBehavior.Strict);

            fileData
            .Setup(x => x.FilePreparationDate())
            .Returns(DateTime.Parse(candidate));

            var learningDeliveryFAMQS = new Mock <ILearningDeliveryFAMQueryService>(MockBehavior.Strict);

            var sut = new ULN_10Rule(handler.Object, academicYear.Object, dateTime.Object, fileData.Object, learningDeliveryFAMQS.Object);

            var result = sut.IsOutsideQualifyingPeriod();

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            academicYear.VerifyAll();
            dateTime.VerifyAll();
            fileData.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
        }
Пример #2
0
        public void HasQualifyingActualDurationMeetsExpectation(int duration, bool expectation)
        {
            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(x => x.LearnActEndDateNullable)
            .Returns(DateTime.Today);

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

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

            academicYear
            .Setup(x => x.JanuaryFirst())
            .Returns(TestNewYearDate);

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

            dateTime
            .Setup(x => x.DaysBetween(It.IsAny <DateTime>(), It.IsAny <DateTime>()))
            .Returns(duration);

            var fileData = new Mock <IFileDataService>(MockBehavior.Strict);

            fileData
            .Setup(x => x.FilePreparationDate())
            .Returns(TestPreparationDate);

            var learningDeliveryFAMQS = new Mock <ILearningDeliveryFAMQueryService>(MockBehavior.Strict);

            var sut = new ULN_10Rule(handler.Object, academicYear.Object, dateTime.Object, fileData.Object, learningDeliveryFAMQS.Object);

            var result = sut.HasQualifyingActualDuration(delivery.Object);

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            academicYear.VerifyAll();
            dateTime.VerifyAll();
            fileData.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
        }
Пример #3
0
        public void HasQualifyingMonitorMeetsExpectation(bool expectation)
        {
            var delivery = new Mock <ILearningDelivery>();

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

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

            academicYear
            .Setup(x => x.JanuaryFirst())
            .Returns(TestNewYearDate);

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

            var fileData = new Mock <IFileDataService>(MockBehavior.Strict);

            fileData
            .Setup(x => x.FilePreparationDate())
            .Returns(TestPreparationDate);

            var learningDeliveryFAMQS = new Mock <ILearningDeliveryFAMQueryService>(MockBehavior.Strict);

            learningDeliveryFAMQS
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       delivery.Object.LearningDeliveryFAMs,
                       "SOF",
                       "1"))
            .Returns(expectation);

            var sut = new ULN_10Rule(handler.Object, academicYear.Object, dateTime.Object, fileData.Object, learningDeliveryFAMQS.Object);

            var result = sut.HasQualifyingMonitor(delivery.Object);

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            academicYear.VerifyAll();
            dateTime.VerifyAll();
            fileData.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
        }
Пример #4
0
        public void HasActualEndDateMeetsExpectation(string actEnd, bool expectation)
        {
            var testDate = GetNullableDate(actEnd);
            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(x => x.LearnActEndDateNullable)
            .Returns(testDate);

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

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

            academicYear
            .Setup(x => x.JanuaryFirst())
            .Returns(TestNewYearDate);

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

            var fileData = new Mock <IFileDataService>(MockBehavior.Strict);

            fileData
            .Setup(x => x.FilePreparationDate())
            .Returns(TestPreparationDate);

            var learningDeliveryFAMQS = new Mock <ILearningDeliveryFAMQueryService>(MockBehavior.Strict);

            var sut = new ULN_10Rule(handler.Object, academicYear.Object, dateTime.Object, fileData.Object, learningDeliveryFAMQS.Object);

            var result = sut.HasActualEndDate(delivery.Object);

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            academicYear.VerifyAll();
            dateTime.VerifyAll();
            fileData.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
        }
Пример #5
0
        public void ValidItemDoesNotRaiseValidationMessage()
        {
            const string LearnRefNumber = "123456789X";

            var testStart = DateTime.Parse("2016-05-01");
            var testEnd   = DateTime.Parse("2017-05-01");

            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(y => y.FundModel)
            .Returns(99);
            delivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(testStart);
            delivery
            .SetupGet(y => y.LearnPlanEndDate)
            .Returns(testEnd);
            delivery
            .SetupGet(y => y.LearnActEndDateNullable)
            .Returns(DateTime.Today);

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

            var learner = new Mock <ILearner>();

            learner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            learner
            .SetupGet(x => x.ULN)
            .Returns(ValidationConstants.TemporaryULN);
            learner
            .SetupGet(x => x.LearningDeliveries)
            .Returns(deliveries);

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

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

            academicYear
            .Setup(x => x.JanuaryFirst())
            .Returns(TestNewYearDate);

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

            dateTime
            .Setup(x => x.DaysBetween(It.IsAny <DateTime>(), It.IsAny <DateTime>()))
            .ReturnsInOrder(4, 5, 60);

            var fileData = new Mock <IFileDataService>(MockBehavior.Strict);

            fileData
            .Setup(x => x.FilePreparationDate())
            .Returns(TestPreparationDate);

            var learningDeliveryFAMQS = new Mock <ILearningDeliveryFAMQueryService>(MockBehavior.Strict);

            learningDeliveryFAMQS
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       delivery.Object.LearningDeliveryFAMs,
                       "LDM",
                       "034"))
            .Returns(false);
            learningDeliveryFAMQS
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       delivery.Object.LearningDeliveryFAMs,
                       "SOF",
                       "1"))
            .Returns(true);

            var sut = new ULN_10Rule(handler.Object, academicYear.Object, dateTime.Object, fileData.Object, learningDeliveryFAMQS.Object);

            sut.Validate(learner.Object);

            handler.VerifyAll();
            academicYear.VerifyAll();
            dateTime.VerifyAll();
            fileData.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
        }