public void MultiValidationTooSmallTest() { var validator = ChainingValidator .Create <int, NumberDetail?>((int source) => source < 10, (NumberDetail?)NumberDetail.TooBig) .Add((source) => source >= 0, NumberDetail.TooSmall); var result = validator.Validate(-1); result.Detail.Is(NumberDetail.TooSmall); result.IsValid.IsFalse(); result.Source.Is(-1); }
public void SingleValidationSuccessTest() { var validator = ChainingValidator .Create <int, NumberDetail?>(source => source < 10, NumberDetail.TooBig); // valid source var result = validator.Validate(1); result.Detail.IsNull(); result.IsValid.IsTrue(); result.Source.Is(1); }
public void SingleValidationFailedTest() { var validator = ChainingValidator .Create <int, NumberDetail?>(source => source < 10, NumberDetail.TooBig); // invalid source var result = validator.Validate(10); result.Detail.Is(NumberDetail.TooBig); result.IsValid.IsFalse(); result.Source.Is(10); }