Ugly integration test - what can I do better?
This test was driving me somewhat crazy…
I want to test that a certain activity is performed on a designated thread, even if the execution of the activity happens from a different thread. This kind of functionality is needed for frontends in Windows Forms or WPF since modifications to the UI can only happen on the same thread under which all UI activities happen.
When I tried running the things that are now running in their own thread in the test itself, a deadlock would occur since the call to Publish blocks, such that that the test’s thread cannot be used for performing any work, which is attempted in lines 19,20.
The test works, and it proves that the subscription code runs on the UI thread, but damn, is it ugly!