PageRenderTime 47ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/src/NUnit/interfaces/TestNode.cs

#
C# | 88 lines | 43 code | 7 blank | 38 comment | 1 complexity | 29b4a3d4bd69e8a438ddf0022da56f83 MD5 | raw file
Possible License(s): GPL-2.0
  1. // ****************************************************************
  2. // Copyright 2007, Charlie Poole
  3. // This is free software licensed under the NUnit license. You may
  4. // obtain a copy of the license at http://nunit.org
  5. // ****************************************************************
  6. using System;
  7. using System.Collections;
  8. namespace NUnit.Core
  9. {
  10. /// <summary>
  11. /// TestNode represents a single test or suite in the test hierarchy.
  12. /// TestNode holds common info needed about a test and represents a
  13. /// single node - either a test or a suite - in the hierarchy of tests.
  14. ///
  15. /// TestNode extends TestInfo, which holds all the information with
  16. /// the exception of the list of child classes. When constructed from
  17. /// a Test, TestNodes are always fully populated with child TestNodes.
  18. ///
  19. /// Like TestInfo, TestNode is purely a data class, and is not able
  20. /// to execute tests.
  21. ///
  22. /// </summary>
  23. [Serializable]
  24. public class TestNode : TestInfo
  25. {
  26. #region Instance Variables
  27. private ITest parent;
  28. /// <summary>
  29. /// For a test suite, the child tests or suites
  30. /// Null if this is not a test suite
  31. /// </summary>
  32. private ArrayList tests;
  33. #endregion
  34. #region Constructors
  35. /// <summary>
  36. /// Construct from an ITest
  37. /// </summary>
  38. /// <param name="test">Test from which a TestNode is to be constructed</param>
  39. public TestNode ( ITest test ) : base( test )
  40. {
  41. if ( test.IsSuite )
  42. {
  43. this.tests = new ArrayList();
  44. foreach( ITest child in test.Tests )
  45. {
  46. TestNode node = new TestNode( child );
  47. this.Tests.Add( node );
  48. node.parent = this;
  49. }
  50. }
  51. }
  52. /// <summary>
  53. /// Construct a TestNode given a TestName and an
  54. /// array of child tests.
  55. /// </summary>
  56. /// <param name="testName">The TestName of the new test</param>
  57. /// <param name="tests">An array of tests to be added as children of the new test</param>
  58. public TestNode ( TestName testName, ITest[] tests ) : base( testName, tests )
  59. {
  60. this.tests = new ArrayList();
  61. this.tests.AddRange( tests );
  62. }
  63. #endregion
  64. #region Properties
  65. /// <summary>
  66. /// Gets the parent test of the current test
  67. /// </summary>
  68. public override ITest Parent
  69. {
  70. get { return parent; }
  71. }
  72. /// <summary>
  73. /// Array of child tests, null if this is a test case.
  74. /// </summary>
  75. public override IList Tests
  76. {
  77. get { return tests; }
  78. }
  79. #endregion
  80. }
  81. }