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,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
}
}