//public void Add( SetUpFixture fixture ) //{ // string ns = fixture.FullName; // int index = ns.LastIndexOf( '.' ); // ns = index > 0 ? ns.Substring( 0, index ) : string.Empty; // TestSuite suite = BuildFromNameSpace( ns ); // // Make the parent point to this instead // // TODO: Get rid of this somehow? // TestSuite parent = suite.Parent; // if ( parent != null ) // { // parent.Tests.Remove( suite ); // parent.Add( fixture ); // } // // Add the old suite's children // foreach( TestSuite child in suite.Tests ) // fixture.Add( child ); // if (parent == null && fixture is SetUpFixture) // { // suite.Tests.Clear(); // suite.Add(fixture); // } // // Update the hashtable // namespaceSuites[ns] = fixture; //} #endregion #region Helper Method private TestSuite BuildFromNameSpace(string nameSpace) { if (nameSpace == null || nameSpace == "") { return(rootSuite); } TestSuite suite = (TestSuite)namespaceSuites[nameSpace]; if (suite != null) { return(suite); } int index = nameSpace.LastIndexOf("."); //string prefix = string.Format( "[{0}]" ); if (index == -1) { suite = new NamespaceSuite(nameSpace); if (rootSuite == null) { rootSuite = suite; } else { rootSuite.Add(suite); } namespaceSuites[nameSpace] = suite; } else { string parentNameSpace = nameSpace.Substring(0, index); TestSuite parent = BuildFromNameSpace(parentNameSpace); string suiteName = nameSpace.Substring(index + 1); suite = new NamespaceSuite(parentNameSpace, suiteName); parent.Add(suite); namespaceSuites[nameSpace] = suite; } return(suite); }
private TestSuite BuildFromNameSpace( string nameSpace, int assemblyKey ) { if( nameSpace == null || nameSpace == "" ) return rootSuite; TestSuite suite = (TestSuite)namespaceSuites[nameSpace]; if(suite!=null) return suite; int index = nameSpace.LastIndexOf("."); string prefix = string.Format( "[{0}]", assemblyKey ); if( index == -1 ) { suite = new NamespaceSuite( nameSpace, assemblyKey ); if ( rootSuite == null ) rootSuite = suite; else rootSuite.Add(suite); namespaceSuites[nameSpace]=suite; } else { string parentNameSpace = nameSpace.Substring( 0,index ); TestSuite parent = BuildFromNameSpace( parentNameSpace, assemblyKey ); string suiteName = nameSpace.Substring( index+1 ); suite = new NamespaceSuite( parentNameSpace, suiteName, assemblyKey ); parent.Add( suite ); namespaceSuites[nameSpace] = suite; } return suite; }