Is there a way to unit test an async method?

Posted by Jiho Han on Stack Overflow See other posts from Stack Overflow or by Jiho Han
Published on 2009-07-23T21:49:03Z Indexed on 2010/04/19 15:33 UTC
Read the original article Hit count: 423

Filed under:
|
|
|

I am using Xunit and NMock on .NET platform. I am testing a presentation model where a method is asynchronous. The method creates an async task and executes it so the method returns immediately and the state I need to check aren't ready yet.

I can set a flag upon finish without modifying the SUT but that would mean I would have to keep checking the flag in a while loop for example, with perhaps timeout.

What are my options?

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about xunit.net