1 // ****************************************************************
\r
2 // Copyright 2007, Charlie Poole
\r
3 // This is free software licensed under the NUnit license. You may
\r
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4
\r
5 // ****************************************************************
\r
7 using System.Collections;
\r
12 /// TestNode represents a single test or suite in the test hierarchy.
\r
13 /// TestNode holds common info needed about a test and represents a
\r
14 /// single node - either a test or a suite - in the hierarchy of tests.
\r
16 /// TestNode extends TestInfo, which holds all the information with
\r
17 /// the exception of the list of child classes. When constructed from
\r
18 /// a Test, TestNodes are always fully populated with child TestNodes.
\r
20 /// Like TestInfo, TestNode is purely a data class, and is not able
\r
21 /// to execute tests.
\r
25 public class TestNode : TestInfo
\r
27 #region Instance Variables
\r
28 private ITest parent;
\r
31 /// For a test suite, the child tests or suites
\r
32 /// Null if this is not a test suite
\r
34 private ArrayList tests;
\r
37 #region Constructors
\r
39 /// Construct from an ITest
\r
41 /// <param name="test">Test from which a TestNode is to be constructed</param>
\r
42 public TestNode ( ITest test ) : base( test )
\r
46 this.tests = new ArrayList();
\r
48 foreach( ITest child in test.Tests )
\r
50 TestNode node = new TestNode( child );
\r
51 this.Tests.Add( node );
\r
58 /// Construct a TestNode given a TestName and an
\r
59 /// array of child tests.
\r
61 /// <param name="testName">The TestName of the new test</param>
\r
62 /// <param name="tests">An array of tests to be added as children of the new test</param>
\r
63 public TestNode ( TestName testName, ITest[] tests ) : base( testName, tests )
\r
65 this.tests = new ArrayList();
\r
66 this.tests.AddRange( tests );
\r
72 /// Gets the parent test of the current test
\r
74 public override ITest Parent
\r
76 get { return parent; }
\r
80 /// Array of child tests, null if this is a test case.
\r
82 public override IList Tests
\r
84 get { return tests; }
\r