public void IsExcludedForInflexibleElementOfTrainingAim() { // 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); mockDDRule29 .Setup(x => x.IsInflexibleElementOfTrainingAim(mockItem.Object)) .Returns(true); var sut = new LearnDelFAMType_61Rule(handler.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.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 IsApprenticeshipMeetsExpectation(bool expectation) { // arrange var mockItem = new Mock <ILearningDelivery>(); 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); mockDDRule07 .Setup(x => x.IsApprenticeship(null)) .Returns(expectation); var sut = new LearnDelFAMType_61Rule(handler.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object); // act var result = sut.IsApprenticeship(mockItem.Object); // 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); mockDDRule28 .Setup(x => x.IsAdultFundedUnemployedWithBenefits(delivery.Object, learner.Object)) .Returns(expectation); var sut = new LearnDelFAMType_61Rule(handler.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.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>(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); mockDDRule29 .Setup(x => x.IsInflexibleElementOfTrainingAim(mockItem.Object)) .Returns(false); mockDDRule07 .Setup(x => x.IsApprenticeship(progType)) .Returns(true); var sut = new LearnDelFAMType_61Rule(handler.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.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 IsNotEntitledMeetsExpectation(int candidate, bool expectation) { // arrange const string learnAimRef = "asdfbasdf"; var mockCat = new Mock <ILARSLearningCategory>(); mockCat .SetupGet(x => x.CategoryRef) .Returns(candidate); var larsCats = Collection.Empty <ILARSLearningCategory>(); larsCats.Add(mockCat.Object); var mock = new Mock <ILARSLearningDelivery>(); mock .SetupGet(x => x.NotionalNVQLevelv2) .Returns(LARSNotionalNVQLevelV2.Level2); mock .SetupGet(x => x.Categories) .Returns(larsCats.AsSafeReadOnlyList()); var service = new Mock <ILARSDataService>(); 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); var mockDDRule28 = new Mock <IDerivedData_28Rule>(MockBehavior.Strict); var mockDDRule29 = new Mock <IDerivedData_29Rule>(MockBehavior.Strict); var validationErrorHandlerMock = new Mock <IValidationErrorHandler>(); var sut = new LearnDelFAMType_61Rule(validationErrorHandlerMock.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object); // act var result = sut.IsNotEntitled(new TestLearningDelivery() { LearnAimRef = learnAimRef }); // assert Assert.Equal(expectation, result); }
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("2017-08-01")); 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.PriorAttainNullable) .Returns(TypeOfPriorAttainment.FullLevel3); mockLearner .SetupGet(x => x.LearnRefNumber) .Returns(LearnRefNumber); mockLearner .SetupGet(x => x.DateOfBirthNullable) .Returns(DateTime.Parse("1996-07-01")); mockLearner .SetupGet(x => x.LearningDeliveries) .Returns(deliveries.AsSafeReadOnlyList()); var handler = 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.Level3); mockLARSDel .SetupGet(x => x.Categories) .Returns(larsCats.AsSafeReadOnlyList()); var service = new Mock <ILARSDataService>(MockBehavior.Strict); service .Setup(x => x.GetDeliveryFor(learnAimRef)) .Returns(mockLARSDel.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 sut = new LearnDelFAMType_61Rule(handler.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object); // act sut.ValidateDeliveries(mockLearner.Object); // assert handler.VerifyAll(); service.VerifyAll(); mockDDRule07.VerifyAll(); mockDDRule21.VerifyAll(); mockDDRule28.VerifyAll(); mockDDRule29.VerifyAll(); }
public void InvalidItemRaisesValidationMessage() { // arrange IFormatProvider requiredCulture = new CultureInfo("en-GB"); const string LearnRefNumber = "123456789X"; const string learnAimRef = "salddfkjeifdnase"; DateTime learnStartDate = new DateTime(2017, 8, 1); DateTime? dateOfBirth = new DateTime(1996, 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.PriorAttainNullable) .Returns(TypeOfPriorAttainment.FullLevel2); 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 mockCat = new Mock <ILARSLearningCategory>(); mockCat .SetupGet(x => x.CategoryRef) .Returns(TypeOfLARSCategory.LicenseToPractice); var larsCats = Collection.Empty <ILARSLearningCategory>(); larsCats.Add(mockCat.Object); var mock = new Mock <ILARSLearningDelivery>(); mock .SetupGet(x => x.NotionalNVQLevelv2) .Returns(LARSNotionalNVQLevelV2.Level2); mock .SetupGet(x => x.Categories) .Returns(larsCats.AsSafeReadOnlyList()); 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 sut = new LearnDelFAMType_61Rule(validationErrorHandlerMock.Object, service.Object, mockDDRule07.Object, mockDDRule21.Object, mockDDRule28.Object, mockDDRule29.Object); // act sut.ValidateDeliveries(mockLearner.Object); // assert validationErrorHandlerMock.VerifyAll(); service.VerifyAll(); mockDDRule07.VerifyAll(); mockDDRule21.VerifyAll(); mockDDRule28.VerifyAll(); mockDDRule29.VerifyAll(); }