locked
dealing with background threads in unit testing RRS feed

  • Question

  • Hi,

       I need to unit test a method that request some method on background thread.Can  shim help us in this regards

     

    Thursday, September 27, 2012 7:54 AM

All replies

  • Hi Vivek,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, September 28, 2012 12:10 AM
  • It is not advisable to use a shim for that purpose. Shims run slower and rewrite code during runtime which can cause problems.


    Trevor Hancock (Microsoft)
    Please remember to "Mark As Answer" the replies that help.

    Monday, October 1, 2012 7:29 PM
  • Thanks to Allen Mathias in this other thread I've found that tests implemented in Visual Studio 2012 can create background threads using Task.Run along with the async keyword and the await operator as described in Writing async methods for test execution.

    There may be limitations or restrictions that my limited testing has not revealed but the basics seem to work.  But of course you need to be able to use Visual Studio 2012 and the 4.5 .NET Framework.



    Sunday, October 7, 2012 5:28 AM