public async void Test_BetweenLongChecker() { var checker = new BetweenLongChecker <Student>(3L, 10L, _Validation); var ex = Assert.Throws <ArgumentOutOfRangeException>(() => new BetweenLongChecker <Student>(33L, 10L, _Validation)); Assert.Equal("max", ex.ParamName); Assert.True(ex.Message.Contains("Max should be larger than min.")); var result = await checker.ValidateAsync(new ValidateResult(), 4L, "", ""); Assert.True(result.IsValid); result = await checker.ValidateAsync(new ValidateResult(), 3L, "a", "c"); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("a", result.Failures[0].Name); Assert.Equal("c", result.Failures[0].Error); Assert.Equal(3L, result.Failures[0].Value); result = await checker.ValidateAsync(new ValidateResult(), 1L, "a1", "c1"); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("a1", result.Failures[0].Name); Assert.Equal("c1", result.Failures[0].Error); Assert.Equal(1L, result.Failures[0].Value); result = await checker.ValidateAsync(new ValidateResult(), 10L, "b", null); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("b", result.Failures[0].Name); Assert.Equal("The value is not between 3 and 10", result.Failures[0].Error); Assert.Equal(10L, result.Failures[0].Value); result = await checker.ValidateAsync(new ValidateResult(), 100L, "b1", null); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("b1", result.Failures[0].Name); Assert.Equal("The value is not between 3 and 10", result.Failures[0].Error); Assert.Equal(100L, result.Failures[0].Value); }
public async void Test_BetweenLongChecker() { var checker = new BetweenLongChecker<Student>(3L, 10L, _Validation); var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new BetweenLongChecker<Student>(33L, 10L, _Validation)); Assert.Equal("max", ex.ParamName); Assert.True(ex.Message.Contains("Max should be larger than min.")); var result = await checker.ValidateAsync(new ValidateResult(), 4L, "", ""); Assert.True(result.IsValid); result = await checker.ValidateAsync(new ValidateResult(), 3L, "a", "c"); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("a", result.Failures[0].Name); Assert.Equal("c", result.Failures[0].Error); Assert.Equal(3L, result.Failures[0].Value); result = await checker.ValidateAsync(new ValidateResult(), 1L, "a1", "c1"); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("a1", result.Failures[0].Name); Assert.Equal("c1", result.Failures[0].Error); Assert.Equal(1L, result.Failures[0].Value); result = await checker.ValidateAsync(new ValidateResult(), 10L, "b", null); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("b", result.Failures[0].Name); Assert.Equal("The value is not between 3 and 10", result.Failures[0].Error); Assert.Equal(10L, result.Failures[0].Value); result = await checker.ValidateAsync(new ValidateResult(), 100L, "b1", null); Assert.False(result.IsValid); Assert.Equal(1, result.Failures.Count); Assert.Equal("b1", result.Failures[0].Name); Assert.Equal("The value is not between 3 and 10", result.Failures[0].Error); Assert.Equal(100L, result.Failures[0].Value); }