Mercurial > pub > bltoolkit
comparison UnitTests/CS/Validation/RegExValidationTest.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 BLToolkit.EditableObjects; | |
2 using BLToolkit.Reflection; | |
3 using BLToolkit.Validation; | |
4 using NUnit.Framework; | |
5 | |
6 namespace Validation | |
7 { | |
8 [TestFixture] | |
9 public class RegExValidationTest | |
10 { | |
11 public abstract class Entity : EditableObject | |
12 { | |
13 [RegEx("[a-zA-Z0-9]*")] | |
14 public string AlphaNumeric; | |
15 } | |
16 | |
17 [Test] | |
18 public void Test() | |
19 { | |
20 Entity entity = (Entity)TypeAccessor.CreateInstance(typeof(Entity)); | |
21 | |
22 entity.AlphaNumeric = null; Assert.IsTrue(entity.IsValid("AlphaNumeric")); | |
23 entity.AlphaNumeric = ""; Assert.IsTrue(entity.IsValid("AlphaNumeric")); | |
24 entity.AlphaNumeric = "abAB01"; Assert.IsTrue(entity.IsValid("AlphaNumeric")); | |
25 entity.AlphaNumeric = "01ABab"; Assert.IsTrue(entity.IsValid("AlphaNumeric")); | |
26 entity.AlphaNumeric = "ab_AB.01"; Assert.IsFalse(entity.IsValid("AlphaNumeric")); | |
27 entity.AlphaNumeric = "33###"; Assert.IsFalse(entity.IsValid("AlphaNumeric")); | |
28 } | |
29 } | |
30 } |