Fixed test issue - PEVerify is now called with a quoted assembly path (to allow for...
[castle.git] / Tools / Castle.DynamicProxy2 / Castle.DynamicProxy.Tests / MethodComparerTestCase.cs
blob167849bdb30876ec810c69d773b5264753c7d739
1 using System.Collections.Generic;
3 namespace Castle.DynamicProxy.Tests
5 using System;
6 using System.Collections;
7 using System.Reflection;
8 using Castle.DynamicProxy.Generators;
9 using NUnit.Framework;
11 [TestFixture]
12 public class MethodComparerTestCase
14 public static void GenericMethod<T> () { }
15 public static void GenericMethod2<T> () { }
17 public static void GenericMethod3<T, H> (T t, H h) { }
19 class FakeScope
21 public static void GenericMethod () { }
22 public static void GenericMethod3<T> (T t) { }
25 class NewScope
27 public static void GenericMethod3<T, H> (H t, T h) { }
30 [Test]
31 public void CompareMethods ()
33 MethodSignatureComparer mc = MethodSignatureComparer.Instance;
34 Assert.IsTrue (mc.Equals (null, null));
35 Assert.IsFalse (mc.Equals (null, typeof (object).GetMethod ("ToString")));
37 Assert.IsTrue (mc.Equals (typeof (object).GetMethod ("ToString"), typeof (object).GetMethod ("ToString")));
38 Assert.IsTrue (mc.Equals (typeof (List<>).GetMethod ("get_Count"), typeof (List<>).GetMethod ("get_Count")));
39 Assert.IsTrue (mc.Equals (typeof (List<int>).GetMethod ("get_Count"), typeof (List<int>).GetMethod ("get_Count")));
40 Assert.IsTrue (mc.Equals (typeof (List<>).GetMethod ("get_Count"), typeof (List<int>).GetMethod ("get_Count")));
41 Assert.IsTrue (mc.Equals (typeof (List<string>).GetMethod ("get_Count"), typeof (List<>).GetMethod ("get_Count")));
42 Assert.IsTrue (mc.Equals (typeof (List<>).GetMethod ("get_Item"), typeof (List<>).GetMethod ("get_Item")));
44 Assert.IsTrue (mc.Equals (typeof (List<string>).GetMethod ("Add"), typeof (List<string>).GetMethod ("Add")));
45 Assert.IsFalse (mc.Equals (typeof (List<string>).GetMethod ("Add"), typeof (List<>).GetMethod ("Add")));
46 Assert.IsFalse (mc.Equals (typeof (List<>).GetMethod ("Add"), typeof (List<string>).GetMethod ("Add")));
48 Assert.IsTrue (mc.Equals (typeof (List<string>).GetMethod ("get_Item"), typeof (List<string>).GetMethod ("get_Item")));
49 Assert.IsFalse (mc.Equals (typeof (List<string>).GetMethod ("get_Item"), typeof (List<>).GetMethod ("get_Item")));
50 Assert.IsFalse (mc.Equals (typeof (List<>).GetMethod ("get_Item"), typeof (List<string>).GetMethod ("get_Item")));
52 Assert.IsTrue (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod"), typeof (MethodComparerTestCase).GetMethod ("GenericMethod")));
53 Assert.IsTrue (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod").MakeGenericMethod (typeof (int)),
54 typeof (MethodComparerTestCase).GetMethod ("GenericMethod").MakeGenericMethod (typeof (int))));
55 Assert.IsFalse (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod").MakeGenericMethod (typeof (int)),
56 typeof (MethodComparerTestCase).GetMethod ("GenericMethod").MakeGenericMethod (typeof (string))));
57 Assert.IsFalse (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod").MakeGenericMethod (typeof (int)),
58 typeof (MethodComparerTestCase).GetMethod ("GenericMethod")));
59 Assert.IsFalse (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod"), typeof (MethodComparerTestCase).GetMethod ("GenericMethod2")));
61 Assert.IsTrue (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod3"), typeof (MethodComparerTestCase).GetMethod ("GenericMethod3")));
62 Assert.IsFalse (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod3"), typeof (NewScope).GetMethod ("GenericMethod3")));
63 Assert.IsTrue (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod3").MakeGenericMethod (typeof (int), typeof (int)),
64 typeof (NewScope).GetMethod ("GenericMethod3").MakeGenericMethod (typeof (int), typeof (int))));
66 Assert.IsFalse (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod3").MakeGenericMethod (typeof (int), typeof (string)),
67 typeof (NewScope).GetMethod ("GenericMethod3").MakeGenericMethod (typeof (int), typeof (string))));
69 Assert.IsFalse (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod3").MakeGenericMethod (typeof (int), typeof (string)),
70 typeof (NewScope).GetMethod ("GenericMethod3").MakeGenericMethod (typeof (string), typeof (int))));
72 Assert.IsFalse (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod3"), typeof (FakeScope).GetMethod ("GenericMethod3")));
74 Assert.IsFalse (mc.Equals (typeof (MethodComparerTestCase).GetMethod ("GenericMethod"), typeof (FakeScope).GetMethod ("GenericMethod")));
76 Assert.IsFalse (mc.Equals (typeof (Console).GetMethod ("WriteLine", new Type[] { typeof (object) }),
77 typeof (Console).GetMethod ("WriteLine", new Type[] { typeof (string), typeof (object[]) })));
78 Assert.IsTrue (mc.Equals (typeof (Console).GetMethod ("WriteLine", new Type[] { typeof (string), typeof (object[]) }),
79 typeof (Console).GetMethod ("WriteLine", new Type[] { typeof (string), typeof (object[]) })));