comparison UnitTests/CS/Validation/NullValue.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using BLToolkit.EditableObjects;
3 using BLToolkit.Reflection;
4 using NUnit.Framework;
5
6 using BLToolkit.Validation;
7 using BLToolkit.Mapping;
8
9 namespace Validation
10 {
11 [TestFixture]
12 public class NullValue
13 {
14 public class Entity : EditableObject
15 {
16 private byte timeStart;
17
18 [Required("Time Start is required")]
19 [NullValue(typeof(byte), 99)]
20 public byte TimeStart
21 {
22 get { return timeStart; }
23 set { timeStart = value; }
24 }
25 }
26
27 [Test]
28 public void Test()
29 {
30 Entity test = new Entity();
31
32 test.TimeStart = 0;
33 test.Validate();
34 }
35
36 public abstract class PersonDoc : EditableObject
37 {
38 [MapField("Series_PersonDoc"), MaxLength(50), Required]
39 public abstract string Series_PersonDoc { get; set; }
40
41 [MapField("BegDate_PersonDoc"), Required]
42 [NullDateTime()]
43 public abstract DateTime BegDate_PersonDoc { get; set; }
44 }
45
46
47 [Test, ExpectedException(typeof(ValidationException))]
48 public void Test2()
49 {
50 PersonDoc doc = TypeAccessor<PersonDoc>.CreateInstance();
51
52 doc.Series_PersonDoc = "PersonDoc";
53 doc.Validate();
54 }
55 }
56 }