public void HasQualifyingNotionalNVQMeetsExpectation(string candidate)
        {
            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.LearnAimRef)
            .Returns(candidate);

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

            service
            .Setup(x => x.GetDeliveryFor(candidate))
            .Returns((ILARSLearningDelivery)null);

            var learningDeliveryFAMQS = new Mock <ILearningDeliveryFAMQueryService>(MockBehavior.Strict);
            var dd07       = new Mock <IDerivedData_07Rule>(MockBehavior.Strict);
            var dateTimeQS = new Mock <IDateTimeQueryService>(MockBehavior.Strict);

            var sut = new LearnAimRef_85Rule(handler.Object, service.Object, learningDeliveryFAMQS.Object, dd07.Object, dateTimeQS.Object);

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

            Assert.False(result);

            handler.VerifyAll();
            service.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
            dd07.VerifyAll();
        }
        public void HasQualifyingNotionalNVQMeetsExpectation(string candidate)
        {
            // arrange
            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.LearnAimRef)
            .Returns(candidate);

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

            service
            .Setup(x => x.GetDeliveryFor(candidate))
            .Returns((ILARSLearningDelivery)null);

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

            var sut = new LearnAimRef_85Rule(handler.Object, service.Object, commonChecks.Object);

            // act
            var result = sut.HasDisqualifyingNotionalNVQ(mockDelivery.Object);

            // assert
            handler.VerifyAll();
            service.VerifyAll();
            commonChecks.VerifyAll();

            Assert.False(result);
        }
        public void ValidItemDoesNotRaiseValidationMessage(int candidate)
        {
            const string learnRefNumber = "123456789X";
            const string learnAimRef    = "salddfkjeifdnase";

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

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(learnAimRef);
            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(testDate);
            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(FundModels.AdultSkills);
            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(ProgTypes.AdvancedLevelApprenticeship);

            var deliveries = new List <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(learnRefNumber);
            mockLearner
            .SetupGet(x => x.PriorAttainNullable)
            .Returns(candidate);
            mockLearner
            .SetupGet(x => x.LearningDeliveries)
            .Returns(deliveries);

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

            var mockLars = new Mock <ILARSLearningDelivery>();

            mockLars
            .SetupGet(x => x.NotionalNVQLevelv2)
            .Returns(LARSConstants.NotionalNVQLevelV2Strings.Level2);

            var service = new Mock <ILARSDataService>(MockBehavior.Strict);

            service
            .Setup(x => x.GetDeliveryFor(learnAimRef))
            .Returns(mockLars.Object);

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

            learningDeliveryFAMQS
            .Setup(x => x.HasLearningDeliveryFAMType(
                       mockDelivery.Object.LearningDeliveryFAMs,
                       "RES"))
            .Returns(false);
            learningDeliveryFAMQS
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       mockDelivery.Object.LearningDeliveryFAMs,
                       "DAM",
                       "023"))
            .Returns(false);
            learningDeliveryFAMQS
            .Setup(x => x.HasLearningDeliveryFAMCodeForType(
                       mockDelivery.Object.LearningDeliveryFAMs,
                       "LDM",
                       "376"))
            .Returns(false);

            var dd07 = new Mock <IDerivedData_07Rule>(MockBehavior.Strict);

            dd07
            .Setup(dd => dd.IsApprenticeship(mockDelivery.Object.ProgTypeNullable)).Returns(false);

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

            dateTimeQS
            .Setup(x => x.IsDateBetween(mockDelivery.Object.LearnStartDate, LearnAimRef_85Rule.FirstViableDate, DateTime.MaxValue, true))
            .Returns(true);

            var sut = new LearnAimRef_85Rule(handler.Object, service.Object, learningDeliveryFAMQS.Object, dd07.Object, dateTimeQS.Object);

            sut.Validate(mockLearner.Object);

            handler.VerifyAll();
            service.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
            dd07.VerifyAll();
        }
        public void ValidItemDoesNotRaiseValidationMessage(int candidate)
        {
            // arrange
            const string learnRefNumber = "123456789X";
            const string learnAimRef    = "salddfkjeifdnase";

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

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(learnAimRef);
            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(testDate);
            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(TypeOfFunding.AdultSkills);

            var deliveries = Collection.Empty <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(learnRefNumber);
            mockLearner
            .SetupGet(x => x.PriorAttainNullable)
            .Returns(candidate);
            mockLearner
            .SetupGet(x => x.LearningDeliveries)
            .Returns(deliveries.AsSafeReadOnlyList());

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

            var mockLars = new Mock <ILARSLearningDelivery>();

            mockLars
            .SetupGet(x => x.NotionalNVQLevelv2)
            .Returns(LARSNotionalNVQLevelV2.Level2);

            var service = new Mock <ILARSDataService>(MockBehavior.Strict);

            service
            .Setup(x => x.GetDeliveryFor(learnAimRef))
            .Returns(mockLars.Object);

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

            commonChecks
            .Setup(x => x.IsRestart(mockDelivery.Object))
            .Returns(false);
            commonChecks
            .Setup(x => x.InApprenticeship(mockDelivery.Object))
            .Returns(false);
            commonChecks
            .Setup(x => x.HasQualifyingFunding(mockDelivery.Object, TypeOfFunding.AdultSkills))
            .Returns(true);
            commonChecks
            .Setup(x => x.HasQualifyingStart(mockDelivery.Object, LearnAimRef_85Rule.FirstViableDate, null))
            .Returns(true);

            var sut = new LearnAimRef_85Rule(handler.Object, service.Object, commonChecks.Object);

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

            // assert
            handler.VerifyAll();
            service.VerifyAll();
            commonChecks.VerifyAll();
        }