|
From: Owen R. <exo...@us...> - 2004-04-08 04:00:48
|
Update of /cvsroot/nmock/nmock/test/NMock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8638/test/NMock Modified Files: DynamicMockTest.cs FastErrorHandlingTest.cs Log Message: - applying Levi's fixes - fixed bug where NMock overrides the class' destructor Index: FastErrorHandlingTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/FastErrorHandlingTest.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FastErrorHandlingTest.cs 29 Nov 2003 17:04:47 -0000 1.4 --- FastErrorHandlingTest.cs 8 Apr 2004 03:47:41 -0000 1.5 *************** *** 25,28 **** --- 25,33 ---- } + public virtual string Foo(string s) + { + return "foo"; + } + public string Bar(string s) { *************** *** 51,57 **** catch (MissingMethodException e) { ! AssertEquals("method <Foo> not defined", e.Message); } } [Test] --- 56,96 ---- catch (MissingMethodException e) { ! AssertEquals( ! "method <MockEmpty.Foo()> not defined", e.Message); } } + + [Test] + public void ExpectWithWrongArgType() + { + try + { + full.Expect("Foo", 1); + Fail(); + } + catch (MissingMethodException e) + { + AssertEquals( + "method <MockFull.Foo(System.Int32)> not defined", + e.Message); + } + } + + [Test] + public void ExpectWithWrongArgNumber() + { + try + { + full.Expect("Foo", true, 1); + Fail(); + } + catch (MissingMethodException e) + { + AssertEquals( + "method <MockFull.Foo(System.Boolean, System.Int32)> not defined", + e.Message); + } + } + [Test] *************** *** 72,76 **** catch (ArgumentException e) { ! AssertEquals("method <Foo> should return a System.String", e.Message); } } --- 111,117 ---- catch (ArgumentException e) { ! AssertEquals( ! "method <MockFull.Foo()> should return a System.String", ! e.Message); } } Index: DynamicMockTest.cs =================================================================== RCS file: /cvsroot/nmock/nmock/test/NMock/DynamicMockTest.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** DynamicMockTest.cs 23 Mar 2004 06:20:17 -0000 1.19 --- DynamicMockTest.cs 8 Apr 2004 03:47:41 -0000 1.20 *************** *** 83,86 **** --- 83,92 ---- Mock ReturnIt(); } + + public class DisposableThingy : Thingy + { + public static int DestructorCallCount = 0; + ~DisposableThingy() { DestructorCallCount++; } + } #endregion *************** *** 364,367 **** --- 370,389 ---- mock.Verify(); } + + [Test] public void VerifyThatFinalizeIsNotOverriddenInMockSubClass() + { + DisposableThingy.DestructorCallCount = 0; + CreateDisposableThingyMock(); + GC.Collect(); + AssertEquals(1, DisposableThingy.DestructorCallCount); + DisposableThingy.DestructorCallCount = 0; + } + + private void CreateDisposableThingyMock() + { + IMock mock = new DynamicMock(typeof(DisposableThingy)); + mock.Strict = true; + DisposableThingy thingy = (DisposableThingy) mock.MockInstance; + } } } |