I use RhinoMocks for a very simple test (I have to say I'm a beginner here). I tried to mock my object like this
var mock = MockRepository.GenerateMock<MyClass>();
create a stub helper:
var stubLinkedObject = MockRepository.GenerateStub<MyClass>();
then follow some logic that should call the AddLinkclass method MyClasswith my stub argument. At the end of the test, I simply state that this method was actually called using
mockAction.AssertWasCalled(a => a.AddLink(stubLinkedObject));
I entered the correct dependency and the method is actually called. However, the problem is that the real's implementation is MyClasscalled and crashes because some logic simply cannot be executed (the collection of links is not available, etc.). How can I get around the execution and just check if the method is called? I tried something like
mockAction.Stub(a => a.AddLink(null)).IgnoreArguments().Do(null);
before I go into execution, but that doesn't seem to work (I only get exceptions). Any ideas and probably an explanation why the layout follows the logic of the method in general?
source
share