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,14 @@
// ****************************************************************
// 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.Reflection;
[assembly: CLSCompliant(true)]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("../../nunit.snk")]
[assembly: AssemblyKeyName("")]

View File

@@ -0,0 +1,75 @@
// ****************************************************************
// 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.
// ****************************************************************
namespace NUnit.Core
{
using System;
/// <summary>
/// The EventListener interface is used within the NUnit core to receive
/// notifications of significant events while a test is being run. These
/// events are propogated to any client, which may choose to convert them
/// to .NET events or to use them directly.
/// </summary>
public interface EventListener
{
/// <summary>
/// Called when a test run is starting
/// </summary>
/// <param name="name">The name of the test being started</param>
/// <param name="testCount">The number of test cases under this test</param>
void RunStarted( string name, int testCount );
/// <summary>
/// Called when a run finishes normally
/// </summary>
/// <param name="result">The result of the test</param>
void RunFinished( TestResult result );
/// <summary>
/// Called when a run is terminated due to an exception
/// </summary>
/// <param name="exception">Exception that was thrown</param>
void RunFinished( Exception exception );
/// <summary>
/// Called when a test case is starting
/// </summary>
/// <param name="testName">The name of the test case</param>
void TestStarted(TestName testName);
/// <summary>
/// Called when a test case has finished
/// </summary>
/// <param name="result">The result of the test</param>
void TestFinished(TestCaseResult result);
/// <summary>
/// Called when a suite is starting
/// </summary>
/// <param name="testName">The name of the suite</param>
void SuiteStarted(TestName testName);
/// <summary>
/// Called when a suite has finished
/// </summary>
/// <param name="result">The result of the suite</param>
void SuiteFinished(TestSuiteResult result);
/// <summary>
/// Called when an unhandled exception is detected during
/// the execution of a test run.
/// </summary>
/// <param name="exception">The exception thta was detected</param>
void UnhandledException( Exception exception );
/// <summary>
/// Called when the test direts output to the console.
/// </summary>
/// <param name="testOutput">A console message</param>
void TestOutput(TestOutput testOutput);
}
}

View File

@@ -0,0 +1,110 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// The Addin class holds information about an addin.
/// </summary>
[Serializable]
public class Addin
{
#region Private Fields
private string typeName;
private string name;
private string description;
private ExtensionType extensionType;
private AddinStatus status;
private string message;
#endregion
#region Constructor
/// <summary>
/// Construct an Addin for a type.
/// </summary>
/// <param name="type">The type to be used</param>
public Addin( Type type )
{
this.typeName = type.AssemblyQualifiedName;
object[] attrs = type.GetCustomAttributes( typeof(NUnitAddinAttribute), false );
if ( attrs.Length == 1 )
{
NUnitAddinAttribute attr = (NUnitAddinAttribute)attrs[0];
this.name = attr.Name;
this.description = attr.Description;
this.extensionType = attr.Type;
}
if ( this.name == null )
this.name = type.Name;
if ( this.extensionType == 0 )
this.extensionType = ExtensionType.Core;
this.status = AddinStatus.Enabled;
}
#endregion
#region Properties
/// <summary>
/// The name of the Addin
/// </summary>
public string Name
{
get { return name; }
}
/// <summary>
/// Brief description of what the Addin does
/// </summary>
public string Description
{
get { return description; }
}
/// <summary>
/// The type or types of extension provided, using
/// one or more members of the ExtensionType enumeration.
/// </summary>
public ExtensionType ExtensionType
{
get { return extensionType; }
}
/// <summary>
/// The AssemblyQualifiedName of the type that implements
/// the addin.
/// </summary>
public string TypeName
{
get { return typeName; }
}
/// <summary>
/// The status of the addin
/// </summary>
public AddinStatus Status
{
get { return status; }
set { status = value; }
}
/// <summary>
/// Any message that clarifies the status of the Addin,
/// such as an error message or an explanation of why
/// the addin is disabled.
/// </summary>
public string Message
{
get { return message; }
set { message = value; }
}
#endregion
}
}

View File

@@ -0,0 +1,36 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// The AddinStatus enum indicates the load status of an addin.
/// </summary>
public enum AddinStatus
{
/// <summary>
/// Not known - default
/// </summary>
Unknown,
/// <summary>
/// The addin is enabled but not loaded
/// </summary>
Enabled,
/// <summary>
/// The addin is disabled
/// </summary>
Disabled,
/// <summary>
/// The addin was loaded successfully
/// </summary>
Loaded,
/// <summary>
/// An error was encountered loading the addin
/// </summary>
Error
}
}

View File

@@ -0,0 +1,35 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// The ExtensionType enumeration is used to indicate the
/// kinds of extensions provided by an Addin. The addin
/// is only installed by hosts supporting one of its
/// extension types.
/// </summary>
[Flags]
public enum ExtensionType
{
/// <summary>
/// A Core extension is installed by the CoreExtensions
/// host in each test domain.
/// </summary>
Core=1,
/// <summary>
/// A Client extension is installed by all clients
/// </summary>
Client=2,
/// <summary>
/// A Gui extension is installed by the gui client
/// </summary>
Gui=4
}
}

View File

@@ -0,0 +1,29 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// Add-ins are used to extend NUnti. All add-ins must
/// implement the IAddin interface.
/// </summary>
public interface IAddin
{
/// <summary>
/// When called, the add-in installs itself into
/// the host, if possible. Because NUnit uses separate
/// hosts for the client and test domain environments,
/// an add-in may be invited to istall itself more than
/// once. The add-in is responsible for checking which
/// extension points are supported by the host that is
/// passed to it and taking the appropriate action.
/// </summary>
/// <param name="host">The host in which to install the add-in</param>
/// <returns>True if the add-in was installed, otehrwise false</returns>
bool Install( IExtensionHost host );
}
}

View File

@@ -0,0 +1,12 @@
using System;
namespace NUnit.Core.Extensibility
{
public interface IAddinManager
{
Addin[] Addins { get; }
TestFramework[] Frameworks { get; }
}
}

View File

@@ -0,0 +1,36 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// The IAddinRegistry interface allows registering addins
/// and retrieving information about them. It is also used
/// to record the load status of an addin.
/// </summary>
public interface IAddinRegistry
{
/// <summary>
/// Gets a list of all addins as Addin objects
/// </summary>
System.Collections.IList Addins { get; }
/// <summary>
/// Registers an addin
/// </summary>
/// <param name="addin">The addin to be registered</param>
void Register( Addin addin );
/// <summary>
/// Sets the load status of an addin
/// </summary>
/// <param name="name">The name of the addin</param>
/// <param name="status">The status to be set</param>
/// <param name="message">An optional message explaining the status</param>
void SetStatus( string name, AddinStatus status, string message );
}
}

View File

@@ -0,0 +1,46 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// The IExtensionHost interface is implemented by each
/// of NUnit's Extension hosts. Currently, there is
/// only one host, which resides in the test domain.
/// </summary>
public interface IExtensionHost
{
/// <summary>
/// Get a list of the ExtensionPoints provided by this host.
/// </summary>
IExtensionPoint[] ExtensionPoints
{
get;
}
/// <summary>
/// Get an interface to the framework registry
/// </summary>
IFrameworkRegistry FrameworkRegistry
{
get;
}
/// <summary>
/// Return an extension point by name, if present
/// </summary>
/// <param name="name">The name of the extension point</param>
/// <returns>The extension point, if found, otherwise null</returns>
IExtensionPoint GetExtensionPoint( string name );
/// <summary>
/// Gets the ExtensionTypes supported by this host
/// </summary>
/// <returns>An enum indicating the ExtensionTypes supported</returns>
ExtensionType ExtensionTypes { get; }
}
}

View File

@@ -0,0 +1,42 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// Represents a single point of extension for NUnit. Some extension
/// points may accept only a single extension, while others may
/// accept more than one at the same time.
/// </summary>
public interface IExtensionPoint
{
/// <summary>
/// Get the name of this extension point
/// </summary>
string Name { get; }
/// <summary>
/// Get the host that provides this extension point
/// </summary>
IExtensionHost Host { get; }
/// <summary>
/// Install an extension at this extension point. If the
/// extension object does not meet the requirements for
/// this extension point, an exception is thrown.
/// </summary>
/// <param name="extension">The extension to install</param>
void Install( object extension );
/// <summary>
/// Removes an extension from this extension point. If the
/// extension object is not present, the method returns
/// without error.
/// <param name="extension"></param>
void Remove( object extension );
}
}

View File

@@ -0,0 +1,23 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// The IFrameworkRegistry allows extensions to register new
/// frameworks or emulations of other frameworks.
/// </summary>
public interface IFrameworkRegistry
{
/// <summary>
/// Register a framework
/// </summary>
/// <param name="frameworkName">The name of the framework</param>
/// <param name="assemblyName">The name of the assembly that the tests reference</param>
void Register( string frameworkName, string assemblyName );
}
}

View File

@@ -0,0 +1,37 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// The ISuiteBuilder interface is exposed by a class that knows how to
/// build a suite from one or more Types.
/// </summary>
public interface ISuiteBuilder
{
/// <summary>
/// Examine the type and determine if it is suitable for
/// this builder to use in building a TestSuite.
///
/// Note that returning false will cause the type to be ignored
/// in loading the tests. If it is desired to load the suite
/// but label it as non-runnable, ignored, etc., then this
/// method must return true.
/// </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>
bool CanBuildFrom( Type type );
/// <summary>
/// Build a TestSuite from type provided.
/// </summary>
/// <param name="type">The type of the fixture to be used</param>
/// <returns>A TestSuite</returns>
Test BuildFrom( Type type );
}
}

View File

@@ -0,0 +1,39 @@
// ****************************************************************
// 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.Reflection;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// The ITestCaseBuilder interface is exposed by a class that knows how to
/// build a test case from certain methods.
/// </summary>
public interface ITestCaseBuilder
{
/// <summary>
/// Examine the method and determine if it is suitable for
/// this builder to use in building a TestCase.
///
/// Note that returning false will cause the method to be ignored
/// in loading the tests. If it is desired to load the method
/// but label it as non-runnable, ignored, etc., then this
/// method must return true.
///
/// Derived classes must override this method.
/// </summary>
/// <param name="method">The test method to examine</param>
/// <returns>True is the builder can use this method</returns>
bool CanBuildFrom( MethodInfo method );
/// <summary>
/// Build a TestCase from the provided MethodInfo.
/// </summary>
/// <param name="method">The method to be used as a test case</param>
/// <returns>A TestCase or null</returns>
Test BuildFrom( MethodInfo method );
}
}

View File

@@ -0,0 +1,26 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// The ITestDecorator interface is exposed by a class that knows how to
/// enhance the functionality of a test case or suite by decorating it.
/// </summary>
public interface ITestDecorator
{
/// <summary>
/// Examine the a Test and either return it as is, modify it
/// or return a different TestCase.
/// </summary>
/// <param name="test">The Test to be decorated</param>
/// <param name="member">The MethodInfo used to construct the test</param>
/// <returns>The resulting Test</returns>
Test Decorate( Test test, MemberInfo member );
}
}

View File

@@ -0,0 +1,40 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// NUnitAddinAttribute is used to mark all add-ins. The marked class
/// must implement the IAddin interface.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=false)]
public sealed class NUnitAddinAttribute : Attribute
{
/// <summary>
/// The name of this addin
/// </summary>
public string Name;
/// <summary>
/// A description for the addin
/// </summary>
public string Description;
/// <summary>
/// The type of extension provided
/// </summary>
public ExtensionType Type;
/// <summary>
/// Default Constructor
/// </summary>
public NUnitAddinAttribute()
{
this.Type = ExtensionType.Core;
}
}
}

View File

@@ -0,0 +1,42 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Extensibility
{
/// <summary>
/// Summary description for TestFramework.
/// </summary>
[Serializable]
public class TestFramework
{
#region Instance Fields
/// <summary>
/// The name of the framework
/// </summary>
public string Name;
/// <summary>
/// The file name of the assembly that defines the framwork
/// </summary>
public string AssemblyName;
#endregion
#region Constructor
/// <summary>
/// Constructs a TestFramwork object given its name and assembly name.
/// </summary>
/// <param name="frameworkName"></param>
/// <param name="assemblyName"></param>
public TestFramework( string frameworkName, string assemblyName )
{
this.Name = frameworkName;
this.AssemblyName = assemblyName;
}
#endregion
}
}

View File

@@ -0,0 +1,82 @@
// ****************************************************************
// 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.Filters
{
/// <summary>
/// Combines multiple filters so that a test must pass all
/// of them in order to pass this filter.
/// </summary>
[Serializable]
public class AndFilter : TestFilter
{
private ArrayList filters = new ArrayList();
/// <summary>
/// Constructs an empty AndFilter
/// </summary>
public AndFilter() { }
/// <summary>
/// Constructs an AndFilter from an array of filters
/// </summary>
/// <param name="filters"></param>
public AndFilter( params ITestFilter[] filters )
{
this.filters.AddRange( filters );
}
/// <summary>
/// Adds a filter to the list of filters
/// </summary>
/// <param name="filter">The filter to be added</param>
public void Add( ITestFilter filter )
{
this.filters.Add( filter );
}
/// <summary>
/// Return an array of the composing filters
/// </summary>
public ITestFilter[] Filters
{
get
{
return (ITestFilter[])filters.ToArray(typeof(ITestFilter));
}
}
/// <summary>
/// Checks whether the AndFilter is matched by a test
/// </summary>
/// <param name="test">The test to be matched</param>
/// <returns>True if all the component filters pass, otherwise false</returns>
public override bool Pass( ITest test )
{
foreach( ITestFilter filter in filters )
if ( !filter.Pass( test ) )
return false;
return true;
}
/// <summary>
/// Checks whether the AndFilter is matched by a test
/// </summary>
/// <param name="test">The test to be matched</param>
/// <returns>True if all the component filters match, otherwise false</returns>
public override bool Match( ITest test )
{
foreach( ITestFilter filter in filters )
if ( !filter.Match( test ) )
return false;
return true;
}
}
}

View File

@@ -0,0 +1,102 @@
// ****************************************************************
// 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.Text;
using System.Collections;
namespace NUnit.Core.Filters
{
/// <summary>
/// CategoryFilter is able to select or exclude tests
/// based on their categories.
/// </summary>
///
[Serializable]
public class CategoryFilter : TestFilter
{
ArrayList categories;
/// <summary>
/// Construct an empty CategoryFilter
/// </summary>
public CategoryFilter()
{
categories = new ArrayList();
}
/// <summary>
/// Construct a CategoryFilter using a single category name
/// </summary>
/// <param name="name">A category name</param>
public CategoryFilter( string name )
{
categories = new ArrayList();
if ( name != null && name != string.Empty )
categories.Add( name );
}
/// <summary>
/// Construct a CategoryFilter using an array of category names
/// </summary>
/// <param name="names">An array of category names</param>
public CategoryFilter( string[] names )
{
categories = new ArrayList();
if ( names != null )
categories.AddRange( names );
}
/// <summary>
/// Add a category name to the filter
/// </summary>
/// <param name="name">A category name</param>
public void AddCategory(string name)
{
categories.Add( name );
}
/// <summary>
/// Check whether the filter matches a test
/// </summary>
/// <param name="test">The test to be matched</param>
/// <returns></returns>
public override bool Match(ITest test)
{
if ( test.Categories == null )
return false;
foreach( string cat in categories )
if ( test.Categories.Contains( cat ) )
return true;
return false;
}
/// <summary>
/// Return the string representation of a category filter
/// </summary>
/// <returns></returns>
public override string ToString()
{
StringBuilder sb = new StringBuilder();
for( int i = 0; i < categories.Count; i++ )
{
if ( i > 0 ) sb.Append( ',' );
sb.Append( categories[i] );
}
return sb.ToString();
}
/// <summary>
/// Gets the list of categories from this filter
/// </summary>
public IList Categories
{
get { return categories; }
}
}
}

View File

@@ -0,0 +1,58 @@
// ****************************************************************
// 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.Filters
{
/// <summary>
/// Summary description for NameFilter.
/// </summary>
///
[Serializable]
public class NameFilter : TestFilter
{
private ArrayList testNames = new ArrayList();
/// <summary>
/// Construct an empty NameFilter
/// </summary>
public NameFilter() { }
/// <summary>
/// Construct a NameFilter for a single TestName
/// </summary>
/// <param name="testName"></param>
public NameFilter( TestName testName )
{
testNames.Add( testName );
}
/// <summary>
/// Add a TestName to a NameFilter
/// </summary>
/// <param name="testName"></param>
public void Add( TestName testName )
{
testNames.Add( testName );
}
/// <summary>
/// Check if a test matches the filter
/// </summary>
/// <param name="test">The test to match</param>
/// <returns>True if it matches, false if not</returns>
public override bool Match( ITest test )
{
foreach( TestName testName in testNames )
if ( test.TestName == testName )
return true;
return false;
}
}
}

View File

@@ -0,0 +1,64 @@
// ****************************************************************
// 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;
namespace NUnit.Core.Filters
{
/// <summary>
/// NotFilter negates the operation of another filter
/// </summary>
[Serializable]
public class NotFilter : TestFilter
{
ITestFilter baseFilter;
/// <summary>
/// Construct a not filter on another filter
/// </summary>
/// <param name="baseFilter">The filter to be negated</param>
public NotFilter( ITestFilter baseFilter)
{
this.baseFilter = baseFilter;
}
/// <summary>
/// Gets the base filter
/// </summary>
public ITestFilter BaseFilter
{
get { return baseFilter; }
}
/// <summary>
/// Check whether the filter matches a test
/// </summary>
/// <param name="test">The test to be matched</param>
/// <returns>True if it matches, otherwise false</returns>
public override bool Match( ITest test )
{
return test.RunState != RunState.Explicit && !baseFilter.Pass( test );
}
/// <summary>
/// Determine whether any descendant of the test matches the filter criteria.
/// </summary>
/// <param name="test">The test to be matched</param>
/// <returns>True if at least one descendant matches the filter criteria</returns>
protected override bool MatchDescendant(ITest test)
{
if (!test.IsSuite || test.Tests == null || test.RunState == RunState.Explicit)
return false;
foreach (ITest child in test.Tests)
{
if (Match(child) || MatchDescendant(child))
return true;
}
return false;
}
}
}

Some files were not shown because too many files have changed in this diff Show More