public async void Test_LessThanIntChecker() { var checker = new LessThanIntChecker <Student>(5, _Validation); var result = await checker.ValidateAsync(new ValidateResult(), 1, "", ""); Assert.True(result.IsValid); result = await checker.ValidateAsync(new ValidateResult(), 9, "a", null); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("a", result.Failures[0].Name); Assert.Equal(string.Format("The value must less than {0}", 5), result.Failures[0].Error); Assert.Equal(9, result.Failures[0].Value); result = await checker.ValidateAsync(new ValidateResult(), 5, "a1", "c"); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("a1", result.Failures[0].Name); Assert.Equal("c", result.Failures[0].Error); Assert.Equal(5, result.Failures[0].Value); }
public async void Test_LessThanIntChecker() { var checker = new LessThanIntChecker<Student>(5, _Validation); var result = await checker.ValidateAsync(new ValidateResult(), 1, "", ""); Assert.True(result.IsValid); result = await checker.ValidateAsync(new ValidateResult(), 9, "a", null); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("a", result.Failures[0].Name); Assert.Equal(string.Format("The value must less than {0}", 5), result.Failures[0].Error); Assert.Equal(9, result.Failures[0].Value); result = await checker.ValidateAsync(new ValidateResult(), 5, "a1", "c"); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("a1", result.Failures[0].Name); Assert.Equal("c", result.Failures[0].Error); Assert.Equal(5, result.Failures[0].Value); }