using System;
using System.Collections.Generic;
using Util.Validation.Tests.Infrastructure;
using Util.Validation.Tests.Samples;
using Xunit;
namespace Util.Validation.Tests {
///
/// 验证拦截器测试
///
public class ValidAttributeTest : TestBase {
///
/// 验证单个对象
///
[Fact]
public void TestValidate() {
Sample sample = new Sample();
var service = GetService();
Assert.Throws( () => {
service.Call( sample );
} );
}
///
/// 验证单个对象 - 验证通过不会抛出异常
///
[Fact]
public void TestValidate_2() {
Sample sample = new Sample {RequiredValue = "a"};
var service = GetService();
service.Call( sample );
}
///
/// 验证集合对象
///
[Fact]
public void TestValidateCollection() {
List samples = new List {new Sample(), new Sample() };
var service = GetService();
Assert.Throws( () => {
service.CallCollection( samples );
} );
}
///
/// 验证集合对象 - 验证通过不会抛出异常
///
[Fact]
public void TestValidateCollection_2() {
List samples = new List { new Sample{RequiredValue = "a"}, new Sample{RequiredValue = "b"} };
var service = GetService();
service.CallCollection( samples );
}
}
}