2009-02-10 Jeffrey Stedfast <fejj@novell.com>
[mono-project/dkf.git] / mcs / nunit20 / mocks / MethodSignature.cs
blob516b5ed6d37b9bdaa1e06fc0a4be39b1916f9e59
1 using System;
3 namespace NUnit.Mocks
5 /// <summary>
6 /// Summary description for MockSignature.
7 /// </summary>
8 public class MethodSignature
10 public readonly string typeName;
11 public readonly string methodName;
12 public readonly Type[] argTypes;
14 public MethodSignature( string typeName, string methodName, Type[] argTypes )
16 this.typeName = typeName;
17 this.methodName = methodName;
18 this.argTypes = argTypes;
21 public bool IsCompatibleWith( object[] args )
23 if ( args.Length != argTypes.Length )
24 return false;
26 for( int i = 0; i < args.Length; i++ )
27 if ( !argTypes[i].IsAssignableFrom( args[i].GetType() ) )
28 return false;
30 return true;
33 public static Type[] GetArgTypes( object[] args )
35 if ( args == null )
36 return new Type[0];
38 Type[] argTypes = new Type[args.Length];
39 for (int i = 0; i < argTypes.Length; ++i)
41 if (args[i] == null)
42 argTypes[i] = typeof(object);
43 else
44 argTypes[i] = args[i].GetType();
47 return argTypes;