Mercurial > pub > bltoolkit
comparison UnitTests/CS/TypeBuilder/GenericMethodTest.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 System.Collections.Generic; | |
3 | |
4 using NUnit.Framework; | |
5 | |
6 using BLToolkit.Aspects; | |
7 using BLToolkit.Reflection; | |
8 | |
9 namespace TypeBuilder | |
10 { | |
11 [TestFixture] | |
12 public class GenericMethodTest | |
13 { | |
14 public abstract class TestObject | |
15 { | |
16 public virtual T GetValue<T>([NotNull] T value) where T : class, ICloneable | |
17 { | |
18 return value; | |
19 } | |
20 | |
21 public abstract T Abstract<T>(T value) where T : struct, IFormattable; | |
22 public abstract T Abstract2<T>(T value) where T : new(); | |
23 public abstract T Abstract3<T>(T value); | |
24 } | |
25 | |
26 [Test, ExpectedException(typeof(ArgumentNullException))] | |
27 public void Test() | |
28 { | |
29 // If you got an 'Invalid executable format' exception here | |
30 // you need to install .Net Framework 2.0 SP1 or later. | |
31 // | |
32 TestObject t = TypeAccessor<TestObject>.CreateInstance(); | |
33 Assert.AreEqual("123", t.GetValue("123")); | |
34 Assert.AreEqual(0, t.Abstract(123)); | |
35 Assert.AreEqual(0, t.Abstract2(123)); | |
36 Assert.AreEqual(0, t.Abstract3(123)); | |
37 | |
38 // Throws ArgumentNullException | |
39 // | |
40 t.GetValue<string>(null); | |
41 } | |
42 | |
43 public abstract class TestClass<T> | |
44 { | |
45 public abstract L SelectAll<L>() where L : IList<T>, new(); | |
46 } | |
47 | |
48 // Works only with Mono. | |
49 // See https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=282829 | |
50 // | |
51 //[Test] | |
52 public void GenericMixTest() | |
53 { | |
54 TestClass<int> t = TypeAccessor.CreateInstance<TestClass<int>>(); | |
55 Assert.That(t, Is.Not.Null); | |
56 } | |
57 } | |
58 } |