public void HasQualifyingCategoryMeetsExpectation(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.GetCategoriesFor(candidate))
            .Returns(Collection.EmptyAndReadOnly <ILARSLearningCategory>());

            var commonChecks = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict);
            var fileData     = new Mock <IFileDataService>(MockBehavior.Strict);
            var orgData      = new Mock <IOrganisationDataService>(MockBehavior.Strict);

            var sut = new LearnAimRef_78Rule(handler.Object, service.Object, commonChecks.Object, fileData.Object, orgData.Object);

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

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

            Assert.False(result);
        }
        public void IsSpecialistDesignatedCollegeMeetsExpectation(int ukprn, bool expectation)
        {
            // arrange
            var mockItem = new Mock <ILearningDelivery>();

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

            fileData
            .Setup(x => x.UKPRN())
            .Returns(ukprn);

            var orgData = new Mock <IOrganisationDataService>(MockBehavior.Strict);

            orgData
            .Setup(x => x.LegalOrgTypeMatchForUkprn(ukprn, "USDC"))
            .Returns(expectation);

            var sut = new LearnAimRef_78Rule(handler.Object, service.Object, commonChecks.Object, fileData.Object, orgData.Object);

            // act
            var result = sut.IsSpecialistDesignatedCollege();

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

            Assert.Equal(expectation, result);
        }
        public void IsSpecialistDesignatedCollegeMeetsExpectation(int ukprn, bool expectation)
        {
            var mockItem = new Mock <ILearningDelivery>();

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

            fileData
            .Setup(x => x.UKPRN())
            .Returns(ukprn);

            var orgData = new Mock <IOrganisationDataService>(MockBehavior.Strict);

            orgData
            .Setup(x => x.LegalOrgTypeMatchForUkprn(ukprn, "USDC"))
            .Returns(expectation);

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

            var sut = new LearnAimRef_78Rule(handler.Object, service.Object, learningDeliveryFAMQS.Object, fileData.Object, orgData.Object, dd07.Object, dateTimeQS.Object);

            var result = sut.IsSpecialistDesignatedCollege();

            handler.VerifyAll();
            service.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
            fileData.VerifyAll();
            orgData.VerifyAll();
            dd07.VerifyAll();

            Assert.Equal(expectation, result);
        }
        public void HasQualifyingCategoryMeetsExpectation(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.GetCategoriesFor(candidate))
            .Returns(new List <ILARSLearningCategory>());

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

            var sut = new LearnAimRef_78Rule(handler.Object, service.Object, learningDeliveryFAMQS.Object, fileData.Object, orgData.Object, dd07.Object, dateTimeQS.Object);

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

            handler.VerifyAll();
            service.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
            fileData.VerifyAll();
            orgData.VerifyAll();
            dd07.VerifyAll();

            Assert.False(result);
        }
        public void ValidItemDoesNotRaiseValidationMessage()
        {
            // 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.LearningDeliveries)
            .Returns(deliveries.AsSafeReadOnlyList());

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

            // it's this value that triggers the rule
            var mockCategory = new Mock <ILARSLearningCategory>();

            mockCategory
            .SetupGet(x => x.CategoryRef)
            .Returns(TypeOfLARSCategory.OnlyForLegalEntitlementAtLevel3);

            var larsCategories = Collection.Empty <ILARSLearningCategory>();

            larsCategories.Add(mockCategory.Object);

            var mockLars = new Mock <ILARSLearningDelivery>();

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

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

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

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

            commonChecks
            .Setup(x => x.IsRestart(mockDelivery.Object))
            .Returns(false);
            commonChecks
            .Setup(x => x.IsLearnerInCustody(mockDelivery.Object))
            .Returns(false);
            commonChecks
            .Setup(x => x.IsSteelWorkerRedundancyTraining(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_78Rule.FirstViableDate, LearnAimRef_78Rule.LastViableDate))
            .Returns(true);

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

            fileData
            .Setup(x => x.UKPRN())
            .Returns(1004);

            var orgData = new Mock <IOrganisationDataService>(MockBehavior.Strict);

            orgData
            .Setup(x => x.LegalOrgTypeMatchForUkprn(1004, "USDC"))
            .Returns(false);

            var sut = new LearnAimRef_78Rule(handler.Object, service.Object, commonChecks.Object, fileData.Object, orgData.Object);

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

            // assert
            handler.VerifyAll();
            service.VerifyAll();
            commonChecks.VerifyAll();
            fileData.VerifyAll();
            orgData.VerifyAll();
        }
        public void ValidItemDoesNotRaiseValidationMessage()
        {
            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);

            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.LearningDeliveries)
            .Returns(deliveries);

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

            var mockCategory = new Mock <ILARSLearningCategory>();

            mockCategory
            .SetupGet(x => x.CategoryRef)
            .Returns(LARSConstants.Categories.OnlyForLegalEntitlementAtLevel3);

            var larsCategories = new List <ILARSLearningCategory>();

            larsCategories.Add(mockCategory.Object);

            var mockLars = new Mock <ILARSLearningDelivery>();

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

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

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

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

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

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

            fileData
            .Setup(x => x.UKPRN())
            .Returns(1004);

            var orgData = new Mock <IOrganisationDataService>(MockBehavior.Strict);

            orgData
            .Setup(x => x.LegalOrgTypeMatchForUkprn(1004, "USDC"))
            .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_78Rule.FirstViableDate, LearnAimRef_78Rule.LastViableDate, true))
            .Returns(true);

            var sut = new LearnAimRef_78Rule(handler.Object, service.Object, learningDeliveryFAMQS.Object, fileData.Object, orgData.Object, dd07.Object, dateTimeQS.Object);

            sut.Validate(mockLearner.Object);

            handler.VerifyAll();
            service.VerifyAll();
            learningDeliveryFAMQS.VerifyAll();
            fileData.VerifyAll();
            orgData.VerifyAll();
            dd07.VerifyAll();
        }