Is it possible to throw an exception if trying to call
Expect.Call(...).. on a non-virtual method?
Invalid call, the last call has been used or no call has been made.
System.InvalidOperationException: Invalid call, the last call has been
used or no call has been made.
at Rhino.Mocks.LastCall.get_Options()
at Rhino.Mocks.Expect.Call(Object ignored)...
I don't think this is very descriptive of the fact the the method was
not marked virtual. Is it possible to return a better exception
message in this case?
the documentation page you were looking for is here:
http://www.ayende.com/Wiki/(S(eqbbidusglkuv145m4s4fq3j))/Rhino+Mocks+Limitations.ashx
I will try to explain the problem to you.
As far as I understand it, what you want is not possible because Rhino
Mocks cannot distinguish between calling a non-virtual method and
calling nothing at all.
Let's say you have the following class:
class BaseClass
{
public virtual int Method() { return 0; }
}
When you mock this class, RhinoMocks actually implements a class that
is derived from BaseClass and overrides all virtual methods with its
own implementation which essentially notifies the mocking repository
about the call and you can access this call for example by writing
LastCall.Return(1).
So, if Method() was non-virtual, RhinoMocks would not be able to
override this method with it's own implementation and thus the mocking
repository would not be notified about a call to Method().
Did that answer your question?
> > > Expect.Call(...).. on a non-virtual method?- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
Brian.
Invalid call, the last call has been used or no call has been made.
System.InvalidOperationException: Invalid call, the last call has
been
used or no call has been made. (Did you call a non-virtual method?)
Shane
On Jun 6, 9:24 pm, "Brian Chan" <bch...@gmail.com> wrote:
> Thanks for the explanation. It makes it clearer now.
>
> Brian.
>
> On 6/6/07, Stefan Podskubka <s.podsku...@hcs.at> wrote:
>
>
>
>
>
> > Brian,
>
> > the documentation page you were looking for is here:
> >http://www.ayende.com/Wiki/(S(eqbbidusglkuv145m4s4fq3j))/Rhino+Mocks+...
> > > - Zitierten Text anzeigen -- Hide quoted text -
>
> - Show quoted text -