Skip to content

Commit 2a3b559

Browse files
committed
test: 更新单元测试
1 parent 30997f9 commit 2a3b559

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/UnitTest/Validators/RequiredValidatorTest.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public void AllowEmptyString_Ok()
3737
[Fact]
3838
public void EnumerableValue_Ok()
3939
{
40+
int[] value = [1, 2];
4041
var foo = new Foo();
4142
var validator = new RequiredValidator()
4243
{
@@ -45,7 +46,7 @@ public void EnumerableValue_Ok()
4546
};
4647
var context = new ValidationContext(foo);
4748
var results = new List<ValidationResult>();
48-
validator.Validate(new int[] { 1, 2 }, context, results);
49+
validator.Validate(value, context, results);
4950
Assert.Empty(results);
5051

5152
validator.Validate(Array.Empty<int>(), context, results);
@@ -76,6 +77,10 @@ public void Localizer_Ok()
7677
validator.Validate("v1", context, results);
7778
Assert.Empty(results);
7879

80+
validator.Validate("", context, results);
81+
Assert.Single(results);
82+
83+
results.Clear();
7984
var provider = Context.Services.GetRequiredService<IServiceProvider>();
8085
validator = new RequiredValidator();
8186
context = new ValidationContext(foo, provider, null);

0 commit comments

Comments
 (0)