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