Started using Rhino.Mocks recently (Awesome!!!) - just wanted to list a few of the basics; the official Rhino Mocks Documentation is very good and available
here. These examples are a bit rough, they have not been compiled; there may be typos.
using
using Rhino.Mocks;
The mock repository
Mock a call to the db
Ignore any arguments
mock a method that returns void
Handle multiple calls to the same method
Partial Mock
5 comments:
Hi,
Does you first example (The mock repository) work with v.3.5?
I get the error:
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).
I have not tried it on 3.5 of .net but I believe it should work. Is it possible you are making multiple calls to the same mocked method? you might need a .Repeat.Any();
In 3.5 CreateMock is deprecated and should be changed to StrictMock. Might want to try that,
IProduct product = new Product("003092", "Sierra Nevada", 6.49);
Lär ju gå bra att instansiera ett interface, nötter...
Had an issue with comment moderation
-------------------------------------
New Day posted this about a month ago
For the Equals method I get the same error as ben.biddington. I am using .NET 2.0
The error occurs on the line with Expect.Call so it does not proceed any further down the test.
Error
"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)."
Post a Comment