public List <LearningDelivery> Evaluate(List <LearningDelivery> objectToValidate) { var result = new List <LearningDelivery>(); foreach (var learningDelivery in objectToValidate) { var learnerAgewithResToProgStartdate = _dateHelper.GetAge(learningDelivery.LearnStartDate.Value, learningDelivery.DateOfBirth); //pick learningdeliverys with age greater than or equal to 24 if (learnerAgewithResToProgStartdate < 24) { continue; } //pick lds with FAMCode and type if (learningDelivery.LearningDeliveryFAMs .Count(ldFAM => ldFAM.LearnDelFAMCode == "1" && ldFAM.LearnDelFAMType == "FFI") <= 0) { continue; } //check and validate the LARSNVQ condition if (_ValidateLARNotionalNVQLevelRule.Evaluate(learningDelivery)) { result.Add(learningDelivery); } } return(result); }
public void ValidLARSNVQValuesReturnsTrue() { var mock = new Mock <ILARSNotionalNVQLevelData>(); mock.Setup(x => x.Get(It.IsAny <string>())).Returns(new List <string>() { "E", "b" }); var mockRefData = new Mock <IReferenceData <string, string> >(); mockRefData.Setup(x => x.Get(It.IsAny <string>())).Returns("E,1"); _ValidateLARNotionalNVQLevelRule = new ValidateLARNotionalNVQLevelRule(mock.Object, mockRefData.Object); var parameter = new MessageLearnerLearningDelivery() { LearnAimRef = "" }; var actual = _ValidateLARNotionalNVQLevelRule.Evaluate(parameter); Assert.True(actual); }
public void InvalidLARSNVQValuesReturnsFalse() { var mockExternalData = new Mock <IExternalData <string, List <string> > >(); mockExternalData.Setup(x => x.Get(It.IsAny <string>())).Returns(new List <string>() { "a", "b" }); var mockRefData = new Mock <IReferenceData <string, string> >(); mockRefData.Setup(x => x.Get(It.IsAny <string>())).Returns("A,1,2"); _ValidateLARNotionalNVQLevelRule = new ValidateLARNotionalNVQLevelRule(mockExternalData.Object, mockRefData.Object); var parameter = new LearningDelivery() { LearnAimRef = "" }; var actual = _ValidateLARNotionalNVQLevelRule.Evaluate(parameter); Assert.False(actual); }