|
From: <sm...@us...> - 2003-11-29 17:04:50
|
Update of /cvsroot/nmock/nmock/test/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv19354/test/NMock
Modified Files:
FastErrorHandlingTest.cs DynamicMockTest.cs
Log Message:
Allow SetupResult to return conformant types, rather than exact match
Bit more refactoring
Index: FastErrorHandlingTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/FastErrorHandlingTest.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** FastErrorHandlingTest.cs 24 Jul 2003 23:09:05 -0000 1.3
--- FastErrorHandlingTest.cs 29 Nov 2003 17:04:47 -0000 1.4
***************
*** 72,76 ****
catch (ArgumentException e)
{
! AssertEquals("method <Foo> returns a System.String", e.Message);
}
}
--- 72,76 ----
catch (ArgumentException e)
{
! AssertEquals("method <Foo> should return a System.String", e.Message);
}
}
Index: DynamicMockTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/DynamicMockTest.cs,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** DynamicMockTest.cs 7 Nov 2003 23:28:39 -0000 1.17
--- DynamicMockTest.cs 29 Nov 2003 17:04:47 -0000 1.18
***************
*** 78,81 ****
--- 78,86 ----
void SomeParametersMethod(string p1, string p2);
}
+
+ interface WithMethodThatReturnsAMock
+ {
+ Mock ReturnIt();
+ }
#endregion
***************
*** 136,139 ****
--- 141,152 ----
}
+ [Test] public void SetupResultCanReturnAssignableTypesAsWellAsTheSameType()
+ {
+ DynamicMock mock = new DynamicMock(typeof(WithMethodThatReturnsAMock));
+
+ mock.SetupResult("ReturnIt", new DynamicMock(typeof(object)));
+
+ ((WithMethodThatReturnsAMock)mock.MockInstance).ReturnIt();
+ }
[Test] public void CanSetStubsAndExpectationsOnMethodsInTheSameClass()
{
|