public async void Test_LessThanFloatChecker() { var checker = new LessThanFloatChecker <Student>(5f, _Validation); var result = await checker.ValidateAsync(new ValidateResult(), 2f, "", ""); Assert.True(result.IsValid); result = await checker.ValidateAsync(new ValidateResult(), 8f, "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}", 5f), result.Failures[0].Error); Assert.Equal(8f, result.Failures[0].Value); result = await checker.ValidateAsync(new ValidateResult(), 5f, "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(5f, result.Failures[0].Value); }
public async void Test_LessThanFloatChecker() { var checker = new LessThanFloatChecker<Student>(5f, _Validation); var result = await checker.ValidateAsync(new ValidateResult(), 2f, "", ""); Assert.True(result.IsValid); result = await checker.ValidateAsync(new ValidateResult(), 8f, "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}", 5f), result.Failures[0].Error); Assert.Equal(8f, result.Failures[0].Value); result = await checker.ValidateAsync(new ValidateResult(), 5f, "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(5f, result.Failures[0].Value); }