2009-06-12 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mcs / nunit20 / mocks / MethodSignature.cs
1 using System;
2
3 namespace NUnit.Mocks
4 {
5         /// <summary>
6         /// Summary description for MockSignature.
7         /// </summary>
8         public class MethodSignature
9         {
10                 public readonly string typeName;
11                 public readonly string methodName;
12                 public readonly Type[] argTypes;
13
14                 public MethodSignature( string typeName, string methodName, Type[] argTypes )
15                 {
16                         this.typeName = typeName;
17                         this.methodName = methodName;
18                         this.argTypes = argTypes; 
19                 }
20
21                 public bool IsCompatibleWith( object[] args )
22                 {
23                         if ( args.Length != argTypes.Length )
24                                 return false;
25
26                         for( int i = 0; i < args.Length; i++ )
27                                 if ( !argTypes[i].IsAssignableFrom( args[i].GetType() ) )
28                                         return false;
29
30                         return true;
31                 }
32
33                 public static Type[] GetArgTypes( object[] args )
34                 {
35                         if ( args == null )
36                                 return new Type[0];
37
38                         Type[] argTypes = new Type[args.Length];
39                         for (int i = 0; i < argTypes.Length; ++i)
40                         {
41                                 if (args[i] == null)
42                                         argTypes[i] = typeof(object);
43                                 else
44                                         argTypes[i] = args[i].GetType();
45                         }
46
47                         return argTypes;
48                 }
49         }
50 }