fixed tests
[mono.git] / mcs / class / corlib / Test / System.Reflection / TypeDelegatorTest.cs
1 //
2 // TypeDelegatorTest.cs - NUnit Test Cases for the TypeDelegator class
3 //
4 // Zoltan Varga (vargaz@freemail.hu)
5 //
6 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
15 // 
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
18 // 
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 //
27
28 using System;
29 using System.Threading;
30 using System.Reflection;
31 using System.Reflection.Emit;
32
33 using NUnit.Framework;
34
35 namespace MonoTests.System.Reflection
36 {
37 [TestFixture]
38 public class TypeDelegatorTest : Assertion {
39
40         [Test]
41         public void IsAssignableFrom ()
42         {
43                 TypeDelegator td = new TypeDelegator (typeof (int));
44
45                 AssertEquals (true, typeof (int).IsAssignableFrom (td));
46                 AssertEquals (false, typeof (string).IsAssignableFrom (td));
47                 AssertEquals (true, td.IsAssignableFrom (typeof (int)));
48                 AssertEquals (false, td.IsAssignableFrom (typeof (string)));
49     }
50
51         [Test]
52         public void CreateInstance ()
53         {
54                 AssertEquals (typeof (int[]), Array.CreateInstance (new TypeDelegator (typeof (int)), 100).GetType ());
55     }
56                 
57         [Test]
58         public void Properties ()
59         {
60                 AssertEquals (false, new TypeDelegator (typeof (IComparable)).IsClass);
61                 AssertEquals (false, new TypeDelegator (typeof (IComparable)).IsValueType);
62                 AssertEquals (false, new TypeDelegator (typeof (IComparable)).IsEnum);
63                 AssertEquals (true, new TypeDelegator (typeof (IComparable)).IsInterface);
64
65                 AssertEquals (true, new TypeDelegator (typeof (TypeDelegatorTest)).IsClass);
66                 AssertEquals (false, new TypeDelegator (typeof (TypeDelegatorTest)).IsValueType);
67                 AssertEquals (false, new TypeDelegator (typeof (TypeDelegatorTest)).IsInterface);
68
69                 AssertEquals (false, new TypeDelegator (typeof (TypeCode)).IsClass);
70                 AssertEquals (false, new TypeDelegator (typeof (TypeCode)).IsInterface);
71                 AssertEquals (true, new TypeDelegator (typeof (TypeCode)).IsValueType);
72                 AssertEquals (true, new TypeDelegator (typeof (TypeCode)).IsEnum);
73         }
74 }
75 }