What is the best way/practice/pattern of writing unit tests when the async factories are used? E.g. lets say I have a test for my Customer object and for simplicity sake I want to assert that:
GetCustomer(int id, EventHandler<DataPortalResult<Customer>> handler)
returns a customer with name "X". How do I make sure my test waits for the factory method to complete before asserting and of course exiting the test?
Have you looked at the Silverlight Unit Testing framework?
If you go here:
http://feeds.timheuer.com/timheuer/pdc/silverlight/wmv
Session CL32
CL32 - Developing Testable Silverlight Applications (Keith Jones)
This one talked a little bit about how actions are "queued" up to where certain asynch operations / etc can have a condition that is waited on. I confess I haven't used the unit test framework, but I thought I'd mention it.
You might also check this thread:
http://forums.lhotka.net/forums/t/8620.aspx
The main thrust is that Rocky/Magenic ended up solving this problem by creating UnitDriven, their own testing framework. It might prove useful for what you're doing.
HTH
- Scott
Thanks to both, I will check the links and get back to mark an answer.
One thing I did forget to mention is that I am not actually doing any SL development aty the moment so not using CSLA Light . I have a WPF client and am using standard CSLA.
UnitDriven works in nunit and mstest as well.
That was half the point actually. We needed three things:
UnitDriven on the SL side is a complete (if relatively simple) unit test framework that meets those needs.
UnitDriven on the .NET side is an "add-in" to nunit or mstest that enables async tests to be written in exactly the same way we write them on the SL side - so the same tests can be used for both platforms.
Thanks for the clarification. I didn't even look at UnitDriven because I thought it was only addressing SL issues around unit testing but all is clear now.
Thanks!
Copyright (c) Marimer LLC