1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using ICSharpCode.SharpDevelop.Dom;
6
using ICSharpCode.SharpDevelop.Gui;
7
using ICSharpCode.SharpDevelop.Project;
9
namespace ICSharpCode.UnitTesting
12
/// Represents a class that has the [TestFixture] attribute
13
/// associated with it.
15
public class TestClassTreeNode : TestTreeNode
19
public TestClassTreeNode(TestProject project, TestClass testClass)
20
: base(project, testClass.Name)
22
this.testClass = testClass;
23
testClass.ResultChanged += TestClassResultChanged;
24
Nodes.Add(new ExtTreeNode());
25
UpdateImageListIndex(testClass.Result);
29
/// Gets the underlying IClass for this test class.
33
return testClass.Class;
37
public override void Dispose()
40
testClass.ResultChanged -= TestClassResultChanged;
41
testClass.TestMethods.TestMethodAdded -= TestMethodAdded;
42
testClass.TestMethods.TestMethodRemoved -= TestMethodRemoved;
47
protected override void Initialize()
51
foreach (TestMethod method in testClass.TestMethods) {
52
AddTestMethodTreeNode(method);
54
testClass.TestMethods.TestMethodAdded += TestMethodAdded;
55
testClass.TestMethods.TestMethodRemoved += TestMethodRemoved;
59
/// Adds a new TestMethodTreeNode to this node.
61
void AddTestMethodTreeNode(TestMethod method)
63
TestMethodTreeNode node = new TestMethodTreeNode(TestProject, method);
68
/// Updates the node's icon based on the test class test result.
70
void TestClassResultChanged(object source, EventArgs e)
72
UpdateImageListIndex(testClass.Result);
76
/// Adds a new test method tree node to this class node after a new
77
/// TestMethod has been added to the TestClass.
79
void TestMethodAdded(object source, TestMethodEventArgs e)
81
AddTestMethodTreeNode(e.TestMethod);
86
/// Removes the corresponding test method node after it has been
87
/// removed from the TestClass.
89
void TestMethodRemoved(object source, TestMethodEventArgs e)
91
foreach (TestMethodTreeNode methodNode in Nodes) {
92
if (methodNode.Text == e.TestMethod.Name) {
93
Nodes.Remove(methodNode);