|
From: <joe...@us...> - 2003-06-01 09:48:51
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv31005/src/NMock
Modified Files:
DynamicMock.cs
Log Message:
Added better support for mocking interface hierarchies (Jeremy Stell-Smith pointed out the brokenness of it all).
Index: DynamicMock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/DynamicMock.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** DynamicMock.cs 13 Mar 2003 22:22:11 -0000 1.8
--- DynamicMock.cs 1 Jun 2003 09:48:48 -0000 1.9
***************
*** 95,111 ****
void checkMethodIsValid(string methodName)
{
! MethodInfo method = type.GetMethod(methodName, ClassGenerator.ALL_INSTANCE_METHODS);
! PropertyInfo property = type.GetProperty(methodName, ClassGenerator.ALL_INSTANCE_METHODS);
!
! if (method == null && property == null)
! {
! throw new MissingMethodException(String.Format("method <{0}> not defined", methodName));
! }
!
!
! if(method != null)
{
! if(!method.IsVirtual) throw new ArgumentException(String.Format("method <{0}> is not virtual", methodName));
}
}
--- 95,118 ----
void checkMethodIsValid(string methodName)
{
!
! Type[] allTypes = new InterfaceLister().List(type);
! foreach (Type t in allTypes)
{
! MethodInfo method = t.GetMethod(methodName, ClassGenerator.ALL_INSTANCE_METHODS);
! PropertyInfo property = t.GetProperty(methodName, ClassGenerator.ALL_INSTANCE_METHODS);
! if (property != null)
! {
! return;
! }
! if(method != null)
! {
! if(!method.IsVirtual)
! {
! throw new ArgumentException(String.Format("method <{0}> is not virtual", methodName));
! }
! return;
! }
}
+ throw new MissingMethodException(String.Format("method <{0}> not defined", methodName));
}
|