2 // TypeDelegatorTest.cs - NUnit Test Cases for the TypeDelegator class
4 // Zoltan Varga (vargaz@freemail.hu)
6 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
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.
29 using System.Threading;
30 using System.Reflection;
31 using System.Reflection.Emit;
33 using NUnit.Framework;
35 namespace MonoTests.System.Reflection
38 public class TypeDelegatorTest : Assertion {
41 public void IsAssignableFrom ()
43 TypeDelegator td = new TypeDelegator (typeof (int));
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)));
52 public void CreateInstance ()
54 AssertEquals (typeof (int[]), Array.CreateInstance (new TypeDelegator (typeof (int)), 100).GetType ());
58 public void Properties ()
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);
65 AssertEquals (true, new TypeDelegator (typeof (TypeDelegatorTest)).IsClass);
66 AssertEquals (false, new TypeDelegator (typeof (TypeDelegatorTest)).IsValueType);
67 AssertEquals (false, new TypeDelegator (typeof (TypeDelegatorTest)).IsInterface);
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);