public void InvalidItemRaisesValidationMessage(string candidate) { const string LearnRefNumber = "123456789X"; var fams = new List <ILearnerFAM>(); var mockLearner = new Mock <ILearner>(); mockLearner .SetupGet(x => x.LearnRefNumber) .Returns(LearnRefNumber); mockLearner .SetupGet(x => x.EngGrade) .Returns(candidate); mockLearner .SetupGet(x => x.LearnerFAMs) .Returns(fams); var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); handler .Setup(x => x.Handle( Moq.It.Is <string>(y => y == EngGrade_03Rule.Name), Moq.It.Is <string>(y => y == LearnRefNumber), null, null)); var sut = new EngGrade_03Rule(handler.Object); sut.Validate(mockLearner.Object); handler.VerifyAll(); }
public void Validate_Error() { var learner = SetupLearner("D"); var validationErrorHandlerMock = new Mock <IValidationErrorHandler>(); Expression <Action <IValidationErrorHandler> > handle = veh => veh.Handle("EngGrade_03", null, null, null); var learnerFamQueryService = new Mock <ILearnerFAMQueryService>(); learnerFamQueryService.Setup(x => x.HasLearnerFAMCodeForType(It.IsAny <IEnumerable <ILearnerFAM> >(), It.IsAny <string>(), It.IsAny <long>())) .Returns(false); var rule = new EngGrade_03Rule(validationErrorHandlerMock.Object, learnerFamQueryService.Object); rule.Validate(learner); validationErrorHandlerMock.Verify(handle, Times.Once); }
public void ValidItemDoesNotRaiseValidationMessage(string candidate) { // arrange const string LearnRefNumber = "123456789X"; // this is actually wrong for level 2 passes // but this rule doesn't require a check for this condition. var mockFAM = new Mock <ILearnerFAM>(); mockFAM .SetupGet(x => x.LearnFAMType) .Returns(Monitoring.Learner.Types.EligibilityFor16To19DisadvantageFunding); mockFAM .SetupGet(x => x.LearnFAMCode) .Returns(2); var fams = Collection.Empty <ILearnerFAM>(); fams.Add(mockFAM.Object); var mockLearner = new Mock <ILearner>(); mockLearner .SetupGet(x => x.LearnRefNumber) .Returns(LearnRefNumber); mockLearner .SetupGet(x => x.EngGrade) .Returns(candidate); mockLearner .SetupGet(x => x.LearnerFAMs) .Returns(fams.AsSafeReadOnlyList()); var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); var sut = new EngGrade_03Rule(handler.Object); // act sut.Validate(mockLearner.Object); // assert handler.VerifyAll(); }
public void ValidItemDoesNotRaiseValidationMessage(string candidate) { const string LearnRefNumber = "123456789X"; var mockFAM = new Mock <ILearnerFAM>(); mockFAM .SetupGet(x => x.LearnFAMType) .Returns(Monitoring.Learner.Types.EligibilityFor16To19DisadvantageFunding); mockFAM .SetupGet(x => x.LearnFAMCode) .Returns(2); var fams = new List <ILearnerFAM>(); fams.Add(mockFAM.Object); var mockLearner = new Mock <ILearner>(); mockLearner .SetupGet(x => x.LearnRefNumber) .Returns(LearnRefNumber); mockLearner .SetupGet(x => x.EngGrade) .Returns(candidate); mockLearner .SetupGet(x => x.LearnerFAMs) .Returns(fams); var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict); var sut = new EngGrade_03Rule(handler.Object); sut.Validate(mockLearner.Object); handler.VerifyAll(); }