本文整理汇总了C#中TestSuite.Add方法的典型用法代码示例。如果您正苦于以下问题:C# TestSuite.Add方法的具体用法?C# TestSuite.Add怎么用?C# TestSuite.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestSuite
的用法示例。
在下文中一共展示了TestSuite.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildMultipleFixtures
private Test BuildMultipleFixtures(Type type, Attribute[] attrs)
{
TestSuite suite = new TestSuite(type.Namespace, TypeHelper.GetDisplayName(type));
foreach (Attribute attr in attrs)
suite.Add(BuildSingleFixture(type, attr));
return suite;
}
示例2: GetTests
public override ITestSuite GetTests()
{
TestSuite suite = new TestSuite(this.Name);
int index = 0;
foreach(Delegate del in Test.GetInvocationList())
{
string name = String.Format("Test{0}", index).TrimEnd('0');
ITestCase tc = CreateTestCase(del, name);
suite.Add(tc);
index++;
}
return suite;
}
示例3: AddSetUpFixture
private void AddSetUpFixture(TestSuite newSetupFixture, TestSuite containingSuite, string ns)
{
// The SetUpFixture must replace the namespace suite
// in which it is "contained".
//
// First, add the old suite's children
foreach (TestSuite child in containingSuite.Tests)
newSetupFixture.Add(child);
if (containingSuite is SetUpFixture)
{
// The parent suite is also a SetupFixture. The new
// SetupFixture is nested below the parent SetupFixture.
// TODO: Avoid nesting of SetupFixtures somehow?
//
// Note: The tests have already been copied to the new
// SetupFixture. Thus the tests collection of
// the parent SetupFixture can be cleared.
containingSuite.Tests.Clear();
containingSuite.Add(newSetupFixture);
}
else
{
// Make the parent of the containing suite point to this
// fixture instead
// TODO: Get rid of this somehow?
TestSuite parent = (TestSuite)containingSuite.Parent;
if (parent == null)
{
newSetupFixture.Name = rootSuite.Name;
rootSuite = newSetupFixture;
}
else
{
parent.Tests.Remove(containingSuite);
parent.Add(newSetupFixture);
}
}
// Update the dictionary
namespaceSuites[ns] = newSetupFixture;
}
示例4: BuildTestAssembly
private TestSuite BuildTestAssembly( string assemblyName, IList fixtures, bool autoSuites )
{
TestSuite testAssembly = new TestSuite( assemblyName );
if ( autoSuites )
{
NamespaceTreeBuilder treeBuilder =
new NamespaceTreeBuilder( testAssembly );
treeBuilder.Add( fixtures );
testAssembly = treeBuilder.RootSuite;
}
else
foreach( TestSuite fixture in fixtures )
{
if ( fixture is SetUpFixture )
{
fixture.RunState = RunState.NotRunnable;
fixture.IgnoreReason = "SetUpFixture cannot be used when loading tests as a flat list of fixtures";
}
testAssembly.Add( fixture );
}
if ( fixtures.Count == 0 )
{
testAssembly.RunState = RunState.NotRunnable;
testAssembly.IgnoreReason = "Has no TestFixtures";
}
NUnitFramework.ApplyCommonAttributes( assembly, testAssembly );
// TODO: Make this an option? Add Option to sort assemblies as well?
testAssembly.Sort();
return testAssembly;
}
示例5: Add
/// <summary>
/// Adds the specified fixture to the tree.
/// </summary>
/// <param name="fixture">The fixture to be added.</param>
public void Add( TestSuite fixture )
{
string ns = fixture.FullName;
int index = ns.IndexOf("[");
if (index >= 0) ns = ns.Substring(0, index);
index = ns.LastIndexOf( '.' );
ns = index > 0 ? ns.Substring( 0, index ) : string.Empty;
TestSuite containingSuite = BuildFromNameSpace( ns );
if (fixture is SetUpFixture)
{
// The SetUpFixture must replace the namespace suite
// in which it is "contained".
//
// First, add the old suite's children
foreach (TestSuite child in containingSuite.Tests)
fixture.Add(child);
// Make the parent of the containing suite point to this
// fixture instead
// TODO: Get rid of this somehow?
TestSuite parent = (TestSuite)containingSuite.Parent;
if (parent == null)
{
fixture.Name = rootSuite.Name;
rootSuite = fixture;
}
else
{
parent.Tests.Remove(containingSuite);
parent.Add(fixture);
}
// Update the dictionary
namespaceSuites[ns] = fixture;
}
else
containingSuite.Add( fixture );
}