Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does Rhino Mocks error on a stub, but not on the exact same thing as a mock?
    primarykey
    data
    text
    <p>I'm fairly new to rhino Mocks, just started using it this project. </p> <p>I am testing some code which calls an external method to get an IEnumerable of 'Project', which I've got an interface for it so that I can stub/mock it out. </p> <p>at the start of my unit test that tests some of the code that iterates over (or calls Count(), both cause the error) that IENumerable, I setup a stub implementation </p> <pre><code>IJobProcess stub = MockRepository.Stub&lt;IJobProcess&gt;(); SetupResult.For(stub.CheckTeamMeetingInLastMonth(null)).IgnoreArguments().Return(true); SetupResult.For(stub.GetOutstandingActions(null)).IgnoreArguments().Return( new List&lt;ProjectActionsDomain.DomainObjects.ProjectAction&gt;() ); </code></pre> <p>This however results in:</p> <pre><code>PmqccFormTests.GetFlagsReturnsIncompleteFlagWhenIncomplete : FailedSystem.InvalidOperationException : Previous method 'IEnumerator.MoveNext();' requires a return value or an exception to throw. at Rhino.Mocks.Impl.RecordMockState.AssertPreviousMethodIsClose() at Rhino.Mocks.Impl.RecordMockState.MethodCall(IInvocation invocation, MethodInfo method, Object[] args) at Rhino.Mocks.MockRepository.MethodCall(IInvocation invocation, Object proxy, MethodInfo method, Object[] args) at Rhino.Mocks.Impl.RhinoInterceptor.Intercept(IInvocation invocation) at Castle.DynamicProxy.AbstractInvocation.Proceed() at System.Linq.Enumerable.Count(IEnumerable`1 source) at PmqccDomain.DomainObjects.PmqccForm.GetFlags() in PmqccForm.cs: line 387 at PmqccUnitTests.PmqccFormTests.GetFlagsReturnsIncompleteFlagWhenIncomplete() in PmqccFormTests.cs: line 426 </code></pre> <p>However, if I change this to </p> <pre><code> IJobProcess mock = MockRepository.GenerateMock&lt;IJobProcess&gt;(); mock.Expect(x =&gt; x.GetOutstandingActions(null)).IgnoreArguments().Return( new List&lt;ProjectActionsDomain.DomainObjects.ProjectAction&gt;()); mock.Expect(x =&gt; x.CheckTeamMeetingInLastMonth(null)).IgnoreArguments().Return(true); </code></pre> <p>It does not error, I thought a stub was a mock that didn't assert on its results basically? or am I wrong there? What does Rhino Mocks do differently that avoids the error when using a mock?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload