root / trunk / hammock / src / net35 / Hammock.Tests / Attributes / Validation / RequiredAttributeTests.cs @ 0eea575a
History | View | Annotate | Download (959 Bytes)
1 |
using Hammock.Attributes.Specialized; |
---|---|
2 |
using Hammock.Attributes.Validation; |
3 |
using Hammock.Validation; |
4 |
using Hammock.Web; |
5 |
using NUnit.Framework; |
6 |
|
7 |
namespace Hammock.Tests.Attributes.Validation |
8 |
{ |
9 |
[TestFixture] |
10 |
public class RequiredAttributeTests |
11 |
{ |
12 |
public class RequiredInfo : IWebQueryInfo |
13 |
{ |
14 |
[Required] |
15 |
[Header("Result")] |
16 |
public string ICantBeNull { get; set; } |
17 |
} |
18 |
|
19 |
[Test] |
20 |
[ExpectedException(typeof(ValidationException))] |
21 |
public void Can_use_required_validation_to_block_null_value() |
22 |
{ |
23 |
var info = new RequiredInfo { ICantBeNull = null }; |
24 |
|
25 |
var client = new RestClient |
26 |
{ |
27 |
Authority = "http://nowhere.com", |
28 |
Info = info |
29 |
}; |
30 |
|
31 |
var request = new RestRequest |
32 |
{ |
33 |
Path = "fast" |
34 |
}; |
35 |
|
36 |
client.Request(request); |
37 |
} |
38 |
} |
39 |
|
40 |
} |