UPDATE:
I already decided to use StatLight for my continuous integration server, but I was looking for a solution to run Silverlight asynchronous unit tests directly in VS2010 during development.
Inspired by Rob Fonseca-Ensor's suggestion to use Rx (see his separate answer on this page), I looked again at this issue. This led me to find a non-Rx solution to the problem of using AgUnit to run Silverlight asynchronous tests.
I think the solution that I will use, at least for now, is a combination:
- Silverlight Unit Test Framework
- ReSharper 5.1
- AgUnit ReSharper Plugin
- [Mock async pattern]
My ViewModels provides special service classes that provide abstractions of my (auto-generated) WCF service reference classes. To provide access to WCF service methods, my specialized service classes also rely on another common class that wraps the asynchronization pattern. For my unit tests, I already ridiculed my WCF service reference classes and my specialized service classes with Moq - but I did not look at the mockery of my asynchronous template shell class.
So, I decided to mock my asynchronous template wrapper class. The appeal of this was that I thought I could use Rx with a mock IScheduler (as Rob said in his answer) in all my bullying, leaving my real classes without any reference to Rx (which is a requirement because for this project in the place where I work, I need to leave Rx outside of any code that will be deployed in the production environment). However, as soon as I made fun of the wrapper class, I realized that I didn’t even need Rx, and that there was an even simpler solution that I had to really look at earlier. This is pretty trivial — all I really needed to do was make fun of the wrapper class and make sure it called Invoke for callback operations, rather than calling BeginInvoke. This ultimately prevents callbacks that work fine while working in the Silverlight Unit Test Framework in a browser session, from going into a black hole when unit tests run AgUnit in VS2010. (Allowing black hole callbacks when using AgUnit would of course prevent individual checks from being performed properly and could lead to timeouts or, even worse, false positives in the test results.)
In the absence of a better answer to any subsequent answers to this question, it seems to me that this is the easiest way to handle this scenario - letting my asynchronous unit tests run in AgUnit without requiring Rx in my production code.
For those who do not have restrictions on the implementation of code that uses Rx (which is still a DevLabs project) for production, I think Rob's solution is definitely worth a look.
Derek Novavi
source share