Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Not sure if I understand the problem.</p> <p>Your code is just calling a method on the mock (<code>WinWaitActive</code>). Of course, it can't proceed before the call returns. This is in the nature of the programming language and nothing you need to test.</p> <p>So if you test that <code>WinWaitActive</code> gets called, your test is done. You could test if <code>WinWaitActive</code> gets called before anything else, but this requires ordered expectations, which requires the old style rhino mocks syntax and is usually not worth to do.</p> <pre><code> mockAutoItLibrary = MockRepository.GenerateStub&lt;IAutoItX3&gt;(); subject = new Subject(mockAutoItLibrary) subject.Run() mockAutoItLib.AssertWasCalled(m =&gt; m.WinWaitActive("Open File", "", 0)); </code></pre> <p>You don't do anything else then calling a method ... so there isn't anything else to test.</p> <p><strong>Edit:</strong> exit the infinite loop</p> <p>You could make it exit the infinite loop by throwing an exception from the mocks. This is not very nice, but it avoids having all this multi-threading stuff in the unit test.</p> <pre><code> mockAutoItLibrary = MockRepository.GenerateStub&lt;IAutoItX3&gt;(); // make loop throw an exception on second call // to exit the infinite loop mockAutoItLib .Stub(m =&gt; m.WinWaitActive( Arg&lt;string&gt;.Is.Anything, Arg&lt;string&gt;.Is.Anything, Arg&lt;int&gt;.Is.Anything)); .Repeat.Once(); mockAutoItLib .Stub(m =&gt; m.WinWaitActive( Arg&lt;string&gt;.Is.Anything, Arg&lt;string&gt;.Is.Anything, Arg&lt;int&gt;.Is.Anything)); .Throw(new StopInfiniteLoopException()); subject = new Subject(mockAutoItLibrary) try { subject.Run() } catch(StopInfiniteLoopException) {} // expected exception thrown by mock mockAutoItLib.AssertWasCalled(m =&gt; m.WinWaitActive("Open File", "", 0)); </code></pre>
 

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