Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
// ****************************************************************
// Copyright 2007, Charlie Poole
// This is free software licensed under the NUnit license. You may
// obtain a copy of the license at http://nunit.org/?p=license&r=2.4
// ****************************************************************
using System;
using System.Collections;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// EventListenerCollection holds multiple event listeners
/// and relays all event calls to each of them.
/// </summary>
public class EventListenerCollection : ExtensionPoint, EventListener
{
#region Constructor
public EventListenerCollection( IExtensionHost host )
: base( "EventListeners", host ) { }
#endregion
#region EventListener Members
public void RunStarted(string name, int testCount)
{
foreach( EventListener listener in extensions )
listener.RunStarted( name, testCount );
}
public void RunFinished(TestResult result)
{
foreach( EventListener listener in extensions )
listener.RunFinished( result );
}
public void RunFinished(Exception exception)
{
foreach( EventListener listener in extensions )
listener.RunFinished( exception );
}
public void SuiteStarted(TestName testName)
{
foreach( EventListener listener in extensions )
listener.SuiteStarted( testName );
}
public void SuiteFinished(TestSuiteResult result)
{
foreach( EventListener listener in extensions )
listener.SuiteFinished( result );
}
public void TestStarted(TestName testName)
{
foreach( EventListener listener in extensions )
listener.TestStarted( testName );
}
public void TestFinished(TestCaseResult result)
{
foreach( EventListener listener in extensions )
listener.TestFinished( result );
}
public void UnhandledException(Exception exception)
{
foreach( EventListener listener in extensions )
listener.UnhandledException( exception );
}
public void TestOutput(TestOutput testOutput)
{
foreach( EventListener listener in extensions )
listener.TestOutput( testOutput );
}
#endregion
#region ExtensionPoint Overrides
protected override bool ValidExtension(object extension)
{
return extension is EventListener;
}
#endregion
}
}

View File

@@ -0,0 +1,60 @@
// ****************************************************************
// Copyright 2007, Charlie Poole
// This is free software licensed under the NUnit license. You may
// obtain a copy of the license at http://nunit.org/?p=license&r=2.4
// ****************************************************************
using System;
using System.Reflection;
using System.Collections;
namespace NUnit.Core.Extensibility
{
public class FrameworkRegistry : IFrameworkRegistry
{
#region Instance Fields
/// <summary>
/// List of FrameworkInfo structs for supported frameworks
/// </summary>
private Hashtable testFrameworks = new Hashtable();
#endregion
#region IFrameworkRegistry Members
/// <summary>
/// Register a framework. NUnit registers itself using this method. Add-ins that
/// work with or emulate a different framework may register themselves as well.
/// </summary>
/// <param name="frameworkName">The name of the framework</param>
/// <param name="assemblyName">The name of the assembly that framework users reference</param>
public void Register(string frameworkName, string assemblyName)
{
testFrameworks[frameworkName] = new TestFramework(frameworkName, assemblyName);
}
#endregion
#region Other Methods
/// <summary>
/// Get a list of known frameworks referenced by an assembly
/// </summary>
/// <param name="assembly">The assembly to be examined</param>
/// <returns>A list of AssemblyNames</returns>
public IList GetReferencedFrameworks(Assembly assembly)
{
ArrayList referencedAssemblies = new ArrayList();
foreach (AssemblyName assemblyRef in assembly.GetReferencedAssemblies())
{
foreach (TestFramework info in testFrameworks.Values)
{
if (assemblyRef.Name == info.AssemblyName)
{
referencedAssemblies.Add(assemblyRef);
break;
}
}
}
return referencedAssemblies;
}
#endregion
}
}

View File

@@ -0,0 +1,68 @@
// ****************************************************************
// This is free software licensed under the NUnit license. You
// may obtain a copy of the license as well as information regarding
// copyright ownership at http://nunit.org/?p=license&r=2.4.
// ****************************************************************
using System;
using System.Collections;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// SuiteBuilderCollection is an ExtensionPoint for SuiteBuilders and
/// implements the ISuiteBuilder interface itself, passing calls
/// on to the individual builders.
///
/// The builders are added to the collection by inserting them at
/// the start, as to take precedence over those added earlier.
/// </summary>
public class SuiteBuilderCollection : ExtensionPoint, ISuiteBuilder
{
#region Constructor
/// <summary>
/// Default constructor
/// </summary>
public SuiteBuilderCollection(IExtensionHost host)
: base("SuiteBuilders", host ) { }
#endregion
#region ISuiteBuilder Members
/// <summary>
/// Examine the type and determine if it is suitable for
/// any SuiteBuilder to use in building a TestSuite
/// </summary>
/// <param name="type">The type of the fixture to be used</param>
/// <returns>True if the type can be used to build a TestSuite</returns>
public bool CanBuildFrom(Type type)
{
foreach( ISuiteBuilder builder in extensions )
if ( builder.CanBuildFrom( type ) )
return true;
return false;
}
/// <summary>
/// Build a TestSuite from type provided.
/// </summary>
/// <param name="type">The type of the fixture to be used</param>
/// <returns>A TestSuite or null</returns>
public Test BuildFrom(Type type)
{
foreach( ISuiteBuilder builder in extensions )
if ( builder.CanBuildFrom( type ) )
return builder.BuildFrom( type );
return null;
}
#endregion
#region ExtensionPoint Overrides
protected override bool ValidExtension(object extension)
{
return extension is ISuiteBuilder;
}
#endregion
}
}

View File

@@ -0,0 +1,67 @@
// ****************************************************************
// Copyright 2007, Charlie Poole
// This is free software licensed under the NUnit license. You may
// obtain a copy of the license at http://nunit.org/?p=license&r=2.4
// ****************************************************************
using System;
using System.Collections;
using System.Reflection;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// TestCaseBuilderCollection is an ExtensionPoint for TestCaseBuilders
/// and implements the ITestCaseBuilder interface itself, passing calls
/// on to the individual builders.
///
/// The builders are added to the collection by inserting them at
/// the start, as to take precedence over those added earlier.
/// </summary>
public class TestCaseBuilderCollection : ExtensionPoint, ITestCaseBuilder
{
#region Constructor
public TestCaseBuilderCollection(IExtensionHost host)
: base("TestCaseBuilders", host) { }
#endregion
#region ITestCaseBuilder Members
/// <summary>
/// Examine the method and determine if it is suitable for
/// any TestCaseBuilder to use in building a TestCase
/// </summary>
/// <param name="method">The method to be used as a test case</param>
/// <returns>True if the type can be used to build a TestCase</returns>
public bool CanBuildFrom( MethodInfo method )
{
foreach( ITestCaseBuilder builder in extensions )
if ( builder.CanBuildFrom( method ) )
return true;
return false;
}
/// <summary>
/// Build a TestCase from the method provided.
/// </summary>
/// <param name="method">The method to be used</param>
/// <returns>A TestCase or null</returns>
public Test BuildFrom( MethodInfo method )
{
foreach( ITestCaseBuilder builder in extensions )
{
if ( builder.CanBuildFrom( method ) )
return builder.BuildFrom( method );
}
return null;
}
#endregion
#region ExtensionPoint Overrides
protected override bool ValidExtension(object extension)
{
return extension is ITestCaseBuilder;
}
#endregion
}
}

View File

@@ -0,0 +1,43 @@
// ****************************************************************
// Copyright 2007, Charlie Poole
// This is free software licensed under the NUnit license. You may
// obtain a copy of the license at http://nunit.org/?p=license&r=2.4
// ****************************************************************
using System;
using System.Collections;
using System.Reflection;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// TestDecoratorCollection is an ExtensionPoint for TestDecorators and
/// implements the ITestDecorator interface itself, passing calls
/// on to the individual decorators.
/// </summary>
public class TestDecoratorCollection : ExtensionPoint, ITestDecorator
{
#region Constructor
public TestDecoratorCollection(IExtensionHost host)
: base( "TestDecorators", host ) { }
#endregion
#region ITestDecorator Members
public Test Decorate(Test test, MemberInfo member)
{
Test decoratedTest = test;
foreach( ITestDecorator decorator in extensions )
decoratedTest = decorator.Decorate( decoratedTest, member );
return decoratedTest;
}
#endregion
#region ExtensionPoint Overrides
protected override bool ValidExtension(object extension)
{
return extension is ITestDecorator;
}
#endregion
}
}