Monday, 16 April 2012

Testing the ViewOpener

I've added a new class and interface to the shell to allow modules to create views that cannot be reached from the menu. An example of this is the job details view which will be opened after adding a job and later on, from one of the job search screens.

I was running into a problem when testing this class that the tests needed to be run in an STA thread (Single Thread Apartment) as opposed to a MTA (Multi Threaded Apartment). This was because I needed to mock the views down to FrameworkElement level so I could access the DataContext property. As FrameworkElement requires to run in STA, I had to ensure that my tests run in STA. Here's an article I found on how this is down using NUnit 2.5 or higher.

http://madcoderspeak.blogspot.co.uk/2008/12/getting-nunit-to-go-all-sta.html

No comments:

Post a Comment