Unit Testing the Metric Dashboard – Part 3
Continuation of unit testing the Metric Dashboard.
Watching for new files
The Dashboard listens to the test result folder for new files. As this is done in another thread, the test must wait for the file to be read and processed in order to verify that the feature works. In the older versions of Typemock there was a VerifyWithTimeout api. Here is a hack to do the same with the lambda API’s. This test is actually an interesting test
- I delete the file before copying just to be sure.
- Here I am faking the current date to be the same as the date of the test – this is so that I get the correct value from CurrentProtection
- Hack to Wait for Load() to be called. In this hack I set an event once the method has been called and then I call the real Load() method.
- Copy file to watched location
- Wait for Load to be called
- Here a short wait is needed for the method to complete.
2 Comments to “Unit Testing the Metric Dashboard – Part 3”
Recent Posts
- Top 5 questions to ask when checking references
- Unacceptable: Unit testing will take 20 years to catch on
- The 4 reasons why we DIDN’T choose Oslo
- Typemock Academy Launch
- The First Rule to Software Craftsmanship
Categories
- .NET Tests
- Agile
- Code Integrity
- Community
- Debugging
- Fun
- Management for Geeks
- Marketing
- Product
- Release
- Reviews
- SharePoint
- TDD
- Time Management
- Uncategorized
- Unit Tests
Archives
- August 2010
- May 2010
- April 2010
- March 2010
- February 2010
- December 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- December 2008
- November 2008
- August 2008
- July 2008
- May 2008
- April 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006


Wouldn’t it be easier to switch the lines inside the “WhenCalled” expression, so the even gets set after the Load performs? You won’t need the Sleep(100) at the end. Or am I missing something?
Yup, that would be a good way.
It just seems a bit brittle.
I would prefer to do something like:
Wait for delegate that is run on another thread to complete.