Browse Source

fixed unittest for FluentValidation

pull/2441/head
兜小神 7 years ago
parent
commit
c318133484
  1. 11
      framework/test/Volo.Abp.FluentValidation.Tests/Volo/Abp/FluentValidation/ApplicationService_FluentValidation_Tests.cs

11
framework/test/Volo.Abp.FluentValidation.Tests/Volo/Abp/FluentValidation/ApplicationService_FluentValidation_Tests.cs

@ -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]

Loading…
Cancel
Save