Displaying Windows Forms inside unit test methods
<p>I just discovered unit test projects in Visual Studio .NET and am using test methods to set up examples of global code I have developed.</p>

<p>Some global methods involve displaying reusable dialogs like a date-picker and input box. Trouble is, sometimes forms will display and sometimes they won't.</p>

<p>I thought it was related to modality, because I have a report preview form that can be shown modally or non-modally. When I show that non-modally, it does not display. When I show it modally, it does.</p>

<p>Trying my input box never works:</p>

<pre><code>string input = "";
using (InputBox box = new InputBox(Title, Prompt, Default))
{
    DialogResult result = box.ShowDialog();
    input = box.txtInput.Text.Trim();
}
return input;
</code></pre>

<p>Execution stops at the "box.ShowDialog()" line, and at that point I can inspect box and see that its dimensions, location, and visibility are all properly configured -- yet I cannot see the form. I've got to cancel the test to stop everything.</p>

<p>I'd love to use a unit testing project to act as a playground and showcase of existing code, but it seems very limited if I can't display certain forms. I realize this is not really what unit testing is meant for, but I hoped I could build a fun little sandbox this way to help get my developers up to speed.</p>