Mercurial > pub > bltoolkit
comparison HowTo/Aspects/NotNull.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 | |
3 using NUnit.Framework; | |
4 | |
5 using BLToolkit.Aspects; | |
6 using BLToolkit.Reflection; | |
7 | |
8 namespace HowTo.Aspects | |
9 { | |
10 [TestFixture] | |
11 public class NotNullTest | |
12 { | |
13 public /*[a]*/abstract/*[/a]*/ class TestObject | |
14 { | |
15 public /*[a]*/virtual/*[/a]*/ void Foo1(string str1, [/*[a]*/NotNull/*[/a]*/] string str2, string str3) {} | |
16 public /*[a]*/virtual/*[/a]*/ void Foo2(string str1, [/*[a]*/NotNull/*[/a]*/(/*[a]*/"Null"/*[/a]*/)] string str2, string str3) {} | |
17 public /*[a]*/virtual/*[/a]*/ void Foo3(string str1, [/*[a]*/NotNull/*[/a]*/(/*[a]*/"Null: {0}"/*[/a]*/)] string str2, string str3) {} | |
18 | |
19 public static TestObject CreateInstance() { return /*[a]*/TypeAccessor/*[/a]*/<TestObject>.CreateInstance(); } | |
20 } | |
21 | |
22 [Test, ExpectedException(typeof(ArgumentNullException))] // Error message is localized by framework. | |
23 public void Test1() | |
24 { | |
25 TestObject o = TestObject.CreateInstance(); | |
26 | |
27 o.Foo1("str1", /*[a]*/null/*[/a]*/, "str3"); | |
28 } | |
29 | |
30 [Test] | |
31 [ExpectedException(typeof(ArgumentNullException), ExpectedMessage="Null")] | |
32 public void Test2() | |
33 { | |
34 TestObject o = TestObject.CreateInstance(); | |
35 | |
36 o.Foo2("str1", /*[a]*/null/*[/a]*/, "str3"); | |
37 } | |
38 | |
39 [Test] | |
40 [ExpectedException(typeof(ArgumentNullException), ExpectedMessage="Null: str2")] | |
41 public void Test3() | |
42 { | |
43 TestObject o = TestObject.CreateInstance(); | |
44 | |
45 o.Foo3("str1", /*[a]*/null/*[/a]*/, "str3"); | |
46 } | |
47 } | |
48 } |