|
|
|
@ -1,3 +1,4 @@ |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using FluentValidation; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
@ -63,7 +64,7 @@ namespace Volo.Abp.FluentValidation |
|
|
|
{ |
|
|
|
// MyStringValue should be aaa, MyStringValue2 should be bbb. MyStringValue3 should be ccc
|
|
|
|
|
|
|
|
Assert.Throws<AbpValidationException>(() => _myAppService.MyMethod(new MyMethodInput |
|
|
|
var exception = Assert.Throws<AbpValidationException>(() => _myAppService.MyMethod(new MyMethodInput |
|
|
|
{ |
|
|
|
MyStringValue = "a", |
|
|
|
MyMethodInput2 = new MyMethodInput2 |
|
|
|
@ -75,8 +76,11 @@ namespace Volo.Abp.FluentValidation |
|
|
|
MyStringValue3 = "c" |
|
|
|
} |
|
|
|
})); |
|
|
|
exception.ValidationErrors.ShouldContain(x => x.MemberNames.Contains("MyStringValue")); |
|
|
|
exception.ValidationErrors.ShouldContain(x => x.MemberNames.Contains("MyMethodInput2.MyStringValue2")); |
|
|
|
exception.ValidationErrors.ShouldContain(x => x.MemberNames.Contains("MyMethodInput3.MyStringValue3")); |
|
|
|
|
|
|
|
await Assert.ThrowsAsync<AbpValidationException>(async () => await _myAppService.MyMethodAsync( |
|
|
|
exception = await Assert.ThrowsAsync<AbpValidationException>(async () => await _myAppService.MyMethodAsync( |
|
|
|
new MyMethodInput |
|
|
|
{ |
|
|
|
MyStringValue = "a", |
|
|
|
@ -89,6 +93,9 @@ namespace Volo.Abp.FluentValidation |
|
|
|
MyStringValue3 = "c" |
|
|
|
} |
|
|
|
})); |
|
|
|
exception.ValidationErrors.ShouldContain(x => x.MemberNames.Contains("MyStringValue")); |
|
|
|
exception.ValidationErrors.ShouldContain(x => x.MemberNames.Contains("MyMethodInput2.MyStringValue2")); |
|
|
|
exception.ValidationErrors.ShouldContain(x => x.MemberNames.Contains("MyMethodInput3.MyStringValue3")); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
|