What you need in order to get this to work is a "partial mock". Rhino Mocks can only stub virtual methods when performing partial mocks. If you mark TestFunction1
as virtual
it should work.
Also you should use Assert.AreEqual
, since it checks for value equality ("are the objects equivalent?"). Assert.AreSame
checks for reference equality ("are they the same object?"). See this answer for further explanation.
Regarding partial mocks in general, they should be avoided. Having to perform partial mocks is often an indication that the class is trying to do too much. Either test the function as part of a unit test of the class, or extract it to a separate collaborating class.