public void IsEarlyStageNVQMeetsExpectation(string candidate, bool expectation) { // arrange var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); var larsDataService = new Mock <ILARSDataService>(MockBehavior.Strict); var mockDDRule07 = new Mock <IDerivedData_07Rule>(MockBehavior.Strict); var mockDDRule21 = new Mock <IDerivedData_21Rule>(MockBehavior.Strict); var mockDDRule28 = new Mock <IDerivedData_28Rule>(MockBehavior.Strict); var mockDDRule29 = new Mock <IDerivedData_29Rule>(MockBehavior.Strict); var organisationDataService = new Mock <IOrganisationDataService>(); var fileDataService = new Mock <IFileDataService>(MockBehavior.Strict); var mockItem = new Mock <ILARSLearningDelivery>(); mockItem.SetupGet(y => y.NotionalNVQLevelv2).Returns(candidate); larsDataService .Setup(x => x.GetDeliveryFor(Moq.It.IsAny <string>())) .Returns(mockItem.Object); var sut = new LearnDelFAMType_60Rule(handler.Object, larsDataService.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object, organisationDataService.Object, fileDataService.Object); // act var result = sut.IsEarlyStageNVQ(new TestLearningDelivery()); // assert Assert.Equal(expectation, result); handler.VerifyAll(); larsDataService.VerifyAll(); mockDDRule07.VerifyAll(); mockDDRule21.VerifyAll(); mockDDRule28.VerifyAll(); mockDDRule29.VerifyAll(); }
public void IsInflexibleElementOfTrainingAimMeetsExpectation(bool expectation) { // arrange var mockItem = new Mock <ILearner>(); var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); var service = new Mock <ILARSDataService>(MockBehavior.Strict); var mockDDRule07 = new Mock <IDerivedData_07Rule>(MockBehavior.Strict); var mockDDRule21 = new Mock <IDerivedData_21Rule>(MockBehavior.Strict); var mockDDRule28 = new Mock <IDerivedData_28Rule>(MockBehavior.Strict); var mockDDRule29 = new Mock <IDerivedData_29Rule>(MockBehavior.Strict); var organisationDataService = new Mock <IOrganisationDataService>(MockBehavior.Strict); var fileDataService = new Mock <IFileDataService>(MockBehavior.Strict); mockDDRule29 .Setup(x => x.IsInflexibleElementOfTrainingAim(mockItem.Object)) .Returns(expectation); var sut = new LearnDelFAMType_60Rule(handler.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object, organisationDataService.Object, fileDataService.Object); // act var result = sut.IsInflexibleElementOfTrainingAim(mockItem.Object); // assert Assert.Equal(expectation, result); handler.VerifyAll(); service.VerifyAll(); mockDDRule07.VerifyAll(); mockDDRule21.VerifyAll(); mockDDRule28.VerifyAll(); mockDDRule29.VerifyAll(); }
public void IsLegalOrgTypeMatchForUkprnMeetsExpectation(string candidate, bool expectation) { // arrange var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); var service = new Mock <ILARSDataService>(MockBehavior.Strict); var mockDDRule07 = new Mock <IDerivedData_07Rule>(MockBehavior.Strict); var mockDDRule21 = new Mock <IDerivedData_21Rule>(MockBehavior.Strict); var mockDDRule28 = new Mock <IDerivedData_28Rule>(MockBehavior.Strict); var mockDDRule29 = new Mock <IDerivedData_29Rule>(MockBehavior.Strict); var organisationDataService = new Mock <IOrganisationDataService>(); var fileDataService = new Mock <IFileDataService>(MockBehavior.Strict); fileDataService.Setup(x => x.UKPRN()).Returns(123456); organisationDataService .Setup(x => x.LegalOrgTypeMatchForUkprn(Moq.It.IsAny <long>(), candidate)) .Returns(expectation); var sut = new LearnDelFAMType_60Rule(handler.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object, organisationDataService.Object, fileDataService.Object); // act var result = sut.IsLegalOrgTypeMatchForUkprn(); // assert Assert.Equal(expectation, result); handler.VerifyAll(); service.VerifyAll(); mockDDRule07.VerifyAll(); mockDDRule21.VerifyAll(); mockDDRule28.VerifyAll(); mockDDRule29.VerifyAll(); }
public void IsAdultFundedUnemployedWithBenefitsMeetsExpectation(bool expectation) { // arrange var delivery = new Mock <ILearningDelivery>(); var learner = new Mock <ILearner>(); var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); var service = new Mock <ILARSDataService>(MockBehavior.Strict); var mockDDRule07 = new Mock <IDerivedData_07Rule>(MockBehavior.Strict); var mockDDRule21 = new Mock <IDerivedData_21Rule>(MockBehavior.Strict); var mockDDRule28 = new Mock <IDerivedData_28Rule>(MockBehavior.Strict); var mockDDRule29 = new Mock <IDerivedData_29Rule>(MockBehavior.Strict); var organisationDataService = new Mock <IOrganisationDataService>(MockBehavior.Strict); var fileDataService = new Mock <IFileDataService>(MockBehavior.Strict); mockDDRule28 .Setup(x => x.IsAdultFundedUnemployedWithBenefits(delivery.Object, learner.Object)) .Returns(expectation); var sut = new LearnDelFAMType_60Rule(handler.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object, organisationDataService.Object, fileDataService.Object); // act var result = sut.IsAdultFundedUnemployedWithBenefits(delivery.Object, learner.Object); // assert Assert.Equal(expectation, result); handler.VerifyAll(); service.VerifyAll(); mockDDRule07.VerifyAll(); mockDDRule21.VerifyAll(); mockDDRule28.VerifyAll(); mockDDRule29.VerifyAll(); }
public void IsExcludedForApprenticeship() { // arrange const int progType = 23; var mockDel = new Mock <ILearningDelivery>(); mockDel .SetupGet(x => x.ProgTypeNullable) .Returns(progType); var deliveries = Collection.Empty <ILearningDelivery>(); deliveries.Add(mockDel.Object); var mockItem = new Mock <ILearner>(); mockItem .SetupGet(x => x.LearningDeliveries) .Returns(deliveries.AsSafeReadOnlyList()); var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); var service = new Mock <ILARSDataService>(MockBehavior.Strict); var mockDDRule07 = new Mock <IDerivedData_07Rule>(); var mockDDRule21 = new Mock <IDerivedData_21Rule>(); var mockDDRule28 = new Mock <IDerivedData_28Rule>(); var mockDDRule29 = new Mock <IDerivedData_29Rule>(); var organisationDataService = new Mock <IOrganisationDataService>(); var fileDataService = new Mock <IFileDataService>(MockBehavior.Strict); mockDDRule07 .Setup(x => x.IsApprenticeship(progType)) .Returns(true); var sut = new LearnDelFAMType_60Rule(handler.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object, organisationDataService.Object, fileDataService.Object); // act var result = sut.IsExcluded(mockItem.Object); // assert Assert.True(result); handler.VerifyAll(); service.VerifyAll(); mockDDRule07.VerifyAll(); mockDDRule21.VerifyAll(); mockDDRule28.VerifyAll(); mockDDRule29.VerifyAll(); }
public void ValidItemDoesNotRaiseValidationMessage() { // arrange const string LearnRefNumber = "123456789X"; const string learnAimRef = "salddfkjeifdnase"; var mockFAM = new Mock <ILearningDeliveryFAM>(); mockFAM .SetupGet(x => x.LearnDelFAMType) .Returns(Monitoring.Delivery.Types.FullOrCoFunding); mockFAM .SetupGet(x => x.LearnDelFAMCode) .Returns("1"); var fams = Collection.Empty <ILearningDeliveryFAM>(); fams.Add(mockFAM.Object); var mockDelivery = new Mock <ILearningDelivery>(); mockDelivery .SetupGet(y => y.LearnAimRef) .Returns(learnAimRef); mockDelivery .SetupGet(y => y.LearnStartDate) .Returns(DateTime.Parse("2016-08-01")); mockDelivery .SetupGet(y => y.FundModel) .Returns(TypeOfFunding.CommunityLearning); // Not Adultskills mockDelivery .SetupGet(y => y.LearningDeliveryFAMs) .Returns(fams.AsSafeReadOnlyList()); 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.DateOfBirthNullable) .Returns(DateTime.Parse("1990-07-01")); mockLearner .SetupGet(x => x.LearningDeliveries) .Returns(deliveries.AsSafeReadOnlyList()); var validationErrorHandlerMock = new Mock <IValidationErrorHandler>(MockBehavior.Strict); var mockCat = new Mock <ILARSLearningCategory>(); mockCat .SetupGet(x => x.CategoryRef) .Returns(TypeOfLARSCategory.LegalEntitlementLevel2); var larsCats = Collection.Empty <ILARSLearningCategory>(); larsCats.Add(mockCat.Object); var mockLARSDel = new Mock <ILARSLearningDelivery>(); mockLARSDel .SetupGet(x => x.NotionalNVQLevelv2) .Returns(LARSNotionalNVQLevelV2.Level2); mockLARSDel .SetupGet(x => x.Categories) .Returns(larsCats.AsSafeReadOnlyList()); var larsDeliveries = Collection.Empty <ILARSLearningDelivery>(); larsDeliveries.Add(mockLARSDel.Object); var service = new Mock <ILARSDataService>(); var mockDDRule07 = new Mock <IDerivedData_07Rule>(MockBehavior.Strict); var mockDDRule21 = new Mock <IDerivedData_21Rule>(MockBehavior.Strict); mockDDRule21 .Setup(x => x.IsAdultFundedUnemployedWithOtherStateBenefits(mockDelivery.Object, mockLearner.Object)) .Returns(false); var mockDDRule28 = new Mock <IDerivedData_28Rule>(MockBehavior.Strict); mockDDRule28 .Setup(x => x.IsAdultFundedUnemployedWithBenefits(mockDelivery.Object, mockLearner.Object)) .Returns(false); var mockDDRule29 = new Mock <IDerivedData_29Rule>(MockBehavior.Strict); var organisationDataService = new Mock <IOrganisationDataService>(MockBehavior.Strict); var fileDataService = new Mock <IFileDataService>(MockBehavior.Strict); var sut = new LearnDelFAMType_60Rule(validationErrorHandlerMock.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object, organisationDataService.Object, fileDataService.Object); // act sut.ValidateDeliveries(mockLearner.Object); // assert validationErrorHandlerMock.VerifyAll(); service.VerifyAll(); mockDDRule07.VerifyAll(); mockDDRule21.VerifyAll(); mockDDRule28.VerifyAll(); mockDDRule29.VerifyAll(); organisationDataService.VerifyAll(); fileDataService.VerifyAll(); }
public void InvalidItemRaisesValidationMessage() { // arrange IFormatProvider requiredCulture = new CultureInfo("en-GB"); const string LearnRefNumber = "123456789X"; const string learnAimRef = "salddfkjeifdnase"; DateTime learnStartDate = new DateTime(2016, 8, 1); DateTime? dateOfBirth = new DateTime(1990, 7, 1); var mockFAM = new Mock <ILearningDeliveryFAM>(); mockFAM .SetupGet(x => x.LearnDelFAMType) .Returns(Monitoring.Delivery.Types.FullOrCoFunding); mockFAM .SetupGet(x => x.LearnDelFAMCode) .Returns("1"); var fams = Collection.Empty <ILearningDeliveryFAM>(); fams.Add(mockFAM.Object); var mockDelivery = new Mock <ILearningDelivery>(); mockDelivery .SetupGet(y => y.LearnAimRef) .Returns(learnAimRef); mockDelivery .SetupGet(y => y.LearnStartDate) .Returns(learnStartDate); mockDelivery .SetupGet(y => y.FundModel) .Returns(TypeOfFunding.AdultSkills); mockDelivery .SetupGet(y => y.LearningDeliveryFAMs) .Returns(fams.AsSafeReadOnlyList()); 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.DateOfBirthNullable) .Returns(dateOfBirth); mockLearner .SetupGet(x => x.LearningDeliveries) .Returns(deliveries.AsSafeReadOnlyList()); var validationErrorHandlerMock = new Mock <IValidationErrorHandler>(); validationErrorHandlerMock .Setup(v => v.BuildErrorMessageParameter(PropertyNameConstants.LearnDelFAMType, Monitoring.Delivery.Types.FullOrCoFunding)) .Verifiable(); validationErrorHandlerMock .Setup(v => v.BuildErrorMessageParameter(PropertyNameConstants.LearnDelFAMCode, "1")) .Verifiable(); validationErrorHandlerMock .Setup(v => v.BuildErrorMessageParameter(PropertyNameConstants.FundModel, TypeOfFunding.AdultSkills)) .Verifiable(); validationErrorHandlerMock .Setup(v => v.BuildErrorMessageParameter(PropertyNameConstants.LearnStartDate, learnStartDate.ToString("d", requiredCulture))) .Verifiable(); validationErrorHandlerMock .Setup(v => v.BuildErrorMessageParameter(PropertyNameConstants.DateOfBirth, dateOfBirth.Value.ToString("d", requiredCulture))) .Verifiable(); var mock = new Mock <ILARSLearningDelivery>(); mock .SetupGet(x => x.NotionalNVQLevelv2) .Returns(LARSNotionalNVQLevelV2.Level2); var service = new Mock <ILARSDataService>(MockBehavior.Strict); service .Setup(x => x.GetDeliveryFor(learnAimRef)) .Returns(mock.Object); var mockDDRule07 = new Mock <IDerivedData_07Rule>(MockBehavior.Strict); var mockDDRule21 = new Mock <IDerivedData_21Rule>(MockBehavior.Strict); mockDDRule21 .Setup(x => x.IsAdultFundedUnemployedWithOtherStateBenefits(mockDelivery.Object, mockLearner.Object)) .Returns(false); var mockDDRule28 = new Mock <IDerivedData_28Rule>(MockBehavior.Strict); mockDDRule28 .Setup(x => x.IsAdultFundedUnemployedWithBenefits(mockDelivery.Object, mockLearner.Object)) .Returns(false); var mockDDRule29 = new Mock <IDerivedData_29Rule>(MockBehavior.Strict); var organisationDataService = new Mock <IOrganisationDataService>(MockBehavior.Strict); var fileDataService = new Mock <IFileDataService>(MockBehavior.Strict); var sut = new LearnDelFAMType_60Rule(validationErrorHandlerMock.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object, organisationDataService.Object, fileDataService.Object); // act sut.ValidateDeliveries(mockLearner.Object); // assert validationErrorHandlerMock.VerifyAll(); service.VerifyAll(); mockDDRule07.VerifyAll(); mockDDRule21.VerifyAll(); mockDDRule28.VerifyAll(); mockDDRule29.VerifyAll(); organisationDataService.VerifyAll(); fileDataService.VerifyAll(); }