From: Joe W. <joe...@us...> - 2002-10-06 22:57:51
|
Update of /cvsroot/mockobjects/nmock/test/NMock In directory usw-pr-cvs1:/tmp/cvs-serv30372/test/NMock Modified Files: MockTest.cs Log Message: Added Mock.SetValue() for setting up methods/properties that always return the same value and have no expectations about how they are called (i.e. getter methods). Index: MockTest.cs =================================================================== RCS file: /cvsroot/mockobjects/nmock/test/NMock/MockTest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- MockTest.cs 6 Oct 2002 20:49:09 -0000 1.1.1.1 +++ MockTest.cs 6 Oct 2002 22:57:48 -0000 1.2 @@ -195,6 +195,27 @@ } [Test] + public void FixedValue() + { + mock.SetValue("myMethod", "hello"); + mock.SetValue("anotherMethod", "world"); + Assertion.AssertEquals("hello", mock.Call("myMethod")); + Assertion.AssertEquals("hello", mock.Call("myMethod")); + Assertion.AssertEquals("hello", mock.Call("myMethod")); + Assertion.AssertEquals("hello", mock.Call("myMethod")); + Assertion.AssertEquals("world", mock.Call("anotherMethod")); + Assertion.AssertEquals("world", mock.Call("anotherMethod")); + mock.SetValue("myMethod", "bye"); + Assertion.AssertEquals("bye", mock.Call("myMethod")); + Assertion.AssertEquals("bye", mock.Call("myMethod")); + Assertion.AssertEquals("world", mock.Call("anotherMethod")); + mock.SetValue("myMethod", null); + Assertion.AssertNull(mock.Call("myMethod")); + Assertion.AssertNull(mock.Call("myMethod")); + mock.Verify(); + } + + [Test] [ExpectedException(typeof(System.IO.IOException))] public void CallThrowingException() { |