I'm writing an NUnit TextFixture for portions of a Windows Forms application. Some of the classes in the file are derived from UI component classes, like so:
[TestFixture]
public class MainFormTest : PersistenceTestBase // Base class here is not a form
{
class TestMainForm : MainForm // MainForm inherits from Form
{
public new String SomeMethod()
{
// Some MainForm private method overridden to expose it to my test fixture
}
}
private TestMainForm mainForm;
[TestFixtureSetUp]
public void TestFixtureSetUp()
{
mainForm = new TestMainForm();
}
[Test]
public void TestMainFormDoesXYZ()
{
// Perform unit testing...
}
}
However, an annoyance I have encountered is that since the classes inherit from UI component classes, Windows opens up the designer window when I double-click my unit test file in the Solution Explorer. Which, since it's not a "real" UI element (but a test class), it displays as a broken UI (depending on how I arrange the file, messages like "The designer could not be shown for this file because none of the classes within it can be designed" are shown). Is there a way to supress this behavior, or will I always have to right-click this file and "View Code"?