Andyk
unread,Nov 12, 2008, 7:28:16 AM11/12/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ALTNET
Hi all,
Can anyone help me with this? Im trying to figure out if I can mock a
concrete implementation? Or do I always have to mock against
interfaces.
I have a DataType which contains a Property to do some calculation.
This is based on a value return from a property from the
ParentCollection.
Im trying to unit test the DataType calculation, and wanting to mock
the ParentCollection property.
But it seemingly wont let me, unless I introduce an interface first.
Im trying to unit test legacy code, so breaking everything up and
introducing interfaces for all the datatypes is going to be alot of
work.
If I try to do something like:
ClientCollection mockCollection = mockery.StrictMock<ClientCollection>
();
When I call:
Expect.Call(mockCollection.TotalShares).return(100);
I get the following error:
Test method RhinoTestProject.ClientTest.ShouldTestMarketShares threw
exception: System.InvalidOperationException: Invalid call, the last
call has been used or no call has been made (make sure that you are
calling a virtual (C#) / Overridable (VB) method)..
And when I actually step through the test, its trying to call the
actual implementation rather than just return my mock value.
So is what Im trying to do possible?
Kinds regards
Andy