给你个Demo(Nunit),特殊界面测试一下,不需要每个都测试.
Code
[SetUp]
public void ShowForm()
{
form = new Form();
list = new ListControl();
list.Visible = true;
list.Dock = DockStyle.Fill;
form.Controls.Add(list);
form.Show();
}
[TearDown]
public void CloseForm()
{
form.Close();
form = null;
}
[Test]
public void AddFilters()
{
IListFilters filters = list;
filters.Add("Bar1", new Filter("Bar1_F1", "Bar1 = true", "Bar1"));
filters.Add("Bar1", new Filter("Bar1_F1", "Bar1 = false", "Bar1"));
Assert.AreEqual(1, list.UT_ToolStripPanel.Controls.Count);
ToolStrip strip = (ToolStrip)list.UT_ToolStripPanel.Controls[0];
Assert.AreEqual(2, strip.Items.Count);
Assert.AreEqual(strip.Items[0].GetType(), typeof(ToolStripLabel));
Assert.AreEqual(strip.Items[1].GetType(), typeof(ToolStripComboBox));
}