RhinoMocks uses subclassing and thus can only intercept virtual
methods; so you need a virtual (or interface) method in order to set
up an expectation. In your example, InsertProfile is not virtual,
which is why its actual implementation is executed instead of an
expectation being created.
Regards,
Fabian
I think that not Rhino.Mocks put that restriction, but the
Castel.DynamicProxy library and their mechanism on how to intercept method
calls. Afaik, it's generally only possible to incept virtual or interface
method calls apart from how Castle DynamicProxy (and so Rhino.Mocks) is
handling this.. right?
Greetings,
Stefan
--
ifu Hamburg - material flows and software
ifu Institut fuer Umweltinformatik Hamburg GmbH
Grosse Bergstrasse 219, 22767 Hamburg, Germany
Managing Director: Jan Hedemann, Commercial Register: Hamburg, HRB 52629
www.ifu.com - www.umberto.de - www.sabento.com - www.e-sankey.com
>>> e!Sankey - Our new software for the easy drawing of Sankey diagrams.
>>> Visit http://www.e-sankey.com
With .NET, there are a few kinds of interception available:
- Remoting proxies
- (Runtime) subclassing
- Static IL or source code rewriting on disk/compiler support
- Profiling API
Each of those has their own set of restrictions, there is no solution
that always works without any constraints or inconveniences. Ayende
probably chose runtime subclassing (via DynamicProxy) very
deliberately. In practice, the virtualness/interface restrictions are
usually not that problematic - in fact, there are quite a few people
advocating that design that can't be mocked that way isn't actually
good design :)
Fabian