This test fails when it is run with the NUnit console runner. It works if I run just that test with TestDriven.NET, but not if I run the entire suite with TestDriven.NET:
[Test]
public void BackgroundWorkerFiresRunWorkerCompleted()
{
var runner = new BackgroundWorker();
ManualResetEvent done = new ManualResetEvent(false);
runner.RunWorkerCompleted += delegate { done.Set(); };
runner.RunWorkerAsync();
bool res = done.WaitOne(TimeSpan.FromSeconds(10));
// This assert fails:
Assert.IsTrue(res, "RunWorkerCompleted was not executed within 10 seconds");
}
I suspect the problem have something to do with not having a message-loop, but I am not sure.
What are the requirements for using BackgroundWorker?
Is there a workaround to make the test work?