Browse Source
Fixes SD2-621 (ExpectedException test failure not added to error list), SD2-408 (Add "Run Test" to member bookmark), SD2-618 (Run test fixture in console with debugger shows no output). git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1069 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
109 changed files with 1792 additions and 6706 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,297 +0,0 @@
@@ -1,297 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using System; |
||||
using System.IO; |
||||
using System.Reflection; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Base class that provides an NCover runner to run tests
|
||||
/// with code coverage
|
||||
/// </summary>
|
||||
public abstract class AbstractRunTestsWithCodeCoverageCommand : AbstractMenuCommand |
||||
{ |
||||
static MessageViewCategory category; |
||||
static NCoverRunner runner; |
||||
|
||||
public AbstractRunTestsWithCodeCoverageCommand() |
||||
{ |
||||
if (runner == null) { |
||||
runner = NCoverRunnerSingleton.Runner; |
||||
runner.NCoverExited += new NCoverExitEventHandler(NCoverExited); |
||||
runner.OutputLineReceived += new LineReceivedEventHandler(OutputLineReceived); |
||||
} |
||||
} |
||||
|
||||
public override void Run() |
||||
{ |
||||
if (IsBuildRunning) { |
||||
throw new CodeCoverageException(); |
||||
} |
||||
|
||||
string ncoverFileName = GetNCoverFileName(); |
||||
if (ncoverFileName != null) { |
||||
SetNCoverRunnerProperties(ncoverFileName); |
||||
RunNCover(); |
||||
} else { |
||||
using (CodeCoverageRunnerNotFoundForm form = new CodeCoverageRunnerNotFoundForm()) { |
||||
form.ShowDialog(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the full filename of the assembly being tested.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual string GetTestAssemblyFileName() |
||||
{ |
||||
return String.Empty; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the project containing the tests.
|
||||
/// </summary>
|
||||
protected virtual IProject GetProject() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
bool IsBuildRunning { |
||||
get { |
||||
return runner.IsRunning; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the message view output window.
|
||||
/// </summary>
|
||||
MessageViewCategory Category { |
||||
get { |
||||
if (category == null) { |
||||
category = new MessageViewCategory("Code Coverage"); |
||||
CompilerMessageView cmv = (CompilerMessageView)WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).PadContent; |
||||
cmv.AddCategory(category); |
||||
} |
||||
return category; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Writes a line of text to the output window.
|
||||
/// </summary>
|
||||
void CategoryWriteLine(string message) |
||||
{ |
||||
Category.AppendText(String.Concat(message, Environment.NewLine)); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Brings output pad to the front.
|
||||
/// </summary>
|
||||
void ShowOutputPad() |
||||
{ |
||||
WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront(); |
||||
} |
||||
|
||||
bool FileNameExists(string fileName) |
||||
{ |
||||
return fileName.Length > 0 && File.Exists(fileName); |
||||
} |
||||
|
||||
void SetNCoverRunnerProperties(string ncoverFileName) |
||||
{ |
||||
IProject project = GetProject(); |
||||
string ncoverOutputDirectory = GetNCoverOutputDirectory(project); |
||||
runner.NCoverFileName = ncoverFileName; |
||||
runner.ProfiledApplicationCommand = GetMbUnitConsoleFileName(); |
||||
runner.ProfiledApplicationCommandLineArguments = GetMbUnitConsoleCommandLineArguments(ncoverOutputDirectory); |
||||
runner.WorkingDirectory = Path.GetDirectoryName(GetTestAssemblyFileName()); |
||||
runner.CoverageResultsFileName = Path.Combine(ncoverOutputDirectory, "Coverage.Xml"); |
||||
runner.LogFileName = Path.Combine(ncoverOutputDirectory, "Coverage.log"); |
||||
runner.AssemblyList = GetAssemblyList(project); |
||||
} |
||||
|
||||
void RunNCover() |
||||
{ |
||||
CodeCoverageService.ClearResults(); |
||||
|
||||
Category.ClearText(); |
||||
TaskService.ClearExceptCommentTasks(); |
||||
ShowOutputPad(); |
||||
|
||||
// Remove existing coverage results file.
|
||||
if (File.Exists(runner.CoverageResultsFileName)) { |
||||
File.Delete(runner.CoverageResultsFileName); |
||||
} |
||||
|
||||
// Remove existing MbUnit results file.
|
||||
string mbUnitResultsFileName = GetMbUnitResultsFileName(); |
||||
if (File.Exists(mbUnitResultsFileName)) { |
||||
File.Delete(mbUnitResultsFileName); |
||||
} |
||||
|
||||
// Create NCover output directory.
|
||||
if (!Directory.Exists(Path.GetDirectoryName(runner.CoverageResultsFileName))) { |
||||
Directory.CreateDirectory(Path.GetDirectoryName(runner.CoverageResultsFileName)); |
||||
} |
||||
|
||||
CategoryWriteLine(StringParser.Parse("Running NCover...")); |
||||
CategoryWriteLine(runner.CommandLine); |
||||
|
||||
runner.Start(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Displays the output from NCover after it has exited.
|
||||
/// </summary>
|
||||
/// <param name="sender">The event source.</param>
|
||||
/// <param name="e">The NCover exit event arguments.</param>
|
||||
void NCoverExited(object sender, NCoverExitEventArgs e) |
||||
{ |
||||
System.Diagnostics.Debug.Assert(e.Error.Length == 0); |
||||
|
||||
DisplayMbUnitResults(GetMbUnitResultsFileName()); |
||||
DisplayCoverageResults(runner.CoverageResultsFileName); |
||||
|
||||
if (TaskService.SomethingWentWrong) { |
||||
ShowErrorList(); |
||||
} |
||||
} |
||||
|
||||
void OutputLineReceived(object sender, LineReceivedEventArgs e) |
||||
{ |
||||
CategoryWriteLine(e.Line); |
||||
} |
||||
|
||||
void DisplayCoverageResults(string fileName) |
||||
{ |
||||
if (!File.Exists(fileName)) { |
||||
Task task = new Task(String.Empty, String.Concat("No code coverage results file generated: ", fileName), 0, 0, TaskType.Error); |
||||
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", new object[] {task}); |
||||
return; |
||||
} |
||||
|
||||
CodeCoverageResults results = new CodeCoverageResults(fileName); |
||||
WorkbenchSingleton.SafeThreadAsyncCall(typeof(CodeCoverageService), "ShowResults", new object[] {results}); |
||||
} |
||||
|
||||
void DisplayMbUnitResults(string fileName) |
||||
{ |
||||
if (!File.Exists(fileName)) { |
||||
Task task = new Task(String.Empty, String.Concat("No MbUnit results file generated: ", fileName), 0, 0, TaskType.Error); |
||||
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", new object[] {task}); |
||||
return; |
||||
} |
||||
|
||||
MbUnitResults results = new MbUnitResults(fileName); |
||||
foreach (Task task in results.Tasks) { |
||||
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", new object[] {task}); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the full path to the NCover console application if it
|
||||
/// exists.
|
||||
/// </summary>
|
||||
string GetNCoverFileName() |
||||
{ |
||||
string ncoverFileName = CodeCoverageOptions.NCoverFileName; |
||||
if (FileNameExists(ncoverFileName)) { |
||||
return ncoverFileName; |
||||
} else { |
||||
ncoverFileName = GetDefaultNCoverFileName(); |
||||
if (FileNameExists(ncoverFileName)) { |
||||
return ncoverFileName; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the default full path to the NCover console application.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string GetDefaultNCoverFileName() |
||||
{ |
||||
string programFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); |
||||
return Path.Combine(programFilesPath, @"NCover\NCover.Console.exe"); |
||||
} |
||||
|
||||
void ShowErrorList() |
||||
{ |
||||
PadDescriptor padDescriptor = WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)); |
||||
if (padDescriptor != null) { |
||||
WorkbenchSingleton.SafeThreadAsyncCall(padDescriptor, "BringPadToFront"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Reads the list of assemblies to be profiled from the project's
|
||||
/// NCover settings.
|
||||
/// </summary>
|
||||
string GetAssemblyList(IProject project) |
||||
{ |
||||
if (project == null) { |
||||
return String.Empty; |
||||
} |
||||
|
||||
string ncoverSettingsFileName = NCoverSettings.GetFileName(project); |
||||
if (File.Exists(ncoverSettingsFileName)) { |
||||
NCoverSettings settings = new NCoverSettings(ncoverSettingsFileName); |
||||
return settings.AssemblyList; |
||||
} |
||||
return String.Empty; |
||||
} |
||||
|
||||
string GetNCoverOutputDirectory(IProject project) |
||||
{ |
||||
return Path.Combine(project.Directory, "NCover"); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the assembly folder where this add-in was loaded from.
|
||||
/// </summary>
|
||||
/// <returns>The assembly folder where this add-in was loaded.</returns>
|
||||
string GetAssemblyFolder() |
||||
{ |
||||
Assembly assembly = GetType().Assembly; |
||||
string assemblyFilename = assembly.CodeBase.Replace("file:///", String.Empty); |
||||
return Path.GetDirectoryName(assemblyFilename); |
||||
} |
||||
|
||||
string GetMbUnitConsoleFileName() |
||||
{ |
||||
return Path.GetFullPath(Path.Combine(GetAssemblyFolder(), |
||||
@"..\..\..\..\bin\Tools\MbUnit\MbUnit.Cons.exe")); |
||||
} |
||||
|
||||
string GetMbUnitConsoleCommandLineArguments(string reportFolder) |
||||
{ |
||||
StringBuilder commandLine = new StringBuilder(); |
||||
|
||||
commandLine.Append("/report-name-format:mbunit "); |
||||
commandLine.Append("/report-type:Xml "); |
||||
commandLine.AppendFormat("/report-folder:\"{0}\" ", reportFolder); |
||||
commandLine.AppendFormat("\"{0}\"", GetTestAssemblyFileName()); |
||||
|
||||
return commandLine.ToString(); |
||||
} |
||||
|
||||
string GetMbUnitResultsFileName() |
||||
{ |
||||
string ncoverOutputDirectory = Path.GetDirectoryName(runner.CoverageResultsFileName); |
||||
return Path.Combine(ncoverOutputDirectory, "mbunit.xml"); |
||||
} |
||||
} |
||||
} |
@ -1,113 +0,0 @@
@@ -1,113 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Reads the MbUnit results file.
|
||||
/// </summary>
|
||||
public class MbUnitResults |
||||
{ |
||||
static readonly string RunElementName = "run"; |
||||
static readonly string MessageElementName = "message"; |
||||
static readonly string StackTraceElementName= "stack-trace"; |
||||
|
||||
List<Task> tasks = new List<Task>(); |
||||
|
||||
public MbUnitResults(string fileName) : this(new StreamReader(fileName, true)) |
||||
{ |
||||
} |
||||
|
||||
public MbUnitResults(XmlTextReader reader) |
||||
{ |
||||
ReadResults(reader); |
||||
} |
||||
|
||||
public MbUnitResults(TextReader reader) : this(new XmlTextReader(reader)) |
||||
{ |
||||
} |
||||
|
||||
public List<Task> Tasks { |
||||
get { |
||||
return tasks; |
||||
} |
||||
} |
||||
|
||||
void ReadResults(XmlTextReader reader) |
||||
{ |
||||
using (reader) { |
||||
while (reader.Read()) { |
||||
if (reader.NodeType == XmlNodeType.Element) { |
||||
if (IsRunFailureElement(reader)) { |
||||
ReadErrorTask(reader); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
bool IsRunFailureElement(XmlReader reader) |
||||
{ |
||||
if (reader.Name == RunElementName) { |
||||
string result = reader.GetAttribute("result"); |
||||
if (result == "failure") { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
void ReadErrorTask(XmlReader reader) |
||||
{ |
||||
string testCase = reader.GetAttribute("name"); |
||||
string message = String.Empty; |
||||
|
||||
while (reader.Read()) { |
||||
if (reader.NodeType == XmlNodeType.Element) { |
||||
if (reader.Name == MessageElementName) { |
||||
message = reader.ReadElementString(); |
||||
} else if (reader.Name == StackTraceElementName) { |
||||
string stackTrace = reader.ReadElementString(); |
||||
AddTask(GetDescription(testCase, message), stackTrace); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets task error description.
|
||||
/// </summary>
|
||||
string GetDescription(string testCase, string message) |
||||
{ |
||||
return StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] { |
||||
{"TestCase", testCase}, |
||||
{"Message", message} |
||||
}); |
||||
} |
||||
|
||||
void AddTask(string description, string stackTrace) |
||||
{ |
||||
FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(stackTrace, true); |
||||
if (lineRef != null) { |
||||
Task task = new Task(Path.GetFullPath(lineRef.FileName), |
||||
description, |
||||
lineRef.Column, |
||||
lineRef.Line, |
||||
TaskType.Error); |
||||
tasks.Add(task); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,113 +0,0 @@
@@ -1,113 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Reads the NUnit results file.
|
||||
/// </summary>
|
||||
public class NUnitResults |
||||
{ |
||||
static readonly string TestCaseElementName = "test-case"; |
||||
static readonly string MessageElementName = "message"; |
||||
static readonly string StackTraceElementName= "stack-trace"; |
||||
|
||||
List<Task> tasks = new List<Task>(); |
||||
|
||||
public NUnitResults(string fileName) : this(new StreamReader(fileName, true)) |
||||
{ |
||||
} |
||||
|
||||
public NUnitResults(XmlTextReader reader) |
||||
{ |
||||
ReadResults(reader); |
||||
} |
||||
|
||||
public NUnitResults(TextReader reader) : this(new XmlTextReader(reader)) |
||||
{ |
||||
} |
||||
|
||||
public List<Task> Tasks { |
||||
get { |
||||
return tasks; |
||||
} |
||||
} |
||||
|
||||
void ReadResults(XmlTextReader reader) |
||||
{ |
||||
using (reader) { |
||||
while (reader.Read()) { |
||||
if (reader.NodeType == XmlNodeType.Element) { |
||||
if (IsTestCaseFailureElement(reader)) { |
||||
ReadErrorTask(reader); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
bool IsTestCaseFailureElement(XmlReader reader) |
||||
{ |
||||
if (reader.Name == TestCaseElementName) { |
||||
string success = reader.GetAttribute("success"); |
||||
if (success == "False") { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
void ReadErrorTask(XmlReader reader) |
||||
{ |
||||
string testCase = reader.GetAttribute("name"); |
||||
string message = String.Empty; |
||||
|
||||
while (reader.Read()) { |
||||
if (reader.NodeType == XmlNodeType.Element) { |
||||
if (reader.Name == MessageElementName) { |
||||
message = reader.ReadElementString(); |
||||
} else if (reader.Name == StackTraceElementName) { |
||||
string stackTrace = reader.ReadElementString(); |
||||
AddTask(GetDescription(testCase, message), stackTrace); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets task error description.
|
||||
/// </summary>
|
||||
string GetDescription(string testCase, string message) |
||||
{ |
||||
return StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] { |
||||
{"TestCase", testCase}, |
||||
{"Message", message} |
||||
}); |
||||
} |
||||
|
||||
void AddTask(string description, string stackTrace) |
||||
{ |
||||
FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(stackTrace, true); |
||||
if (lineRef != null) { |
||||
Task task = new Task(Path.GetFullPath(lineRef.FileName), |
||||
description, |
||||
lineRef.Column, |
||||
lineRef.Line, |
||||
TaskType.Error); |
||||
tasks.Add(task); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,37 +0,0 @@
@@ -1,37 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.MbUnitPad; |
||||
using System; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class RunMbUnitPadTestsWithCodeCoverageCommand : AbstractRunTestsWithCodeCoverageCommand |
||||
{ |
||||
protected override string GetTestAssemblyFileName() |
||||
{ |
||||
return MbUnitPadContent.Instance.SelectedAssemblyFileName; |
||||
} |
||||
|
||||
protected override IProject GetProject() |
||||
{ |
||||
return GetSelectedProject(GetTestAssemblyFileName()); |
||||
} |
||||
|
||||
IProject GetSelectedProject(string outputAssemblyFileName) |
||||
{ |
||||
foreach (IProject project in ProjectService.OpenSolution.Projects) { |
||||
if (FileUtility.IsEqualFileName(outputAssemblyFileName, project.OutputAssemblyFullPath)) { |
||||
return project; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -1,47 +0,0 @@
@@ -1,47 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.MbUnitPad; |
||||
using System; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Menu command selected after right clicking a test fixture in the text editor
|
||||
/// to run tests with code coverage.
|
||||
/// </summary>
|
||||
public class RunTestFixtureWithCodeCoverageCommand : AbstractRunTestsWithCodeCoverageCommand |
||||
{ |
||||
IProject project; |
||||
|
||||
public override void Run() |
||||
{ |
||||
IMember m = MbUnitTestableCondition.GetMember(Owner); |
||||
IClass c = (m != null) ? m.DeclaringType : MbUnitTestableCondition.GetClass(Owner); |
||||
project = c.ProjectContent.Project; |
||||
if (project != null) { |
||||
base.Run(); |
||||
} else { |
||||
MessageService.ShowMessage("Unable to determine project."); |
||||
} |
||||
} |
||||
|
||||
protected override IProject GetProject() |
||||
{ |
||||
return project; |
||||
} |
||||
|
||||
protected override string GetTestAssemblyFileName() |
||||
{ |
||||
return project.OutputAssemblyFullPath; |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||
# SharpDevelop 2.0.0.960 |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MbUnitPad", "Project\MbUnitPad.csproj", "{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}" |
||||
EndProject |
||||
Global |
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
Debug|Any CPU = Debug|Any CPU |
||||
Release|Any CPU = Release|Any CPU |
||||
EndGlobalSection |
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
EndGlobalSection |
||||
EndGlobal |
@ -1,176 +0,0 @@
@@ -1,176 +0,0 @@
|
||||
<AddIn name = "MbUnit-Addin" |
||||
author = "Daniel Grunwald" |
||||
copyright = "prj:///doc/copyright.txt" |
||||
description = "Runs MbUnit and NUnit tests inside #Develop"> |
||||
|
||||
<Manifest> |
||||
<Identity name = "ICSharpCode.MbUnitPad"/> |
||||
</Manifest> |
||||
|
||||
<Runtime> |
||||
<!-- MbUnit is not in the path, so we need to load it manually --> |
||||
<Import assembly = "../../../../bin/Tools/MbUnit/MbUnit.GUI.exe"/> |
||||
<Import assembly = "MbUnitPad.dll"> |
||||
<ConditionEvaluator name = "MbUnitTestable" class = "ICSharpCode.MbUnitPad.MbUnitTestableCondition"/> |
||||
<ConditionEvaluator name = "MbUnitRunningTests" class = "ICSharpCode.MbUnitPad.MbUnitRunningTestsCondition"/> |
||||
</Import> |
||||
</Runtime> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/Pads"> |
||||
<Pad id = "MbUnitPad" |
||||
category = "Tools" |
||||
title = "${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}" |
||||
icon = "PadIcons.MbUnitTest" |
||||
shortcut = "Control|Alt|T" |
||||
class = "ICSharpCode.MbUnitPad.MbUnitPadContent"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassMemberContextMenu"> |
||||
<Include id = "MbUnitTests" insertbefore = "MenuBuilder" item="/SharpDevelop/Pads/ClassBrowser/MemberContextMenu/MbUnitTestMenu"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassBookmarkContextMenu"> |
||||
<Include id = "MbUnitTests" insertbefore = "MenuBuilder" item="/SharpDevelop/Pads/ClassBrowser/ClassContextMenu/MbUnitTestMenu"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Pads/ClassBrowser/MemberContextMenu"> |
||||
<Condition name = "MbUnitTestable"> |
||||
<MenuItem id="MbUnitTestMenu" type="Menu" label="Unit Testing" icon="PadIcons.MbUnitTest" insertbefore="MenuBuilder"> |
||||
<MenuItem id = "RunInPad" |
||||
label = "Run in unit test pad" |
||||
icon = "PadIcons.MbUnitTest" |
||||
class = "ICSharpCode.MbUnitPad.RunTestInPadCommand"/> |
||||
<MenuItem id = "RunWithDebugger" |
||||
label = "Run in console with debugger" |
||||
icon = "Icons.16x16.RunProgramIcon" |
||||
class = "ICSharpCode.MbUnitPad.RunTestWithDebuggerCommand"/> |
||||
</MenuItem> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Pads/ClassBrowser/ClassContextMenu"> |
||||
<Condition name = "MbUnitTestable"> |
||||
<MenuItem id="MbUnitTestMenu" type="Menu" label="Unit Testing" icon="PadIcons.MbUnitTest" insertbefore="MenuBuilder"> |
||||
<MenuItem id = "RunInPad" |
||||
label = "Run in unit test pad" |
||||
icon = "PadIcons.MbUnitTest" |
||||
class = "ICSharpCode.MbUnitPad.RunTestInPadCommand"/> |
||||
<MenuItem id = "RunWithDebugger" |
||||
label = "Run in console with debugger" |
||||
icon = "Icons.16x16.RunProgramIcon" |
||||
class = "ICSharpCode.MbUnitPad.RunTestWithDebuggerCommand"/> |
||||
</MenuItem> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Pads/MbUnitPad/Toolbar"> |
||||
<Condition name = "SolutionOpen" action="Disable"> |
||||
<ToolbarItem id = "Reload" |
||||
icon = "Icons.16x16.BrowserRefresh" |
||||
tooltip = "${res:NUnitPad.NUnitPadContent.RefreshItem}" |
||||
class = "ICSharpCode.MbUnitPad.ReloadCommand"/> |
||||
<ToolbarItem id = "Unload" |
||||
icon = "Icons.16x16.BrowserCancel" |
||||
tooltip = "${res:NUnitPad.NUnitPadContent.CancelItem}" |
||||
class = "ICSharpCode.MbUnitPad.UnloadCommand"/> |
||||
<ToolbarItem id = "Separator1" type = "Separator"/> |
||||
<ToolbarItem id = "AddMbUnitReference" |
||||
icon = "Icons.16x16.Reference" |
||||
tooltip = "${res:MbUnitPad.ReferenceItem}" |
||||
class = "ICSharpCode.MbUnitPad.AddMbUnitReferenceCommand"/> |
||||
<ToolbarItem id = "AddNUnitReference" |
||||
icon = "PadIcons.NUnitTest" |
||||
tooltip = "${res:NUnitPad.NUnitPadContent.ReferenceItem}" |
||||
class = "ICSharpCode.MbUnitPad.AddNUnitReferenceCommand"/> |
||||
<ToolbarItem id = "Separator2" type = "Separator"/> |
||||
</Condition> |
||||
<ComplexCondition action="Disable"> |
||||
<And> |
||||
<Condition name="SolutionOpen"/> |
||||
<Not> |
||||
<Condition name="MbUnitRunningTests"/> |
||||
</Not> |
||||
</And> |
||||
<ToolbarItem id = "Run" |
||||
icon = "Icons.16x16.RunProgramIcon" |
||||
tooltip = "${res:NUnitPad.NUnitPadContent.RunItem}" |
||||
class = "ICSharpCode.MbUnitPad.RunTestsCommand"/> |
||||
</ComplexCondition> |
||||
<ComplexCondition action="Disable"> |
||||
<And> |
||||
<Condition name="SolutionOpen"/> |
||||
<Condition name="MbUnitRunningTests"/> |
||||
</And> |
||||
<ToolbarItem id = "Stop" |
||||
icon = "Icons.16x16.Debug.StopProcess" |
||||
tooltip = "${res:NUnitPad.NUnitPadContent.StopTests}" |
||||
class = "ICSharpCode.MbUnitPad.StopTestsCommand"/> |
||||
</ComplexCondition> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Pads/MbUnitPad/ContextMenu"> |
||||
<ComplexCondition action="Disable"> |
||||
<And> |
||||
<Condition name="Ownerstate" ownerstate="TestItemSelected"/> |
||||
<Not> |
||||
<Condition name="MbUnitRunningTests"/> |
||||
</Not> |
||||
</And> |
||||
<MenuItem id = "Run" |
||||
icon = "Icons.16x16.RunProgramIcon" |
||||
label = "${res:NUnitPad.NUnitPadContent.RunTestsContextMenuLabel}" |
||||
class = "ICSharpCode.MbUnitPad.RunTestsCommand"/> |
||||
</ComplexCondition> |
||||
<ComplexCondition action="Disable"> |
||||
<And> |
||||
<Condition name="Ownerstate" ownerstate="TestItemSelected"/> |
||||
<Condition name="MbUnitRunningTests"/> |
||||
</And> |
||||
<MenuItem id = "Stop" |
||||
icon = "Icons.16x16.Debug.StopProcess" |
||||
label = "${res:NUnitPad.NUnitPadContent.StopTests}" |
||||
class = "ICSharpCode.MbUnitPad.StopTestsCommand"/> |
||||
</ComplexCondition> |
||||
<Condition name="Ownerstate" ownerstate="SourceCodeItemSelected" action="Disable"> |
||||
|
||||
<MenuItem id = "GotoDefinition" |
||||
label = "${res:NUnitPad.NUnitPadContent.GotoDefinitionContextMenuLabel}" |
||||
class = "ICSharpCode.MbUnitPad.GotoDefinitionCommand"/> |
||||
</Condition> |
||||
<MenuItem id="Tree" |
||||
label="${res:MainWindow.Windows.UnitTestsTreeView.TreeMenu}" |
||||
type="Menu"> |
||||
<MenuItem id = "ExpandAll" |
||||
label = "${res:MainWindow.Windows.SearchResultPanel.ExpandAll.ToolTip}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandAllCommand"/> |
||||
<MenuItem id = "CollapseAll" |
||||
label = "${res:MainWindow.Windows.SearchResultPanel.CollapseAll.ToolTip}" |
||||
class = "ICSharpCode.MbUnitPad.CollapseAllCommand"/> |
||||
<MenuItem id="Separator1" type = "Separator"/> |
||||
<MenuItem id = "ExpandCurrent" |
||||
label = "${res:MainWindow.Windows.TreeView.ExpandCurrent}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandCurrentCommand"/> |
||||
<MenuItem id = "CollapseCurrent" |
||||
label = "${res:MainWindow.Windows.TreeView.CollapseCurrent}" |
||||
class = "ICSharpCode.MbUnitPad.CollapseCurrentCommand"/> |
||||
<MenuItem id="Separator2" type = "Separator"/> |
||||
<MenuItem id = "ExpandAllFailures" |
||||
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandAllFailures}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandAllFailuresCommand"/> |
||||
<MenuItem id = "ExpandCurrentFailures" |
||||
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandCurrentFailures}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandCurrentFailuresCommand"/> |
||||
<MenuItem id="Separator3" type = "Separator"/> |
||||
<MenuItem id = "ExpandAllIgnored" |
||||
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandAllIgnoredTests}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandAllIgnoredCommand"/> |
||||
<MenuItem id = "ExpandCurrentIgnored" |
||||
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandCurrentIgnoredTests}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandCurrentIgnoredCommand"/> |
||||
<MenuItem id="Separator4" type = "Separator"/> |
||||
<MenuItem id = "ClearResults" |
||||
label = "${res:MainWindow.Windows.UnitTestsTreeView.ClearResults}" |
||||
class = "ICSharpCode.MbUnitPad.ClearResultsCommand"/> |
||||
</MenuItem> |
||||
</Path> |
||||
</AddIn> |
@ -1,69 +0,0 @@
@@ -1,69 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.MbUnitPad</RootNamespace> |
||||
<AssemblyName>MbUnitPad</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}</ProjectGuid> |
||||
<ProductVersion>8.0.50215</ProductVersion> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\MbUnitPad\</OutputPath> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\MbUnitPad\</OutputPath> |
||||
<Optimize>true</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="MbUnit.Framework"> |
||||
<HintPath>..\..\..\..\Tools\MbUnit\MbUnit.Framework.dll</HintPath> |
||||
<SpecificVersion>False</SpecificVersion> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="MbUnit.GUI"> |
||||
<HintPath>..\..\..\..\Tools\MbUnit\MbUnit.GUI.exe</HintPath> |
||||
<SpecificVersion>False</SpecificVersion> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="MbUnitPad.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
<Compile Include="Src\MbUnitPad.cs" /> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\MbUnitCommands.cs" /> |
||||
<Compile Include="Src\TestTreeView.cs"> |
||||
<SubType>UserControl</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\MbUnitTestableCondition.cs" /> |
||||
<Compile Include="Src\MbUnitRunningTestsCondition.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj"> |
||||
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project> |
||||
<Name>ICSharpCode.TextEditor</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<LastOpenVersion>8.0.50215</LastOpenVersion> |
||||
</PropertyGroup> |
||||
</Project> |
@ -1,198 +0,0 @@
@@ -1,198 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using MbUnit.Forms; |
||||
|
||||
namespace ICSharpCode.MbUnitPad |
||||
{ |
||||
public class ReloadCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.ReloadAssemblyList(); |
||||
} |
||||
} |
||||
|
||||
public class UnloadCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.RemoveAssemblies(); |
||||
} |
||||
} |
||||
|
||||
public class RunTestsCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.RunTests(); |
||||
} |
||||
} |
||||
|
||||
public class StopTestsCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.StopTests(); |
||||
} |
||||
} |
||||
|
||||
public class AddNUnitReferenceCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
if (ProjectService.CurrentProject != null) { |
||||
ProjectService.AddProjectItem(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "nunit.framework")); |
||||
ProjectService.CurrentProject.Save(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public class AddMbUnitReferenceCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
if (ProjectService.CurrentProject != null) { |
||||
ProjectService.AddProjectItem(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "MbUnit.Framework")); |
||||
ProjectService.CurrentProject.Save(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public class RunTestInPadCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
IMember m = MbUnitTestableCondition.GetMember(Owner); |
||||
IClass c = (m != null) ? m.DeclaringType : MbUnitTestableCondition.GetClass(Owner); |
||||
MessageService.ShowMessage("Not implemented"); |
||||
} |
||||
} |
||||
|
||||
public class RunTestWithDebuggerCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
if (DebuggerService.IsDebuggerLoaded && DebuggerService.CurrentDebugger.IsDebugging) { |
||||
MessageService.ShowMessage("The debugger is currently busy."); |
||||
return; |
||||
} |
||||
IMember m = MbUnitTestableCondition.GetMember(Owner); |
||||
IClass c = (m != null) ? m.DeclaringType : MbUnitTestableCondition.GetClass(Owner); |
||||
if (m != null) { |
||||
MessageService.ShowMessage("Running single tests is not implemented, run the test fixture instead."); |
||||
return; |
||||
} |
||||
IProject project = c.ProjectContent.Project; |
||||
MSBuildEngineCallback callback = delegate(System.CodeDom.Compiler.CompilerResults results) { |
||||
if (results.Errors.Count > 0) { |
||||
return; |
||||
} |
||||
string mbUnitDir = Path.GetDirectoryName(typeof(ReflectorTreeView).Assembly.Location); |
||||
ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(mbUnitDir, "MbUnit.Cons.exe")); |
||||
string assemblyPath = project.OutputAssemblyFullPath; |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.Append("\"/filter-type:" + c.FullyQualifiedName + "\""); |
||||
sb.Append(" \"/assembly-path:" + Path.GetDirectoryName(assemblyPath) + "\""); |
||||
sb.Append(" \"" + assemblyPath + "\""); |
||||
startInfo.Arguments = sb.ToString(); |
||||
startInfo.WorkingDirectory = mbUnitDir; |
||||
LoggingService.Info("Run " + startInfo.FileName + " " + startInfo.Arguments); |
||||
DebuggerService.CurrentDebugger.Start(startInfo); |
||||
}; |
||||
project.Build(callback); |
||||
} |
||||
} |
||||
|
||||
public class GotoDefinitionCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.GotoDefinition(); |
||||
} |
||||
} |
||||
|
||||
public class ExpandAllCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.ExpandAll(); |
||||
} |
||||
} |
||||
|
||||
public class CollapseAllCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.CollapseAll(); |
||||
} |
||||
} |
||||
|
||||
public class ExpandCurrentCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.ExpandChildNode(MbUnitPadContent.Instance.TreeView.SelectedNode); |
||||
} |
||||
} |
||||
|
||||
public class CollapseCurrentCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.CollapseChildNode(MbUnitPadContent.Instance.TreeView.SelectedNode); |
||||
} |
||||
} |
||||
|
||||
public class ExpandAllFailuresCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.ExpandAllFailures(); |
||||
} |
||||
} |
||||
|
||||
public class ExpandCurrentFailuresCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.ExpandCurrentFailures(); |
||||
} |
||||
} |
||||
|
||||
public class ExpandAllIgnoredCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.ExpandAllIgnored(); |
||||
} |
||||
} |
||||
|
||||
public class ExpandCurrentIgnoredCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.ExpandCurrentIgnored(); |
||||
} |
||||
} |
||||
|
||||
public class ClearResultsCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
MbUnitPadContent.Instance.TreeView.ClearAllResults(); |
||||
} |
||||
} |
||||
} |
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.Core; |
||||
using System; |
||||
|
||||
namespace ICSharpCode.MbUnitPad |
||||
{ |
||||
/// <summary>
|
||||
/// Determines whether #develop is currently running MbUnit tests.
|
||||
/// </summary>
|
||||
public class MbUnitRunningTestsCondition : IConditionEvaluator |
||||
{ |
||||
public bool IsValid(object caller, Condition condition) |
||||
{ |
||||
MbUnitPadContent pad = caller as MbUnitPadContent; |
||||
if (pad != null) { |
||||
return pad.IsRunningTests; |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -1,336 +0,0 @@
@@ -1,336 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Reflection; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using MbUnit.Forms; |
||||
using MbUnit.Core; |
||||
using MbUnit.Core.Graph; |
||||
using MbUnit.Core.Remoting; |
||||
using MbUnit.Core.Reports.Serialization; |
||||
|
||||
namespace ICSharpCode.MbUnitPad |
||||
{ |
||||
public class TestTreeView : ReflectorTreeView, IOwnerState |
||||
{ |
||||
Hashtable pipeNodes; |
||||
|
||||
[Flags] |
||||
public enum TestTreeViewState { |
||||
Nothing = 0, |
||||
SourceCodeItemSelected = 1, |
||||
TestItemSelected = 2 |
||||
} |
||||
|
||||
protected TestTreeViewState internalState = TestTreeViewState.Nothing; |
||||
|
||||
public System.Enum InternalState { |
||||
get { |
||||
return internalState; |
||||
} |
||||
} |
||||
|
||||
public TestTreeView() |
||||
{ |
||||
TypeTree.HideSelection = false; |
||||
TypeTree.ContextMenu = null; |
||||
TypeTree.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/MbUnitPad/ContextMenu"); |
||||
TypeTree.MouseDown += TreeViewMouseDown; |
||||
this.StartTests += OnTestsStarted; |
||||
this.FinishTests += delegate { BeginInvoke(new MethodInvoker(ExpandAllFailures)); }; |
||||
this.Facade.Updated += OnFacadeUpdated; |
||||
// I don't see another good way to get a pipe node by GUID but stealing the facade's hashtable
|
||||
pipeNodes = (Hashtable)typeof(TestTreeNodeFacade).InvokeMember("pipeNodes", BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic, null, Facade, null); |
||||
} |
||||
|
||||
public TreeNode SelectedNode { |
||||
get { |
||||
return TypeTree.SelectedNode; |
||||
} |
||||
} |
||||
|
||||
public string SelectedAssemblyFileName { |
||||
get { |
||||
UnitTreeNode node = SelectedNode as UnitTreeNode; |
||||
if (node != null) { |
||||
foreach (TreeTestDomain d in this.TestDomains) { |
||||
if (d.Identifier == node.DomainIdentifier) { |
||||
return d.TestFilePath; |
||||
} |
||||
} |
||||
} |
||||
return String.Empty; |
||||
} |
||||
} |
||||
|
||||
public bool IsPopulated { |
||||
get { |
||||
return TypeTree.Nodes.Count > 0; |
||||
} |
||||
} |
||||
|
||||
public void ExpandChildNode(TreeNode node) |
||||
{ |
||||
TypeTree.BeginUpdate(); |
||||
if (node != null) { |
||||
node.Expand(); |
||||
foreach(TreeNode child in node.Nodes) { |
||||
ExpandChildNode(child); |
||||
} |
||||
} |
||||
TypeTree.EndUpdate(); |
||||
} |
||||
|
||||
public void CollapseChildNode(TreeNode node) |
||||
{ |
||||
TypeTree.BeginUpdate(); |
||||
if (node != null) { |
||||
node.Collapse(); |
||||
foreach(TreeNode child in node.Nodes) { |
||||
CollapseChildNode(child); |
||||
} |
||||
} |
||||
TypeTree.EndUpdate(); |
||||
} |
||||
|
||||
public void ExpandAll() |
||||
{ |
||||
TypeTree.ExpandAll(); |
||||
} |
||||
|
||||
public void CollapseAll() |
||||
{ |
||||
TypeTree.CollapseAll(); |
||||
} |
||||
|
||||
public void GotoDefinition() |
||||
{ |
||||
UnitTreeNode node = SelectedNode as UnitTreeNode; |
||||
if (node != null) { |
||||
string methodName = null; |
||||
string fixtureName = null; |
||||
switch (node.TestNodeType) { |
||||
case TestNodeType.Test: |
||||
methodName = GetTestMethodName(node.Text); |
||||
fixtureName = node.Parent.Text; |
||||
break; |
||||
|
||||
case TestNodeType.Fixture: |
||||
fixtureName = node.Text; |
||||
break; |
||||
} |
||||
|
||||
if (fixtureName != null) { |
||||
List<IClass> fixtures = FindTestFixtures(fixtureName); |
||||
if (fixtures.Count > 0) { |
||||
if (methodName == null) { |
||||
// Go to fixture definition.
|
||||
IClass c = fixtures[0]; |
||||
if (c.CompilationUnit != null) { |
||||
FileService.JumpToFilePosition(c.CompilationUnit.FileName, c.Region.BeginLine - 1, c.Region.BeginColumn - 1); |
||||
} |
||||
} else { |
||||
foreach (IClass c in fixtures) { |
||||
IMethod method = FindTestMethod(c, methodName); |
||||
if (method != null) { |
||||
FileService.JumpToFilePosition(c.CompilationUnit.FileName, method.Region.BeginLine - 1, method.Region.BeginColumn - 1); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
static MessageViewCategory testRunnerCategory; |
||||
|
||||
string GetTestMethodName(string methodName) |
||||
{ |
||||
int index = methodName.IndexOf("."); |
||||
if (index >= 0) { |
||||
return methodName.Substring(index + 1); |
||||
} |
||||
|
||||
return methodName; |
||||
} |
||||
|
||||
void OnTestsStarted(object sender, EventArgs e) |
||||
{ |
||||
BeginInvoke(new EventHandler(OnTestsStartedInvoked)); |
||||
} |
||||
|
||||
void OnTestsStartedInvoked(object sender, EventArgs e) |
||||
{ |
||||
PadDescriptor outputPad = WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)); |
||||
|
||||
if (testRunnerCategory == null) { |
||||
testRunnerCategory = new MessageViewCategory("MbUnit"); |
||||
((CompilerMessageView)outputPad.PadContent).AddCategory(testRunnerCategory); |
||||
} else { |
||||
testRunnerCategory.ClearText(); |
||||
} |
||||
|
||||
outputPad.BringPadToFront(); |
||||
} |
||||
|
||||
void OnFacadeUpdated(ResultEventArgs e) |
||||
{ |
||||
try { |
||||
if (e.State == TestState.Failure) { |
||||
IList list = (IList)pipeNodes[e.PipeIdentifier]; |
||||
for (int i = 0; i < list.Count; i++) { |
||||
UnitTreeNode node = list[i] as UnitTreeNode; |
||||
if (node != null) { |
||||
AppendResult(this.TestDomains.GetResult(node)); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} catch (Exception ex) { |
||||
MessageService.ShowError(ex); |
||||
} |
||||
} |
||||
|
||||
void AppendResult(ReportRun result) |
||||
{ |
||||
ReportException ex = result.Exception; |
||||
string message = (ex != null) ? ex.Message : "-"; |
||||
string outputMessage = StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] { |
||||
{"TestCase", result.Name}, |
||||
{"Message", message} |
||||
}); |
||||
|
||||
testRunnerCategory.AppendText(outputMessage + Environment.NewLine); |
||||
testRunnerCategory.AppendText(result.Description + Environment.NewLine); |
||||
if (ex != null) { |
||||
testRunnerCategory.AppendText(ex.StackTrace + Environment.NewLine); |
||||
|
||||
FileLineReference LineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(ex.StackTrace, true); |
||||
if (LineRef != null) { |
||||
Task task = new Task(Path.GetFullPath(LineRef.FileName), |
||||
outputMessage, |
||||
LineRef.Column, |
||||
LineRef.Line, |
||||
TaskType.Error); |
||||
|
||||
BeginInvoke(new AddTaskInvoker(TaskService.Add), new object[] { task }); |
||||
} |
||||
} |
||||
} |
||||
|
||||
delegate void AddTaskInvoker(Task task); |
||||
|
||||
/// <summary>
|
||||
/// Default MbUnit-GUI doesn't use shadow copy, we have to override that behaviour.
|
||||
/// </summary>
|
||||
public new void AddAssembly(string file) |
||||
{ |
||||
if (this.TestDomains.ContainsTestAssembly(file)) { |
||||
throw new ApplicationException(string.Format("The file {0} is already loaded.", file)); |
||||
} else { |
||||
TreeTestDomain domain = this.TestDomains.Add(file); |
||||
domain.ShadowCopyFiles = true; |
||||
this.TestDomains.Watcher.Start(); |
||||
} |
||||
} |
||||
|
||||
protected override void MessageOnStatusBar(string message, object[] args) |
||||
{ |
||||
if (message.Length == 0) { |
||||
StatusBarService.SetMessage(null); |
||||
} else { |
||||
string msg = string.Format(message, args); |
||||
LoggingService.Debug(msg); |
||||
StatusBarService.SetMessage("MbUnit: " + msg); |
||||
} |
||||
} |
||||
|
||||
void TreeViewMouseDown(object sender, MouseEventArgs e) |
||||
{ |
||||
TreeNode node = TypeTree.GetNodeAt(e.X, e.Y); |
||||
|
||||
TypeTree.SelectedNode = node; |
||||
|
||||
internalState = TestTreeViewState.Nothing; |
||||
if (IsSourceCodeItemSelected) { |
||||
internalState |= TestTreeViewState.SourceCodeItemSelected; |
||||
} |
||||
|
||||
if (IsTestItemSelected) { |
||||
internalState |= TestTreeViewState.TestItemSelected; |
||||
} |
||||
} |
||||
|
||||
bool IsSourceCodeItemSelected { |
||||
get { |
||||
UnitTreeNode node = TypeTree.SelectedNode as UnitTreeNode; |
||||
if (node != null) { |
||||
return (node.TestNodeType == TestNodeType.Test) || (node.TestNodeType == TestNodeType.Fixture); |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
bool IsTestItemSelected { |
||||
get { |
||||
UnitTreeNode node = TypeTree.SelectedNode as UnitTreeNode; |
||||
return node != null; |
||||
} |
||||
} |
||||
|
||||
List<IClass> FindTestFixtures(string name) |
||||
{ |
||||
List<IClass> fixtures = new List<IClass>(); |
||||
if (ProjectService.OpenSolution != null) { |
||||
foreach (IProject project in ProjectService.OpenSolution.Projects) { |
||||
IProjectContent projectContent = ParserService.GetProjectContent(project); |
||||
if (projectContent != null) { |
||||
foreach (IClass c in projectContent.Classes) { |
||||
if (c.Name == name) { |
||||
if (HasAttribute(c.Attributes, "TestFixture")) { |
||||
fixtures.Add(c); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return fixtures; |
||||
} |
||||
|
||||
IMethod FindTestMethod(IClass c, string name) |
||||
{ |
||||
foreach (IMethod method in c.Methods) { |
||||
if (method.Name == name) { |
||||
if (HasAttribute(method.Attributes, "Test")) { |
||||
return method; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
bool HasAttribute(IList<IAttribute> attributes, string name) |
||||
{ |
||||
foreach (IAttribute attr in attributes) { |
||||
if (attr.Name == name) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,102 @@
@@ -0,0 +1,102 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Xml; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.UnitTesting |
||||
{ |
||||
/// <summary>
|
||||
/// Reads the NUnit results file.
|
||||
/// </summary>
|
||||
public class NUnitResults |
||||
{ |
||||
static readonly string TestCaseElementName = "test-case"; |
||||
static readonly string MessageElementName = "message"; |
||||
static readonly string StackTraceElementName= "stack-trace"; |
||||
|
||||
readonly List<Task> tasks = new List<Task>(); |
||||
|
||||
public List<Task> Tasks { |
||||
get { |
||||
return tasks; |
||||
} |
||||
} |
||||
|
||||
public NUnitResults(string fileName) : this(new StreamReader(fileName, true)) |
||||
{ |
||||
} |
||||
|
||||
public NUnitResults(TextReader reader) : this(new XmlTextReader(reader)) |
||||
{ |
||||
} |
||||
|
||||
public NUnitResults(XmlReader reader) |
||||
{ |
||||
using (reader) { |
||||
ReadResults(reader); |
||||
} |
||||
} |
||||
|
||||
void ReadResults(XmlReader reader) |
||||
{ |
||||
while (reader.Read()) { |
||||
if (reader.NodeType == XmlNodeType.Element) { |
||||
if (reader.Name == TestCaseElementName) { |
||||
if (bool.Parse(reader.GetAttribute("executed")) == false) { |
||||
// test was ignored.
|
||||
AddTest(reader, TaskType.Warning, "${res:NUnitPad.NUnitPadContent.TestTreeView.TestNotExecutedMessage}"); |
||||
} else if (bool.Parse(reader.GetAttribute("success")) == false) { |
||||
// test failed.
|
||||
AddTest(reader, TaskType.Error, "${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}"); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void AddTest(XmlReader reader, TaskType type, string message) |
||||
{ |
||||
string testName = reader.GetAttribute("name"); |
||||
string msg, stackTrace; |
||||
GetDescription(reader, out msg, out stackTrace); |
||||
|
||||
message = StringParser.Parse(message, new string[,] { |
||||
{"TestCase", testName}, |
||||
{"Message", msg} |
||||
}); |
||||
Task task = TestTreeView.CreateTask(type, message, testName, stackTrace); |
||||
if (task != null) { |
||||
tasks.Add(task); |
||||
} |
||||
} |
||||
|
||||
void GetDescription(XmlReader reader, out string message, out string stackTrace) |
||||
{ |
||||
message = ""; |
||||
stackTrace = ""; |
||||
while (reader.Read()) { |
||||
if (reader.NodeType == XmlNodeType.Element) { |
||||
if (reader.Name == MessageElementName) { |
||||
message = reader.ReadElementString(); |
||||
} else if (reader.Name == StackTraceElementName) { |
||||
stackTrace = reader.ReadElementString(); |
||||
} |
||||
} else if (reader.NodeType == XmlNodeType.EndElement) { |
||||
if (reader.Name == TestCaseElementName) { |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,100 @@
@@ -0,0 +1,100 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.UnitTesting |
||||
{ |
||||
public abstract class AbstractRunTestCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
IMember m = TestableCondition.GetMember(Owner); |
||||
IClass c = (m != null) ? m.DeclaringType : TestableCondition.GetClass(Owner); |
||||
Run(TestableCondition.GetProject(Owner), c, m); |
||||
} |
||||
|
||||
public void Run(IProject project, IClass fixture, IMember test) |
||||
{ |
||||
if (project == null) { |
||||
throw new ArgumentNullException("project"); |
||||
} |
||||
MSBuildEngineCallback callback = delegate(System.CodeDom.Compiler.CompilerResults results) { |
||||
if (results.Errors.Count > 0) { |
||||
return; |
||||
} |
||||
RunTests(project, fixture, test); |
||||
}; |
||||
project.Build(callback); |
||||
} |
||||
|
||||
protected abstract void RunTests(IProject project, IClass fixture, IMember test); |
||||
} |
||||
|
||||
public class RunTestInPadCommand : AbstractRunTestCommand |
||||
{ |
||||
protected override void RunTests(IProject project, IClass fixture, IMember test) |
||||
{ |
||||
PadContent.BringToFront(); |
||||
PadContent.Instance.RunTest(project, fixture, test); |
||||
} |
||||
} |
||||
|
||||
public class RunTestWithDebuggerCommand : AbstractRunTestCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
if (DebuggerService.IsDebuggerLoaded && DebuggerService.CurrentDebugger.IsDebugging) { |
||||
MessageService.ShowMessage("The debugger is currently busy."); |
||||
} else { |
||||
base.Run(); |
||||
} |
||||
} |
||||
|
||||
static string lastOutputFile; |
||||
|
||||
protected override void RunTests(IProject project, IClass fixture, IMember test) |
||||
{ |
||||
ProcessStartInfo startInfo = new ProcessStartInfo(UnitTestApplicationStartHelper.UnitTestConsoleApplication); |
||||
UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper(); |
||||
helper.Initialize(project, fixture, test); |
||||
helper.XmlOutputFile = Path.GetTempFileName(); |
||||
try { |
||||
File.Delete(helper.XmlOutputFile); |
||||
} catch {} |
||||
lastOutputFile = helper.XmlOutputFile; |
||||
startInfo.Arguments = helper.GetArguments(); |
||||
startInfo.WorkingDirectory = UnitTestApplicationStartHelper.UnitTestApplicationDirectory; |
||||
LoggingService.Info("Run " + startInfo.FileName + " " + startInfo.Arguments); |
||||
|
||||
// register event if it is not already registered
|
||||
DebuggerService.DebugStopped -= DebuggerFinished; |
||||
DebuggerService.DebugStopped += DebuggerFinished; |
||||
DebuggerService.CurrentDebugger.Start(startInfo); |
||||
} |
||||
|
||||
static void DebuggerFinished(object sender, EventArgs e) |
||||
{ |
||||
DebuggerService.DebugStopped -= DebuggerFinished; |
||||
if (lastOutputFile != null) { |
||||
UnitTestApplicationStartHelper.DisplayResults(lastOutputFile); |
||||
try { |
||||
File.Delete(lastOutputFile); |
||||
} catch {} |
||||
lastOutputFile = null; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.Core; |
||||
using System; |
||||
|
||||
namespace ICSharpCode.UnitTesting |
||||
{ |
||||
/// <summary>
|
||||
/// Determines whether #develop is currently running unit tests.
|
||||
/// </summary>
|
||||
public class RunningTestsCondition : IConditionEvaluator |
||||
{ |
||||
public bool IsValid(object caller, Condition condition) |
||||
{ |
||||
// initializing PadContent might call IsValid
|
||||
if (caller is PadContent) |
||||
return ((PadContent)caller).IsRunningTests; |
||||
return PadContent.Instance.IsRunningTests; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Determines whether starting unit tests by calling a command derived from
|
||||
/// AbstractRunTestCommand is possible.
|
||||
/// </summary>
|
||||
public class UnitCommonTestCommandsEnabledCondition : IConditionEvaluator |
||||
{ |
||||
public bool IsValid(object caller, Condition condition) |
||||
{ |
||||
if (PadContent.Instance.IsRunningTests) |
||||
return false; |
||||
TestTreeView view = caller as TestTreeView; |
||||
if (view != null) { |
||||
return view.SelectedProject != null; |
||||
} else { |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,448 @@
@@ -0,0 +1,448 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
using NUnit.Core; |
||||
using NUnit.Framework; |
||||
using NUnit.UiKit; |
||||
using NUnit.Util; |
||||
|
||||
namespace ICSharpCode.UnitTesting |
||||
{ |
||||
public class TestTreeView : TestSuiteTreeView, IOwnerState |
||||
{ |
||||
TestLoader loader = new TestLoader(); |
||||
static MessageViewCategory testRunnerCategory; |
||||
|
||||
[Flags] |
||||
public enum TestTreeViewState { |
||||
Nothing = 0, |
||||
SourceCodeItemSelected = 1, |
||||
TestItemSelected = 2 |
||||
} |
||||
|
||||
System.Enum IOwnerState.InternalState { |
||||
get { |
||||
TestTreeViewState state = TestTreeViewState.Nothing; |
||||
UITestNode test = SelectedTest; |
||||
if (test != null) { |
||||
state |= TestTreeViewState.TestItemSelected; |
||||
if (test.IsTestCase || test.IsFixture) { |
||||
state |= TestTreeViewState.SourceCodeItemSelected; |
||||
} |
||||
} |
||||
return state; |
||||
} |
||||
} |
||||
|
||||
public static MessageViewCategory TestRunnerCategory { |
||||
get { |
||||
if (testRunnerCategory == null) { |
||||
testRunnerCategory = new MessageViewCategory("${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}"); |
||||
CompilerMessageView.Instance.AddCategory(testRunnerCategory); |
||||
} |
||||
return testRunnerCategory; |
||||
} |
||||
} |
||||
|
||||
void OnRunStarting() |
||||
{ |
||||
TaskService.ClearExceptCommentTasks(); |
||||
TestRunnerCategory.ClearText(); |
||||
PadDescriptor outputPad = WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)); |
||||
outputPad.BringPadToFront(); |
||||
} |
||||
|
||||
public TestTreeView() |
||||
{ |
||||
loader.ReloadOnChange = false; |
||||
loader.ReloadOnRun = false; |
||||
loader.Events.TestLoadFailed += delegate(object sender, TestEventArgs e) { |
||||
TestRunnerCategory.AppendText("Loading " + e.Name + " failed: " + e.Exception.ToString()); |
||||
if (e.Exception is InvalidCastException && e.Exception.Message.Contains(typeof(AssemblyResolver).FullName)) { |
||||
MessageService.ShowMessage("Loading tests failed, make sure NUnit.Core is in the Global Assembly Cache."); |
||||
} else { |
||||
MessageService.ShowMessage("Loading " + e.Name + " failed: " + e.Exception.ToString()); |
||||
} |
||||
}; |
||||
loader.Events.TestLoaded += delegate(object sender, TestEventArgs e) { |
||||
WorkbenchSingleton.SafeThreadAsyncCall((MethodInvoker)UpdateProjectTitles); |
||||
}; |
||||
loader.Events.RunStarting += delegate(object sender, TestEventArgs e) { |
||||
WorkbenchSingleton.SafeThreadAsyncCall((MethodInvoker)OnRunStarting); |
||||
}; |
||||
loader.Events.TestOutput += delegate(object sender, TestEventArgs e) { |
||||
// This method interceps StdOut/StdErr from the tests
|
||||
TestRunnerCategory.AppendText(e.TestOutput.Text); |
||||
}; |
||||
loader.Events.TestFinished += delegate(object sender, TestEventArgs e) { |
||||
TestResult result = e.Result; |
||||
if (!result.IsSuccess) { |
||||
string outputMessage = StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] { |
||||
{"TestCase", result.Test.FullName}, |
||||
{"Message", result.Message.Replace("\t", " ").Trim()} |
||||
}); |
||||
|
||||
TestRunnerCategory.AppendText(Environment.NewLine + outputMessage + Environment.NewLine); |
||||
if (!string.IsNullOrEmpty(result.Description)) { |
||||
TestRunnerCategory.AppendText(result.Description + Environment.NewLine); |
||||
} |
||||
TestRunnerCategory.AppendText(result.StackTrace + Environment.NewLine); |
||||
|
||||
AddTask(TaskType.Error, outputMessage, result.Test.FullName, result.StackTrace); |
||||
} else if (!result.Executed) { |
||||
string outputMessage = StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestNotExecutedMessage}", new string[,] { |
||||
{"TestCase", result.Test.FullName} |
||||
}); |
||||
|
||||
testRunnerCategory.AppendText(Environment.NewLine + outputMessage + Environment.NewLine); |
||||
testRunnerCategory.AppendText(result.Message + Environment.NewLine); |
||||
if (!string.IsNullOrEmpty(result.Description)) { |
||||
TestRunnerCategory.AppendText(result.Description + Environment.NewLine); |
||||
} |
||||
testRunnerCategory.AppendText(result.StackTrace + Environment.NewLine); |
||||
|
||||
AddTask(TaskType.Warning, outputMessage, result.Test.FullName, result.StackTrace); |
||||
} |
||||
}; |
||||
Initialize(loader, loader.Events); |
||||
this.ContextMenu = null; |
||||
this.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/UnitTestingPad/ContextMenu"); |
||||
} |
||||
|
||||
void UpdateProjectTitles() |
||||
{ |
||||
if (Nodes.Count == 0) |
||||
return; |
||||
TreeNode root = Nodes[0]; |
||||
root.Text = ProjectService.OpenSolution.Name; |
||||
foreach (TreeNode project in root.Nodes) { |
||||
if (Path.IsPathRooted(project.Text)) { |
||||
project.Text = Path.GetFileNameWithoutExtension(project.Text); |
||||
} |
||||
} |
||||
} |
||||
|
||||
static void AddTask(TaskType type, string message, string fullTestName, string stackTrace) |
||||
{ |
||||
Task task = CreateTask(type, message, fullTestName, stackTrace); |
||||
if (task != null) { |
||||
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", task); |
||||
} |
||||
} |
||||
|
||||
internal static Task CreateTask(TaskType type, string message, string fullTestName, string stackTrace) |
||||
{ |
||||
FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(stackTrace, true); |
||||
if (lineRef == null) { |
||||
lineRef = FindTest(fullTestName); |
||||
} |
||||
if (lineRef != null) { |
||||
return new Task(Path.GetFullPath(lineRef.FileName), |
||||
message, lineRef.Column, lineRef.Line, type); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public void StopTests() |
||||
{ |
||||
loader.CancelTestRun(); |
||||
} |
||||
|
||||
public event TestEventHandler RunStarted { |
||||
add { loader.Events.RunStarting += value; } |
||||
remove { loader.Events.RunStarting -= value; } |
||||
} |
||||
|
||||
public event TestEventHandler RunFinished { |
||||
add { loader.Events.RunFinished += value; } |
||||
remove { loader.Events.RunFinished -= value; } |
||||
} |
||||
|
||||
public bool IsTestRunning { |
||||
get { |
||||
return loader.IsTestRunning; |
||||
} |
||||
} |
||||
|
||||
NUnitProject project; |
||||
|
||||
public void StartAddingAssemblies() |
||||
{ |
||||
project = NUnitProject.NewProject(); |
||||
project.ProjectPath = ProjectService.OpenSolution.Directory; |
||||
// assemblies outside the BasePath cannot be loaded by .NET, so use the root of the drive
|
||||
project.BasePath = Path.GetPathRoot(ProjectService.OpenSolution.Directory); |
||||
} |
||||
|
||||
public void FinishAddingAssemblies() |
||||
{ |
||||
loader.TestProject = project; |
||||
loader.LoadTest(); |
||||
project = null; |
||||
} |
||||
|
||||
public void AddAssembly(IProject sdProject, string assemblyFile) |
||||
{ |
||||
if (!File.Exists(assemblyFile)) { |
||||
TestRunnerCategory.AppendText(assemblyFile + " does not exist."); |
||||
return; |
||||
} |
||||
|
||||
#if DEBUG
|
||||
// NUnit uses cross thread calls.......
|
||||
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; |
||||
#endif
|
||||
|
||||
if (project != null) { |
||||
project.ActiveConfig.Assemblies.Add(assemblyFile); |
||||
} else { |
||||
if (!loader.IsProjectLoaded) { |
||||
StartAddingAssemblies(); |
||||
loader.TestProject = project; |
||||
project = null; |
||||
} |
||||
|
||||
loader.TestProject.ActiveConfig.Assemblies.Add(assemblyFile); |
||||
} |
||||
} |
||||
|
||||
public void UnloadTestAssemblies() |
||||
{ |
||||
if (loader.IsProjectLoaded) { |
||||
loader.UnloadProject(); |
||||
} |
||||
} |
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e) |
||||
{ |
||||
if (e.Button == MouseButtons.Right) { |
||||
// required to run context menu commands on the correct item:
|
||||
this.SelectedNode = GetNodeAt(e.Location); |
||||
} |
||||
base.OnMouseDown(e); |
||||
} |
||||
|
||||
protected override void OnKeyPress(KeyPressEventArgs e) |
||||
{ |
||||
if (e.KeyChar == '\r') { |
||||
e.Handled = true; |
||||
GotoDefinition(); |
||||
} else if (e.KeyChar == ' ') { |
||||
e.Handled = true; |
||||
RunTests(); |
||||
} else { |
||||
base.OnKeyPress(e); |
||||
} |
||||
} |
||||
|
||||
public void SelectTest(IProject project, IClass fixture, IMember test) |
||||
{ |
||||
if (Nodes.Count == 0) { |
||||
return; |
||||
} |
||||
TreeNode root = Nodes[0]; |
||||
TreeNode nodeToSelect = null; |
||||
foreach (TreeNode projectNode in root.Nodes) { |
||||
if (projectNode.Text == project.Name) { |
||||
nodeToSelect = projectNode; |
||||
break; |
||||
} |
||||
} |
||||
if (nodeToSelect != null && fixture != null) { |
||||
// find fixture node
|
||||
TestSuiteTreeNode node = FindTest(nodeToSelect, fixture); |
||||
if (node != null) { |
||||
nodeToSelect = node; |
||||
if (test != null) { |
||||
node = FindTest(node, test); |
||||
if (node != null) { |
||||
nodeToSelect = node; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
this.SelectedNode = nodeToSelect; |
||||
} |
||||
|
||||
TestSuiteTreeNode FindTest(TestSuiteTreeNode fixtureNode, IMember test) |
||||
{ |
||||
foreach (TestSuiteTreeNode node in fixtureNode.Nodes) { |
||||
if (node.Text == test.Name) |
||||
return node; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
TestSuiteTreeNode FindTest(TreeNode projectNode, IClass fixture) |
||||
{ |
||||
foreach (TreeNode node in projectNode.Nodes) { |
||||
TestSuiteTreeNode testNode = node as TestSuiteTreeNode; |
||||
if (testNode != null) { |
||||
if (testNode.Test.IsFixture) { |
||||
if (testNode.Test.FullName == fixture.FullyQualifiedName) |
||||
return testNode; |
||||
} else { |
||||
testNode = FindTest(testNode, fixture); |
||||
if (testNode != null) |
||||
return testNode; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public new void RunTests() |
||||
{ |
||||
if (Nodes.Count > 0) { |
||||
base.RunTests(); |
||||
} |
||||
} |
||||
|
||||
protected override void OnDoubleClick(EventArgs e) |
||||
{ |
||||
GotoDefinition(); |
||||
} |
||||
|
||||
public void GotoDefinition() |
||||
{ |
||||
UITestNode node = SelectedTest; |
||||
if (node != null) { |
||||
FileLineReference lr = null; |
||||
if (node.IsFixture) { |
||||
lr = FindTest(node.FullName, null); |
||||
} else if (node.IsTestCase) { |
||||
lr = FindTest(node.FullName); |
||||
} |
||||
if (lr != null) { |
||||
FileService.JumpToFilePosition(lr.FileName, lr.Line, lr.Column); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public IProject SelectedProject { |
||||
get { |
||||
IClass fixture = SelectedFixtureClass; |
||||
if (fixture != null) |
||||
return fixture.ProjectContent.Project; |
||||
TreeNode node = SelectedNode; |
||||
if (node == null) |
||||
return null; |
||||
if (node.Level == 0 && node.Nodes.Count == 1) { |
||||
// solution node clicked, but has only 1 project
|
||||
node = node.Nodes[0]; |
||||
} |
||||
if (node.Level == 2 && node.Parent.Nodes.Count == 1) { |
||||
// namespace node clicked, but project has only 1 namespace
|
||||
node = node.Parent; |
||||
} |
||||
if (node.Level == 1) { |
||||
foreach (IProject p in ProjectService.OpenSolution.Projects) { |
||||
if (p.Name == node.Text) { |
||||
return p; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public IClass SelectedFixtureClass { |
||||
get { |
||||
IMember member = SelectedTestMethod; |
||||
if (member != null) |
||||
return member.DeclaringType; |
||||
UITestNode node = SelectedTest; |
||||
if (node != null && node.IsFixture) { |
||||
foreach (IClass fixture in FindTestFixtures(node.FullName)) { |
||||
return fixture; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public IMember SelectedTestMethod { |
||||
get { |
||||
UITestNode node = SelectedTest; |
||||
if (node != null && node.IsTestCase) { |
||||
string fullMethodName = node.FullName; |
||||
int pos = fullMethodName.LastIndexOf('.'); |
||||
string shortName = fullMethodName.Substring(pos + 1); |
||||
foreach (IClass fixture in FindTestFixtures(fullMethodName.Substring(0, pos))) { |
||||
IMember m = FindTestMethod(fixture, shortName); |
||||
if (m != null) |
||||
return m; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
static FileLineReference FindTest(string fullMethodName) |
||||
{ |
||||
int pos = fullMethodName.LastIndexOf('.'); |
||||
return FindTest(fullMethodName.Substring(0, pos), fullMethodName.Substring(pos + 1)); |
||||
} |
||||
|
||||
static FileLineReference FindTest(string fixtureName, string methodName) |
||||
{ |
||||
if (fixtureName != null) { |
||||
List<IClass> fixtures = FindTestFixtures(fixtureName); |
||||
if (fixtures.Count > 0) { |
||||
if (methodName == null) { |
||||
// Go to fixture definition.
|
||||
IClass c = fixtures[0]; |
||||
if (c.CompilationUnit != null) { |
||||
return new FileLineReference(c.CompilationUnit.FileName, c.Region.BeginLine - 1, c.Region.BeginColumn - 1); |
||||
} |
||||
} else { |
||||
foreach (IClass c in fixtures) { |
||||
IMethod method = FindTestMethod(c, methodName); |
||||
if (method != null) { |
||||
return new FileLineReference(c.CompilationUnit.FileName, method.Region.BeginLine - 1, method.Region.BeginColumn - 1); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
static List<IClass> FindTestFixtures(string fullName) |
||||
{ |
||||
List<IClass> fixtures = new List<IClass>(); |
||||
if (ProjectService.OpenSolution != null) { |
||||
foreach (IProject project in ProjectService.OpenSolution.Projects) { |
||||
IProjectContent projectContent = ParserService.GetProjectContent(project); |
||||
if (projectContent != null) { |
||||
IClass c = projectContent.GetClass(fullName, 0, projectContent.Language, false); |
||||
if (c != null) { |
||||
fixtures.Add(c); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return fixtures; |
||||
} |
||||
|
||||
static IMethod FindTestMethod(IClass c, string name) |
||||
{ |
||||
return c.Methods.Find(delegate(IMethod m) { return m.Name == name; }); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,151 @@
@@ -0,0 +1,151 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.UnitTesting |
||||
{ |
||||
/// <summary>
|
||||
/// Helper to run the unit testing console application.
|
||||
/// </summary>
|
||||
public class UnitTestApplicationStartHelper |
||||
{ |
||||
/// <summary>
|
||||
/// returns full/path/to/Tools/NUnit
|
||||
/// </summary>
|
||||
public static string UnitTestApplicationDirectory { |
||||
get { |
||||
return Path.Combine(FileUtility.ApplicationRootPath, "bin/Tools/NUnit"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// returns full/path/to/Tools/NUnit/nunit-console.exe
|
||||
/// </summary>
|
||||
public static string UnitTestConsoleApplication { |
||||
get { |
||||
return Path.Combine(UnitTestApplicationDirectory, "nunit-console.exe"); |
||||
} |
||||
} |
||||
|
||||
public readonly List<string> Assemblies = new List<string>(); |
||||
|
||||
/// <summary>
|
||||
/// Use shadow copy assemblies. Default = true.
|
||||
/// </summary>
|
||||
public bool ShadowCopy = true; |
||||
|
||||
/// <summary>
|
||||
/// Run tests on separate thread. Default = false.
|
||||
/// </summary>
|
||||
public bool Threaded = false; |
||||
|
||||
/// <summary>
|
||||
/// Use /nologo directive.
|
||||
/// </summary>
|
||||
public bool NoLogo = false; |
||||
|
||||
/// <summary>
|
||||
/// File to write xml output to. Default = null.
|
||||
/// </summary>
|
||||
public string XmlOutputFile; |
||||
|
||||
/// <summary>
|
||||
/// Fixture to test. Null = test all fixtures.
|
||||
/// </summary>
|
||||
public string Fixture; |
||||
|
||||
/// <summary>
|
||||
/// Test to run. Null = run all tests. Only valid together with the Fixture property.
|
||||
/// </summary>
|
||||
public string Test; |
||||
|
||||
public void Initialize(IProject project, IClass fixture, IMember test) |
||||
{ |
||||
Assemblies.Add(project.OutputAssemblyFullPath); |
||||
if (fixture != null) { |
||||
Fixture = fixture.FullyQualifiedName; |
||||
if (test != null) { |
||||
Test = test.Name; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the arguments to use on the command line to run NUnit.
|
||||
/// </summary>
|
||||
public string GetArguments() |
||||
{ |
||||
StringBuilder b = new StringBuilder(); |
||||
foreach (string assembly in Assemblies) { |
||||
if (b.Length > 0) |
||||
b.Append(' '); |
||||
b.Append('"'); |
||||
b.Append(assembly); |
||||
b.Append('"'); |
||||
} |
||||
if (!ShadowCopy) |
||||
b.Append(" /noshadow"); |
||||
if (Threaded) |
||||
b.Append(" /thread"); |
||||
if (NoLogo) |
||||
b.Append(" /nologo"); |
||||
if (XmlOutputFile != null) { |
||||
b.Append(" /xml=\""); |
||||
b.Append(XmlOutputFile); |
||||
b.Append('"'); |
||||
} |
||||
if (Fixture != null) { |
||||
b.Append(" /fixture=\""); |
||||
b.Append(Fixture); |
||||
b.Append('"'); |
||||
if (Test != null) { |
||||
b.Append(" /testMethodName=\""); |
||||
b.Append(Fixture); |
||||
b.Append('.'); |
||||
b.Append(Test); |
||||
b.Append('"'); |
||||
} |
||||
} |
||||
return b.ToString(); |
||||
} |
||||
|
||||
public void DisplayResults() |
||||
{ |
||||
DisplayResults(XmlOutputFile); |
||||
} |
||||
|
||||
public static void DisplayResults(string resultFile) |
||||
{ |
||||
if (resultFile == null) |
||||
throw new ArgumentNullException("resultFile"); |
||||
|
||||
if (!File.Exists(resultFile)) { |
||||
Task task = new Task("", "No NUnit results file generated: " + resultFile, 0, 0, TaskType.Error); |
||||
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", task); |
||||
return; |
||||
} |
||||
|
||||
try { |
||||
NUnitResults results = new NUnitResults(resultFile); |
||||
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "AddRange", results.Tasks); |
||||
} catch (System.Xml.XmlException ex) { |
||||
Task task = new Task(resultFile, "Invalid NUnit results file: " + ex.Message, ex.LineNumber, ex.LinePosition, TaskType.Error); |
||||
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", task); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,96 @@
@@ -0,0 +1,96 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.UnitTesting |
||||
{ |
||||
public class ReloadCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
PadContent.Instance.ReloadAssemblyList(null); |
||||
} |
||||
} |
||||
|
||||
public class UnloadCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
PadContent.Instance.UnloadTests(); |
||||
} |
||||
} |
||||
|
||||
public class RunTestsCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
PadContent.Instance.RunTests(); |
||||
} |
||||
} |
||||
|
||||
public class StopTestsCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
PadContent.Instance.StopTests(); |
||||
} |
||||
} |
||||
|
||||
public class AddNUnitReferenceCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
if (ProjectService.CurrentProject != null) { |
||||
ProjectService.AddProjectItem(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "nunit.framework")); |
||||
ProjectService.CurrentProject.Save(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public class AddMbUnitReferenceCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
if (ProjectService.CurrentProject != null) { |
||||
ProjectService.AddProjectItem(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "MbUnit.Framework")); |
||||
ProjectService.CurrentProject.Save(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public class GotoDefinitionCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
PadContent.Instance.TreeView.GotoDefinition(); |
||||
} |
||||
} |
||||
|
||||
public class ExpandAllCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
PadContent.Instance.TreeView.ExpandAll(); |
||||
} |
||||
} |
||||
|
||||
public class CollapseAllCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
PadContent.Instance.TreeView.CollapseAll(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,187 @@
@@ -0,0 +1,187 @@
|
||||
<AddIn name = "UnitTesting-Addin" |
||||
author = "Daniel Grunwald" |
||||
copyright = "prj:///doc/copyright.txt" |
||||
description = "Runs NUnit tests inside #Develop"> |
||||
|
||||
<Manifest> |
||||
<Identity name = "ICSharpCode.UnitTesting"/> |
||||
</Manifest> |
||||
|
||||
<Runtime> |
||||
<!-- NUnit is not in the path, so we need to load it manually --> |
||||
<Import assembly = "../../../../bin/Tools/NUnit/NUnit.Util.dll"/> |
||||
<Import assembly = "../../../../bin/Tools/NUnit/NUnit.UIKit.dll"/> |
||||
<Import assembly = "UnitTesting.dll"> |
||||
<ConditionEvaluator name = "UnitTestable" class = "ICSharpCode.UnitTesting.TestableCondition"/> |
||||
<ConditionEvaluator name = "UnitRunningTests" class = "ICSharpCode.UnitTesting.RunningTestsCondition"/> |
||||
<ConditionEvaluator name = "UnitCommonTestCommandsEnabled" class = "ICSharpCode.UnitTesting.UnitCommonTestCommandsEnabledCondition"/> |
||||
</Import> |
||||
</Runtime> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/Pads"> |
||||
<Pad id = "UnitTestingPad" |
||||
category = "Tools" |
||||
title = "${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}" |
||||
icon = "PadIcons.NUnitTest" |
||||
shortcut = "Control|Alt|T" |
||||
class = "ICSharpCode.UnitTesting.PadContent"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassMemberContextMenu"> |
||||
<Include id = "UnitTests" insertbefore = "MenuBuilder" item="/SharpDevelop/Pads/ClassBrowser/MemberContextMenu/UnitTestMenu"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassBookmarkContextMenu"> |
||||
<Include id = "UnitTests" insertbefore = "MenuBuilder" item="/SharpDevelop/Pads/ClassBrowser/ClassContextMenu/UnitTestMenu"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Pads/ClassBrowser/MemberContextMenu"> |
||||
<Condition name = "UnitTestable"> |
||||
<MenuItem id="UnitTestMenu" type="Menu" label="Unit Testing" icon="PadIcons.NUnitTest" insertbefore="MenuBuilder"> |
||||
<Condition name="UnitCommonTestCommandsEnabled" action="Disable"> |
||||
<MenuItem id = "RunInPad" |
||||
label = "${res:ICSharpCode.UnitTesting.RunInTestPad}" |
||||
icon = "PadIcons.NUnitTest" |
||||
class = "ICSharpCode.UnitTesting.RunTestInPadCommand"/> |
||||
</Condition> |
||||
<Include id = "CommonTestCommands" path = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands"/> |
||||
</MenuItem> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Pads/ClassBrowser/ClassContextMenu"> |
||||
<Condition name = "UnitTestable"> |
||||
<MenuItem id="UnitTestMenu" type="Menu" label="Unit Testing" icon="PadIcons.NUnitTest" insertbefore="MenuBuilder"> |
||||
<Condition name="UnitCommonTestCommandsEnabled" action="Disable"> |
||||
<MenuItem id = "RunInPad" |
||||
label = "${res:ICSharpCode.UnitTesting.RunInTestPad}" |
||||
icon = "PadIcons.NUnitTest" |
||||
class = "ICSharpCode.UnitTesting.RunTestInPadCommand"/> |
||||
</Condition> |
||||
<Include id = "CommonTestCommands" path = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands"/> |
||||
</MenuItem> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
|
||||
<Path name = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands"> |
||||
<Condition name="UnitCommonTestCommandsEnabled" action="Disable"> |
||||
<MenuItem id = "RunWithDebugger" |
||||
label = "${res:ICSharpCode.UnitTesting.RunWithDebugger}" |
||||
icon = "Icons.16x16.RunProgramIcon" |
||||
class = "ICSharpCode.UnitTesting.RunTestWithDebuggerCommand"/> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Pads/UnitTestingPad/Toolbar"> |
||||
<Condition name = "SolutionOpen" action="Disable"> |
||||
<ToolbarItem id = "Reload" |
||||
icon = "Icons.16x16.BrowserRefresh" |
||||
tooltip = "${res:NUnitPad.NUnitPadContent.RefreshItem}" |
||||
class = "ICSharpCode.UnitTesting.ReloadCommand"/> |
||||
<ToolbarItem id = "Unload" |
||||
icon = "Icons.16x16.BrowserCancel" |
||||
tooltip = "${res:NUnitPad.NUnitPadContent.CancelItem}" |
||||
class = "ICSharpCode.UnitTesting.UnloadCommand"/> |
||||
<ToolbarItem id = "Separator1" type = "Separator"/> |
||||
<!--<ToolbarItem id = "AddMbUnitReference" |
||||
icon = "Icons.16x16.Reference" |
||||
tooltip = "${res:MbUnitPad.ReferenceItem}" |
||||
class = "ICSharpCode.MbUnitPad.AddMbUnitReferenceCommand"/>--> |
||||
<ToolbarItem id = "AddNUnitReference" |
||||
icon = "Icons.16x16.Reference" |
||||
tooltip = "${res:NUnitPad.NUnitPadContent.ReferenceItem}" |
||||
class = "ICSharpCode.UnitTesting.AddNUnitReferenceCommand"/> |
||||
<ToolbarItem id = "Separator2" type = "Separator"/> |
||||
</Condition> |
||||
<ComplexCondition action="Disable"> |
||||
<And> |
||||
<Condition name="SolutionOpen"/> |
||||
<Not> |
||||
<Condition name="UnitRunningTests"/> |
||||
</Not> |
||||
</And> |
||||
<ToolbarItem id = "Run" |
||||
icon = "Icons.16x16.RunProgramIcon" |
||||
tooltip = "${res:NUnitPad.NUnitPadContent.RunItem}" |
||||
class = "ICSharpCode.UnitTesting.RunTestsCommand"/> |
||||
</ComplexCondition> |
||||
<ComplexCondition action="Disable"> |
||||
<And> |
||||
<Condition name="SolutionOpen"/> |
||||
<Condition name="UnitRunningTests"/> |
||||
</And> |
||||
<ToolbarItem id = "Stop" |
||||
icon = "Icons.16x16.Debug.StopProcess" |
||||
tooltip = "${res:NUnitPad.NUnitPadContent.StopTests}" |
||||
class = "ICSharpCode.UnitTesting.StopTestsCommand"/> |
||||
</ComplexCondition> |
||||
</Path> |
||||
<Path name = "/SharpDevelop/Pads/UnitTestingPad/ContextMenu"> |
||||
<ComplexCondition action="Disable"> |
||||
<And> |
||||
<Condition name="Ownerstate" ownerstate="TestItemSelected"/> |
||||
<Not> |
||||
<Condition name="UnitRunningTests"/> |
||||
</Not> |
||||
</And> |
||||
<MenuItem id = "Run" |
||||
icon = "Icons.16x16.RunProgramIcon" |
||||
label = "${res:NUnitPad.NUnitPadContent.RunTestsContextMenuLabel}" |
||||
class = "ICSharpCode.UnitTesting.RunTestsCommand"/> |
||||
</ComplexCondition> |
||||
<Include id = "CommonTestCommands" path = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands"/> |
||||
<ComplexCondition action="Disable"> |
||||
<And> |
||||
<Condition name="Ownerstate" ownerstate="TestItemSelected"/> |
||||
<Condition name="UnitRunningTests"/> |
||||
</And> |
||||
<MenuItem id = "Stop" |
||||
icon = "Icons.16x16.Debug.StopProcess" |
||||
label = "${res:NUnitPad.NUnitPadContent.StopTests}" |
||||
class = "ICSharpCode.UnitTesting.StopTestsCommand"/> |
||||
</ComplexCondition> |
||||
<Condition name="Ownerstate" ownerstate="SourceCodeItemSelected" action="Disable"> |
||||
<MenuItem id = "GotoDefinition" |
||||
label = "${res:NUnitPad.NUnitPadContent.GotoDefinitionContextMenuLabel}" |
||||
class = "ICSharpCode.UnitTesting.GotoDefinitionCommand"/> |
||||
</Condition> |
||||
<!--<MenuItem id="Tree" |
||||
label="${res:MainWindow.Windows.UnitTestsTreeView.TreeMenu}" |
||||
type="Menu">--> |
||||
<MenuItem id="Separator0" type = "Separator"/> |
||||
<MenuItem id = "ExpandAll" |
||||
label = "${res:MainWindow.Windows.SearchResultPanel.ExpandAll.ToolTip}" |
||||
class = "ICSharpCode.UnitTesting.ExpandAllCommand"/> |
||||
<MenuItem id = "CollapseAll" |
||||
label = "${res:MainWindow.Windows.SearchResultPanel.CollapseAll.ToolTip}" |
||||
class = "ICSharpCode.UnitTesting.CollapseAllCommand"/> |
||||
<!-- |
||||
<MenuItem id="Separator1" type = "Separator"/> |
||||
<MenuItem id = "ExpandCurrent" |
||||
label = "${res:MainWindow.Windows.TreeView.ExpandCurrent}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandCurrentCommand"/> |
||||
<MenuItem id = "CollapseCurrent" |
||||
label = "${res:MainWindow.Windows.TreeView.CollapseCurrent}" |
||||
class = "ICSharpCode.MbUnitPad.CollapseCurrentCommand"/> |
||||
<MenuItem id="Separator2" type = "Separator"/> |
||||
<MenuItem id = "ExpandAllFailures" |
||||
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandAllFailures}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandAllFailuresCommand"/> |
||||
<MenuItem id = "ExpandCurrentFailures" |
||||
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandCurrentFailures}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandCurrentFailuresCommand"/> |
||||
<MenuItem id="Separator3" type = "Separator"/> |
||||
<MenuItem id = "ExpandAllIgnored" |
||||
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandAllIgnoredTests}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandAllIgnoredCommand"/> |
||||
<MenuItem id = "ExpandCurrentIgnored" |
||||
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandCurrentIgnoredTests}" |
||||
class = "ICSharpCode.MbUnitPad.ExpandCurrentIgnoredCommand"/> |
||||
<MenuItem id="Separator4" type = "Separator"/> |
||||
<MenuItem id = "ClearResults" |
||||
label = "${res:MainWindow.Windows.UnitTestsTreeView.ClearResults}" |
||||
class = "ICSharpCode.MbUnitPad.ClearResultsCommand"/> |
||||
</MenuItem>--> |
||||
</Path> |
||||
</AddIn> |
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.UnitTesting</RootNamespace> |
||||
<AssemblyName>UnitTesting</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{1F261725-6318-4434-A1B1-6C70CE4CD324}</ProjectGuid> |
||||
<OutputPath>..\..\..\..\AddIns\AddIns\Misc\UnitTesting\</OutputPath> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<Optimize>True</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="nunit.uikit"> |
||||
<HintPath>..\..\..\Tools\NUnit\nunit.uikit.dll</HintPath> |
||||
<SpecificVersion>False</SpecificVersion> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="nunit.core"> |
||||
<HintPath>..\..\..\Tools\NUnit\nunit.core.dll</HintPath> |
||||
<SpecificVersion>False</SpecificVersion> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="nunit.framework"> |
||||
<HintPath>..\..\..\Tools\NUnit\nunit.framework.dll</HintPath> |
||||
<SpecificVersion>False</SpecificVersion> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="nunit.util"> |
||||
<HintPath>..\..\..\Tools\NUnit\nunit.util.dll</HintPath> |
||||
<SpecificVersion>False</SpecificVersion> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="UnitTesting.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\UnitTestCommands.cs" /> |
||||
<Compile Include="Src\TestableCondition.cs" /> |
||||
<Compile Include="Src\RunningTestsCondition.cs" /> |
||||
<Compile Include="Src\PadContent.cs" /> |
||||
<Compile Include="Src\TestTreeView.cs" /> |
||||
<Compile Include="Src\UnitTestApplicationStartHelper.cs" /> |
||||
<Compile Include="Src\NUnitResults.cs" /> |
||||
<Compile Include="Src\RunTestCommands.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj"> |
||||
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project> |
||||
<Name>ICSharpCode.TextEditor</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -1,80 +0,0 @@
@@ -1,80 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// AbstractAsserter is the base class for all asserters.
|
||||
/// Asserters encapsulate a condition test and generation
|
||||
/// of an AssertionException with a tailored message. They
|
||||
/// are used by the Assert class as helper objects.
|
||||
///
|
||||
/// User-defined asserters may be passed to the
|
||||
/// Assert.DoAssert method in order to implement
|
||||
/// extended asserts.
|
||||
/// </summary>
|
||||
public abstract class AbstractAsserter : IAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// The user-defined message for this asserter.
|
||||
/// </summary>
|
||||
protected readonly string userMessage; |
||||
|
||||
/// <summary>
|
||||
/// Arguments to use in formatting the user-defined message.
|
||||
/// </summary>
|
||||
protected readonly object[] args; |
||||
|
||||
/// <summary>
|
||||
/// Our failure message object, initialized as needed
|
||||
/// </summary>
|
||||
private AssertionFailureMessage failureMessage; |
||||
|
||||
/// <summary>
|
||||
/// Constructs an AbstractAsserter
|
||||
/// </summary>
|
||||
/// <param name="message">The message issued upon failure</param>
|
||||
/// <param name="args">Arguments to be used in formatting the message</param>
|
||||
public AbstractAsserter( string message, params object[] args ) |
||||
{ |
||||
this.userMessage = message; |
||||
this.args = args; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// AssertionFailureMessage object used internally
|
||||
/// </summary>
|
||||
protected AssertionFailureMessage FailureMessage |
||||
{ |
||||
get |
||||
{ |
||||
if ( failureMessage == null ) |
||||
failureMessage = new AssertionFailureMessage( userMessage, args ); |
||||
return failureMessage; |
||||
} |
||||
} |
||||
|
||||
#region IAsserter Interface
|
||||
/// <summary>
|
||||
/// Test method to be implemented by derived types.
|
||||
/// Default always succeeds.
|
||||
/// </summary>
|
||||
/// <returns>True if the test succeeds</returns>
|
||||
public virtual bool Test() |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Message related to a failure. If no failure has
|
||||
/// occured, the result is unspecified.
|
||||
/// </summary>
|
||||
public virtual string Message |
||||
{ |
||||
get |
||||
{ |
||||
return FailureMessage.ToString(); |
||||
} |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
using System; |
||||
using System.Reflection; |
||||
|
||||
[assembly: CLSCompliant(true)] |
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,190 +0,0 @@
@@ -1,190 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
|
||||
/// <summary>A set of Assert methods.</summary>
|
||||
///
|
||||
[Obsolete("Use Assert class instead")] |
||||
public class Assertion |
||||
{ |
||||
/// <summary>
|
||||
/// Asserts that a condition is true. If it isn't it throws
|
||||
/// an <see cref="AssertionException"/>.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to display is the condition
|
||||
/// is false</param>
|
||||
/// <param name="condition">The evaluated condition</param>
|
||||
static public void Assert(string message, bool condition) |
||||
{ |
||||
NUnit.Framework.Assert.IsTrue(condition, message); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Asserts that a condition is true. If it isn't it throws
|
||||
/// an <see cref="AssertionException"/>.
|
||||
/// </summary>
|
||||
/// <param name="condition">The evaluated condition</param>
|
||||
static public void Assert(bool condition) |
||||
{ |
||||
Assertion.Assert(string.Empty, condition); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// /// Asserts that two doubles are equal concerning a delta. If the
|
||||
/// expected value is infinity then the delta value is ignored.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="delta">The maximum acceptable difference between the
|
||||
/// the expected and the actual</param>
|
||||
static public void AssertEquals(double expected, double actual, double delta) |
||||
{ |
||||
Assertion.AssertEquals(string.Empty, expected, actual, delta); |
||||
} |
||||
/// <summary>
|
||||
/// /// Asserts that two singles are equal concerning a delta. If the
|
||||
/// expected value is infinity then the delta value is ignored.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="delta">The maximum acceptable difference between the
|
||||
/// the expected and the actual</param>
|
||||
static public void AssertEquals(float expected, float actual, float delta) |
||||
{ |
||||
Assertion.AssertEquals(string.Empty, expected, actual, delta); |
||||
} |
||||
|
||||
/// <summary>Asserts that two objects are equal. If they are not
|
||||
/// an <see cref="AssertionException"/> is thrown.</summary>
|
||||
static public void AssertEquals(Object expected, Object actual) |
||||
{ |
||||
Assertion.AssertEquals(string.Empty, expected, actual); |
||||
} |
||||
|
||||
/// <summary>Asserts that two ints are equal. If they are not
|
||||
/// an <see cref="AssertionException"/> is thrown.</summary>
|
||||
static public void AssertEquals(int expected, int actual) |
||||
{ |
||||
Assertion.AssertEquals(string.Empty, expected, actual); |
||||
} |
||||
|
||||
/// <summary>Asserts that two ints are equal. If they are not
|
||||
/// an <see cref="AssertionException"/> is thrown.</summary>
|
||||
static public void AssertEquals(string message, int expected, int actual) |
||||
{ |
||||
NUnit.Framework.Assert.AreEqual(expected, actual, message); |
||||
} |
||||
|
||||
/// <summary>Asserts that two doubles are equal concerning a delta.
|
||||
/// If the expected value is infinity then the delta value is ignored.
|
||||
/// </summary>
|
||||
static public void AssertEquals(string message, double expected, |
||||
double actual, double delta) |
||||
{ |
||||
NUnit.Framework.Assert.AreEqual(expected, actual, delta, message); |
||||
} |
||||
|
||||
/// <summary>Asserts that two floats are equal concerning a delta.
|
||||
/// If the expected value is infinity then the delta value is ignored.
|
||||
/// </summary>
|
||||
static public void AssertEquals(string message, float expected, |
||||
float actual, float delta) |
||||
{ |
||||
NUnit.Framework.Assert.AreEqual(expected, actual, delta, message); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Asserts that two objects are equal. Two objects are considered
|
||||
/// equal if both are null, or if both have the same value. Numeric
|
||||
/// types are compared via string comparision on their contents to
|
||||
/// avoid problems comparing values between different types. All
|
||||
/// non-numeric types are compared by using the <c>Equals</c> method.
|
||||
/// If they are not equal an <see cref="AssertionException"/> is thrown.
|
||||
/// </summary>
|
||||
static public void AssertEquals(string message, Object expected, Object actual) |
||||
{ |
||||
NUnit.Framework.Assert.AreEqual(expected, actual, message); |
||||
} |
||||
|
||||
/// <summary>Asserts that an object isn't null.</summary>
|
||||
static public void AssertNotNull(Object anObject) |
||||
{ |
||||
NUnit.Framework.Assert.IsNotNull(anObject, string.Empty); |
||||
} |
||||
|
||||
/// <summary>Asserts that an object isn't null.</summary>
|
||||
static public void AssertNotNull(string message, Object anObject) |
||||
{ |
||||
NUnit.Framework.Assert.IsNotNull(anObject, message); |
||||
} |
||||
|
||||
/// <summary>Asserts that an object is null.</summary>
|
||||
static public void AssertNull(Object anObject) |
||||
{ |
||||
NUnit.Framework.Assert.IsNull(anObject, string.Empty); |
||||
} |
||||
|
||||
/// <summary>Asserts that an object is null.</summary>
|
||||
static public void AssertNull(string message, Object anObject) |
||||
{ |
||||
NUnit.Framework.Assert.IsNull(anObject, message); |
||||
} |
||||
|
||||
/// <summary>Asserts that two objects refer to the same object. If they
|
||||
/// are not the same an <see cref="AssertionException"/> is thrown.
|
||||
/// </summary>
|
||||
static public void AssertSame(Object expected, Object actual) |
||||
{ |
||||
NUnit.Framework.Assert.AreSame(expected, actual, string.Empty); |
||||
} |
||||
|
||||
/// <summary>Asserts that two objects refer to the same object.
|
||||
/// If they are not an <see cref="AssertionException"/> is thrown.
|
||||
/// </summary>
|
||||
static public void AssertSame(string message, Object expected, Object actual) |
||||
{ |
||||
NUnit.Framework.Assert.AreSame(expected, actual, message); |
||||
} |
||||
|
||||
/// <summary>Fails a test with no message.</summary>
|
||||
static public void Fail() |
||||
{ |
||||
NUnit.Framework.Assert.Fail(); |
||||
} |
||||
|
||||
/// <summary>Fails a test with the given message.</summary>
|
||||
static public void Fail(string message) |
||||
{ |
||||
NUnit.Framework.Assert.Fail(message); |
||||
} |
||||
} |
||||
} |
@ -1,68 +0,0 @@
@@ -1,68 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
using System.Runtime.Serialization; |
||||
|
||||
/// <summary>
|
||||
/// Thrown when an assertion failed.
|
||||
/// </summary>
|
||||
///
|
||||
[Serializable] |
||||
public class AssertionException : System.Exception |
||||
{ |
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
public AssertionException (string message) : base(message) |
||||
{} |
||||
|
||||
/// <summary>
|
||||
/// Standard constructor
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains
|
||||
/// the reason for the exception</param>
|
||||
/// <param name="inner">The exception that caused the
|
||||
/// current exception</param>
|
||||
public AssertionException(string message, Exception inner) : |
||||
base(message, inner) |
||||
{} |
||||
|
||||
/// <summary>
|
||||
/// Serialization Constructor
|
||||
/// </summary>
|
||||
protected AssertionException(SerializationInfo info, |
||||
StreamingContext context) : base(info,context) |
||||
{} |
||||
|
||||
} |
||||
} |
@ -1,481 +0,0 @@
@@ -1,481 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig, Douglas de la Torre
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright 2000-2002 Philip A. Craig |
||||
' Copyright 2001 Douglas de la Torre |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov |
||||
' Copyright 2000-2002 Philip A. Craig, or Copyright 2001 Douglas de la Torre |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
using System; |
||||
using System.Text; |
||||
using System.IO; |
||||
using System.Collections; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// Summary description for AssertionFailureMessage.
|
||||
/// </summary>
|
||||
public class AssertionFailureMessage : StringWriter |
||||
{ |
||||
#region Static Constants
|
||||
|
||||
/// <summary>
|
||||
/// Number of characters before a highlighted position before
|
||||
/// clipping will occur. Clipped text is replaced with an
|
||||
/// elipsis "..."
|
||||
/// </summary>
|
||||
static public readonly int PreClipLength = 35; |
||||
|
||||
/// <summary>
|
||||
/// Number of characters after a highlighted position before
|
||||
/// clipping will occur. Clipped text is replaced with an
|
||||
/// elipsis "..."
|
||||
/// </summary>
|
||||
static public readonly int PostClipLength = 35; |
||||
|
||||
/// <summary>
|
||||
/// Prefix used to start an expected value line.
|
||||
/// Must be same length as actualPrefix.
|
||||
/// </summary>
|
||||
static protected readonly string expectedPrefix = "expected:"; |
||||
|
||||
/// <summary>
|
||||
/// Prefix used to start an actual value line.
|
||||
/// Must be same length as expectedPrefix.
|
||||
/// </summary>
|
||||
static protected readonly string actualPrefix = " but was:"; |
||||
|
||||
static private readonly string expectedAndActualFmt = "\t{0} {1}"; |
||||
static private readonly string diffStringLengthsFmt |
||||
= "\tString lengths differ. Expected length={0}, but was length={1}."; |
||||
static private readonly string sameStringLengthsFmt |
||||
= "\tString lengths are both {0}."; |
||||
static private readonly string diffArrayLengthsFmt |
||||
= "Array lengths differ. Expected length={0}, but was length={1}."; |
||||
static private readonly string sameArrayLengthsFmt |
||||
= "Array lengths are both {0}."; |
||||
static private readonly string stringsDifferAtIndexFmt |
||||
= "\tStrings differ at index {0}."; |
||||
static private readonly string arraysDifferAtIndexFmt |
||||
= "Arrays differ at index {0}."; |
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Construct an AssertionFailureMessage with a message
|
||||
/// and optional arguments.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
public AssertionFailureMessage( string message, params object[] args ) |
||||
: base( CreateStringBuilder( message, args ) ) { } |
||||
|
||||
/// <summary>
|
||||
/// Construct an empty AssertionFailureMessage
|
||||
/// </summary>
|
||||
public AssertionFailureMessage() : this( null, null ) { } |
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Add text to the message as a new line.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to add</param>
|
||||
public void AddLine( string text ) |
||||
{ |
||||
WriteLine(); |
||||
Write( text ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Add formatted text and arguments to the message as a new line.
|
||||
/// </summary>
|
||||
/// <param name="fmt">Format string</param>
|
||||
/// <param name="args">Arguments to use with the format</param>
|
||||
public void AddLine( string fmt, params object[] args ) |
||||
{ |
||||
WriteLine(); |
||||
Write( fmt, args ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Add an expected value line to the message containing
|
||||
/// the text provided as an argument.
|
||||
/// </summary>
|
||||
/// <param name="text">Text describing what was expected.</param>
|
||||
public void AddExpectedLine( string text ) |
||||
{ |
||||
AddLine( string.Format( expectedAndActualFmt, expectedPrefix, text ) ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Add an actual value line to the message containing
|
||||
/// the text provided as an argument.
|
||||
/// </summary>
|
||||
/// <param name="text">Text describing the actual value.</param>
|
||||
public void AddActualLine( string text ) |
||||
{ |
||||
AddLine( string.Format( expectedAndActualFmt, actualPrefix, text ) ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Add an expected value line to the message containing
|
||||
/// a string representation of the object provided.
|
||||
/// </summary>
|
||||
/// <param name="expected">An object representing the expected value</param>
|
||||
public void DisplayExpectedValue( object expected ) |
||||
{ |
||||
AddExpectedLine( FormatObjectForDisplay( expected ) ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Add an actual value limne to the message containing
|
||||
/// a string representation of the object provided.
|
||||
/// </summary>
|
||||
/// <param name="actual">An object representing what was actually found</param>
|
||||
public void DisplayActualValue( object actual ) |
||||
{ |
||||
AddActualLine( FormatObjectForDisplay( actual ) ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Display two lines that communicate the expected value, and the actual value
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value found</param>
|
||||
public void DisplayExpectedAndActual( Object expected, Object actual ) |
||||
{ |
||||
DisplayExpectedValue( expected ); |
||||
DisplayActualValue( actual ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Draws a marker under the expected/actual strings that highlights
|
||||
/// where in the string a mismatch occurred.
|
||||
/// </summary>
|
||||
/// <param name="iPosition">The position of the mismatch</param>
|
||||
public void DisplayPositionMarker( int iPosition ) |
||||
{ |
||||
AddLine( "\t{0}^", new String( '-', expectedPrefix.Length + iPosition + 3 ) ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Reports whether the string lengths are the same or different, and
|
||||
/// what the string lengths are.
|
||||
/// </summary>
|
||||
/// <param name="sExpected">The expected string</param>
|
||||
/// <param name="sActual">The actual string value</param>
|
||||
protected void BuildStringLengthReport( string sExpected, string sActual ) |
||||
{ |
||||
if( sExpected.Length != sActual.Length ) |
||||
AddLine( diffStringLengthsFmt, sExpected.Length, sActual.Length ); |
||||
else |
||||
AddLine( sameStringLengthsFmt, sExpected.Length ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Called to create additional message lines when two objects have been
|
||||
/// found to be unequal. If the inputs are strings, a special message is
|
||||
/// rendered that can help track down where the strings are different,
|
||||
/// based on differences in length, or differences in content.
|
||||
///
|
||||
/// If the inputs are not strings, the ToString method of the objects
|
||||
/// is used to show what is different about them.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="caseInsensitive">True if a case-insensitive comparison is being performed</param>
|
||||
public void DisplayDifferences( object expected, object actual, bool caseInsensitive ) |
||||
{ |
||||
if( InputsAreStrings( expected, actual ) ) |
||||
{ |
||||
DisplayStringDifferences( |
||||
(string)expected, |
||||
(string)actual, |
||||
caseInsensitive ); |
||||
} |
||||
else |
||||
{ |
||||
DisplayExpectedAndActual( expected, actual ); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Constructs a message that can be displayed when the content of two
|
||||
/// strings are different, but the string lengths are the same. The
|
||||
/// message will clip the strings to a reasonable length, centered
|
||||
/// around the first position where they are mismatched, and draw
|
||||
/// a line marking the position of the difference to make comparison
|
||||
/// quicker.
|
||||
/// </summary>
|
||||
/// <param name="sExpected">The expected string value</param>
|
||||
/// <param name="sActual">The actual string value</param>
|
||||
/// <param name="caseInsensitive">True if a case-insensitive comparison is being performed</param>
|
||||
protected void DisplayStringDifferences( string sExpected, string sActual, bool caseInsensitive ) |
||||
{ |
||||
//
|
||||
// If they mismatch at a specified position, report the
|
||||
// difference.
|
||||
//
|
||||
int iPosition = caseInsensitive |
||||
? FindMismatchPosition( sExpected.ToLower(), sActual.ToLower(), 0 ) |
||||
: FindMismatchPosition( sExpected, sActual, 0 ); |
||||
//
|
||||
// If the lengths differ, but they match up to the length,
|
||||
// show the difference just past the length of the shorter
|
||||
// string
|
||||
//
|
||||
if( iPosition == -1 ) |
||||
iPosition = Math.Min( sExpected.Length, sActual.Length ); |
||||
|
||||
BuildStringLengthReport( sExpected, sActual ); |
||||
|
||||
AddLine( stringsDifferAtIndexFmt, iPosition ); |
||||
|
||||
//
|
||||
// Clips the strings, then turns any hidden whitespace into visible
|
||||
// characters
|
||||
//
|
||||
string sClippedExpected = ConvertWhitespace(ClipAroundPosition( sExpected, iPosition )); |
||||
string sClippedActual = ConvertWhitespace(ClipAroundPosition( sActual, iPosition )); |
||||
|
||||
DisplayExpectedAndActual( |
||||
sClippedExpected, |
||||
sClippedActual ); |
||||
|
||||
// Add a line showing where they differ. If the string lengths are
|
||||
// different, they start differing just past the length of the
|
||||
// shorter string
|
||||
DisplayPositionMarker( caseInsensitive |
||||
? FindMismatchPosition( sClippedExpected.ToLower(), sClippedActual.ToLower(), 0 ) |
||||
: FindMismatchPosition( sClippedExpected, sClippedActual, 0 ) ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Display a standard message showing the differences found between
|
||||
/// two arrays that were expected to be equal.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected array value</param>
|
||||
/// <param name="actual">The actual array value</param>
|
||||
/// <param name="index">The index at which a difference was found</param>
|
||||
public void DisplayArrayDifferences( Array expected, Array actual, int index ) |
||||
{ |
||||
if( expected.Length != actual.Length ) |
||||
AddLine( diffArrayLengthsFmt, expected.Length, actual.Length ); |
||||
else |
||||
AddLine( sameArrayLengthsFmt, expected.Length ); |
||||
|
||||
AddLine( arraysDifferAtIndexFmt, index ); |
||||
|
||||
if ( index < expected.Length && index < actual.Length ) |
||||
DisplayDifferences( expected.GetValue( index ), actual.GetValue( index ), false ); |
||||
else if( expected.Length < actual.Length ) |
||||
DisplayListElements( " extra:", actual, index, 3 ); |
||||
else |
||||
DisplayListElements( " missing:", expected, index, 3 ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Displays elements from a list on a line
|
||||
/// </summary>
|
||||
/// <param name="label">Text to prefix the line with</param>
|
||||
/// <param name="list">The list of items to display</param>
|
||||
/// <param name="index">The index in the list of the first element to display</param>
|
||||
/// <param name="max">The maximum number of elements to display</param>
|
||||
public void DisplayListElements( string label, IList list, int index, int max ) |
||||
{ |
||||
AddLine( "{0}<", label ); |
||||
|
||||
if ( list == null ) |
||||
Write( "null" ); |
||||
else if ( list.Count == 0 ) |
||||
Write( "empty" ); |
||||
else |
||||
{ |
||||
for( int i = 0; i < max && index < list.Count; i++ ) |
||||
{ |
||||
Write( FormatObjectForDisplay( list[index++] ) ); |
||||
|
||||
if ( index < list.Count ) |
||||
Write( "," ); |
||||
} |
||||
|
||||
if ( index < list.Count ) |
||||
Write( "..." ); |
||||
} |
||||
|
||||
Write( ">" ); |
||||
} |
||||
|
||||
#region Static Methods
|
||||
|
||||
/// <summary>
|
||||
/// Formats an object for display in a message line
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to be displayed</param>
|
||||
/// <returns></returns>
|
||||
static protected string FormatObjectForDisplay( object obj ) |
||||
{ |
||||
if ( obj == null ) |
||||
return "<(null)>"; |
||||
else if ( obj is string ) |
||||
return string.Format( "<\"{0}\">", obj ); |
||||
else |
||||
return string.Format( "<{0}>", obj ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Tests two objects to determine if they are strings.
|
||||
/// </summary>
|
||||
/// <param name="expected"></param>
|
||||
/// <param name="actual"></param>
|
||||
/// <returns></returns>
|
||||
static protected bool InputsAreStrings( Object expected, Object actual ) |
||||
{ |
||||
return expected != null && actual != null && |
||||
expected is string && actual is string; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Used to create a StringBuilder that is used for constructing
|
||||
/// the output message when text is different. Handles initialization
|
||||
/// when a message is provided. If message is null, an empty
|
||||
/// StringBuilder is returned.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
static protected StringBuilder CreateStringBuilder( string message, params object[] args ) |
||||
{ |
||||
if (message != null) |
||||
if ( args != null && args.Length > 0 ) |
||||
return new StringBuilder( string.Format( message, args ) ); |
||||
else |
||||
return new StringBuilder( message ); |
||||
else |
||||
return new StringBuilder(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Renders up to M characters before, and up to N characters after
|
||||
/// the specified index position. If leading or trailing text is
|
||||
/// clipped, and elipses "..." is added where the missing text would
|
||||
/// be.
|
||||
///
|
||||
/// Clips strings to limit previous or post newline characters,
|
||||
/// since these mess up the comparison
|
||||
/// </summary>
|
||||
/// <param name="sString"></param>
|
||||
/// <param name="iPosition"></param>
|
||||
/// <returns></returns>
|
||||
static protected string ClipAroundPosition( string sString, int iPosition ) |
||||
{ |
||||
if( sString == null || sString.Length == 0 ) |
||||
return ""; |
||||
|
||||
bool preClip = iPosition > PreClipLength; |
||||
bool postClip = iPosition + PostClipLength < sString.Length; |
||||
|
||||
int start = preClip |
||||
? iPosition - PreClipLength : 0; |
||||
int length = postClip |
||||
? iPosition + PostClipLength - start : sString.Length - start; |
||||
|
||||
if ( start + length > iPosition + PostClipLength ) |
||||
length = iPosition + PostClipLength - start; |
||||
|
||||
StringBuilder sb = new StringBuilder(); |
||||
if ( preClip ) sb.Append("..."); |
||||
sb.Append( sString.Substring( start, length ) ); |
||||
if ( postClip ) sb.Append("..."); |
||||
|
||||
return sb.ToString(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Shows the position two strings start to differ. Comparison
|
||||
/// starts at the start index.
|
||||
/// </summary>
|
||||
/// <param name="sExpected"></param>
|
||||
/// <param name="sActual"></param>
|
||||
/// <param name="iStart"></param>
|
||||
/// <returns>-1 if no mismatch found, or the index where mismatch found</returns>
|
||||
static private int FindMismatchPosition( string sExpected, string sActual, int iStart ) |
||||
{ |
||||
int iLength = Math.Min( sExpected.Length, sActual.Length ); |
||||
for( int i=iStart; i<iLength; i++ ) |
||||
{ |
||||
//
|
||||
// If they mismatch at a specified position, report the
|
||||
// difference.
|
||||
//
|
||||
if( sExpected[i] != sActual[i] ) |
||||
{ |
||||
return i; |
||||
} |
||||
} |
||||
//
|
||||
// Strings have same content up to the length of the shorter string.
|
||||
// Mismatch occurs because string lengths are different, so show
|
||||
// that they start differing where the shortest string ends
|
||||
//
|
||||
if( sExpected.Length != sActual.Length ) |
||||
{ |
||||
return iLength; |
||||
} |
||||
|
||||
//
|
||||
// Same strings
|
||||
//
|
||||
Assert.IsTrue( sExpected.Equals( sActual ) ); |
||||
return -1; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Turns CR, LF, or TAB into visual indicator to preserve visual marker
|
||||
/// position. This is done by replacing the '\r' into '\\' and 'r'
|
||||
/// characters, and the '\n' into '\\' and 'n' characters, and '\t' into
|
||||
/// '\\' and 't' characters.
|
||||
///
|
||||
/// Thus the single character becomes two characters for display.
|
||||
/// </summary>
|
||||
/// <param name="sInput"></param>
|
||||
/// <returns></returns>
|
||||
static protected string ConvertWhitespace( string sInput ) |
||||
{ |
||||
if( null != sInput ) |
||||
{ |
||||
sInput = sInput.Replace( "\r", "\\r" ); |
||||
sInput = sInput.Replace( "\n", "\\n" ); |
||||
sInput = sInput.Replace( "\t", "\\t" ); |
||||
} |
||||
return sInput; |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
@ -1,60 +0,0 @@
@@ -1,60 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// Summary description for CategoryAttribute.
|
||||
/// </summary>
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple=true)] |
||||
public sealed class CategoryAttribute : Attribute |
||||
{ |
||||
private string name; |
||||
|
||||
/// <summary>
|
||||
/// Construct attribute for a given category
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the category</param>
|
||||
public CategoryAttribute(string name) |
||||
{ |
||||
this.name = name; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The name of the category
|
||||
/// </summary>
|
||||
public string Name |
||||
{ |
||||
get { return name; } |
||||
} |
||||
} |
||||
} |
@ -1,57 +0,0 @@
@@ -1,57 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2002 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2002 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
using System.Reflection; |
||||
|
||||
//
|
||||
// Common Information about all NUnit assemblies is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("NUnit.org")] |
||||
[assembly: AssemblyProduct("NUnit")] |
||||
[assembly: AssemblyCopyright("Copyright (C) 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole.\r\nCopyright (C) 2000-2003 Philip Craig.\r\nAll Rights Reserved.")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("2.2.5.0")] |
@ -1,35 +0,0 @@
@@ -1,35 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// Abstract class used as a base for asserters that compare
|
||||
/// expected and an actual values in some way or another.
|
||||
/// </summary>
|
||||
public abstract class ComparisonAsserter : AbstractAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// The expected value, used as the basis for comparison.
|
||||
/// </summary>
|
||||
protected object expected; |
||||
|
||||
/// <summary>
|
||||
/// The actual value to be compared.
|
||||
/// </summary>
|
||||
protected object actual; |
||||
|
||||
/// <summary>
|
||||
/// Constructs a ComparisonAsserter for two objects
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public ComparisonAsserter( object expected, object actual, string message, params object[] args ) |
||||
: base( message, args ) |
||||
{ |
||||
this.expected = expected; |
||||
this.actual = actual; |
||||
} |
||||
} |
||||
} |
@ -1,186 +0,0 @@
@@ -1,186 +0,0 @@
|
||||
using System; |
||||
using System.Collections; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
#region ConditionAsserter
|
||||
/// <summary>
|
||||
/// ConditionAsserter class represents an asssertion
|
||||
/// that tests a particular condition, which is passed
|
||||
/// to it in the constructor. The failure message is
|
||||
/// not specialized in this class, but derived classes
|
||||
/// are free to do so.
|
||||
/// </summary>
|
||||
public class ConditionAsserter : AbstractAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// The condition we are testing
|
||||
/// </summary>
|
||||
protected bool condition; |
||||
|
||||
/// <summary>
|
||||
/// Phrase indicating what we expected to find
|
||||
/// Ignored unless set by derived class
|
||||
/// </summary>
|
||||
protected string expectation; |
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition to be tested</param>
|
||||
/// <param name="message">The message issued upon failure</param>
|
||||
/// <param name="args">Arguments to be used in formatting the message</param>
|
||||
public ConditionAsserter( bool condition, string message, params object[] args ) |
||||
: base( message, args ) |
||||
{ |
||||
this.condition = condition; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Test the condition being asserted directly
|
||||
/// </summary>
|
||||
public override bool Test() |
||||
{ |
||||
return condition; |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region TrueAsserter
|
||||
/// <summary>
|
||||
/// Class to assert that a condition is true
|
||||
/// </summary>
|
||||
public class TrueAsserter : ConditionAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition to assert</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public TrueAsserter( bool condition, string message, params object[] args ) |
||||
: base( condition, message, args ) { } |
||||
} |
||||
#endregion
|
||||
|
||||
#region FalseAsserter
|
||||
/// <summary>
|
||||
/// Class to assert that a condition is false
|
||||
/// </summary>
|
||||
public class FalseAsserter : ConditionAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition to assert</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public FalseAsserter( bool condition, string message, params object[] args ) |
||||
: base( !condition, message, args ) { } |
||||
|
||||
} |
||||
#endregion
|
||||
|
||||
#region NullAsserter
|
||||
/// <summary>
|
||||
/// Class to assert that an object is null
|
||||
/// </summary>
|
||||
public class NullAsserter : ConditionAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="anObject">The object to test</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public NullAsserter( object anObject, string message, params object[] args ) |
||||
: base( anObject == null, message, args ) { } |
||||
} |
||||
#endregion
|
||||
|
||||
#region NotNullAsserter
|
||||
/// <summary>
|
||||
/// Class to assert that an object is not null
|
||||
/// </summary>
|
||||
public class NotNullAsserter : ConditionAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="anObject">The object to test</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public NotNullAsserter( object anObject, string message, params object[] args ) |
||||
: base( anObject != null, message, args ) { } |
||||
} |
||||
#endregion
|
||||
|
||||
#region NaNAsserter
|
||||
/// <summary>
|
||||
/// Class to assert that a double is an NaN
|
||||
/// </summary>
|
||||
public class NaNAsserter : ConditionAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="aDouble">The value to test</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public NaNAsserter( double aDouble, string message, params object[] args ) |
||||
: base( double.IsNaN( aDouble ), message, args ) { } |
||||
} |
||||
#endregion
|
||||
|
||||
#region EmptyAsserter
|
||||
/// <summary>
|
||||
/// Class to Assert that a string or collection is empty
|
||||
/// </summary>
|
||||
public class EmptyAsserter : ConditionAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Construct an EmptyAsserter for a string
|
||||
/// </summary>
|
||||
/// <param name="aString">The string to be tested</param>
|
||||
/// <param name="message">The message to display if the string is not empty</param>
|
||||
/// <param name="args">Arguements to use in formatting the message</param>
|
||||
public EmptyAsserter( string aString, string message, params object[] args ) |
||||
: base( aString == string.Empty, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Construct an EmptyAsserter for a collection
|
||||
/// </summary>
|
||||
/// <param name="collection">The collection to be tested</param>
|
||||
/// <param name="message">The message to display if the collection is not empty</param>
|
||||
/// <param name="args">Arguements to use in formatting the message</param>
|
||||
public EmptyAsserter( ICollection collection, string message, params object[] args ) |
||||
: base( collection.Count == 0, message, args ) { } |
||||
} |
||||
#endregion
|
||||
|
||||
#region NotEmptyAsserter
|
||||
/// <summary>
|
||||
/// Class to Assert that a string or collection is not empty
|
||||
/// </summary>
|
||||
public class NotEmptyAsserter : ConditionAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Construct a NotEmptyAsserter for a string
|
||||
/// </summary>
|
||||
/// <param name="aString">The string to be tested</param>
|
||||
/// <param name="message">The message to display if the string is empty</param>
|
||||
/// <param name="args">Arguements to use in formatting the message</param>
|
||||
public NotEmptyAsserter( string aString, string message, params object[] args ) |
||||
: base( aString != string.Empty, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Construct a NotEmptyAsserter for a collection
|
||||
/// </summary>
|
||||
/// <param name="collection">The collection to be tested</param>
|
||||
/// <param name="message">The message to display if the collection is empty</param>
|
||||
/// <param name="args">Arguements to use in formatting the message</param>
|
||||
public NotEmptyAsserter( ICollection collection, string message, params object[] args ) |
||||
: base( collection.Count != 0, message, args ) { } |
||||
} |
||||
#endregion
|
||||
} |
@ -1,99 +0,0 @@
@@ -1,99 +0,0 @@
|
||||
using System; |
||||
using System.Text; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// Class to assert that two objects are equal
|
||||
/// </summary>
|
||||
public class EqualAsserter : EqualityAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructs an EqualAsserter for two objects
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public EqualAsserter( object expected, object actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Constructs an EqualAsserter for two doubles and a tolerance
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="tolerance">The tolerance used in making the comparison</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public EqualAsserter( double expected, double actual, double tolerance, string message, params object[] args ) |
||||
: base( expected, actual, tolerance, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test whether the objects are equal, building up
|
||||
/// the failure message for later use if they are not.
|
||||
/// </summary>
|
||||
/// <returns>True if the objects are equal</returns>
|
||||
public override bool Test() |
||||
{ |
||||
if ( expected == null && actual == null ) return true; |
||||
if ( expected == null || actual == null ) |
||||
{ |
||||
DisplayDifferences(); |
||||
return false; |
||||
} |
||||
|
||||
// For now, dynamically call array assertion if necessary. Try to move
|
||||
// this into the ObjectsEqual method later on.
|
||||
if ( expected.GetType().IsArray && actual.GetType().IsArray ) |
||||
{ |
||||
Array expectedArray = expected as Array; |
||||
Array actualArray = actual as Array; |
||||
|
||||
if ( expectedArray.Rank != actualArray.Rank ) |
||||
{ |
||||
DisplayDifferences(); |
||||
return false; |
||||
} |
||||
|
||||
if ( expectedArray.Rank != 1 ) |
||||
throw new ArgumentException( "Multi-dimension array comparison is not supported" ); |
||||
|
||||
int iLength = Math.Min( expectedArray.Length, actualArray.Length ); |
||||
for( int i = 0; i < iLength; i++ ) |
||||
if ( !ObjectsEqual( expectedArray.GetValue( i ), actualArray.GetValue( i ) ) ) |
||||
{ |
||||
DisplayArrayDifferences( i ); |
||||
return false; |
||||
} |
||||
|
||||
if ( expectedArray.Length != actualArray.Length ) |
||||
{ |
||||
DisplayArrayDifferences( iLength ); |
||||
return false; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
if ( !ObjectsEqual( expected, actual ) ) |
||||
{ |
||||
DisplayDifferences(); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
private void DisplayDifferences() |
||||
{ |
||||
FailureMessage.DisplayDifferences( expected, actual, false ); |
||||
} |
||||
|
||||
|
||||
private void DisplayArrayDifferences( int index ) |
||||
{ |
||||
FailureMessage.DisplayArrayDifferences( (Array)expected, (Array)actual, index ); |
||||
} |
||||
} |
||||
} |
@ -1,152 +0,0 @@
@@ -1,152 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// Abstract base class for EqualsAsserter and NotEqualsAsserter
|
||||
/// </summary>
|
||||
public abstract class EqualityAsserter : ComparisonAsserter |
||||
{ |
||||
private double delta; |
||||
|
||||
/// <summary>
|
||||
/// Constructor taking expected and actual values and a user message with arguments.
|
||||
/// </summary>
|
||||
/// <param name="expected"></param>
|
||||
/// <param name="actual"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
public EqualityAsserter( object expected, object actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Constructor taking expected and actual values, a tolerance
|
||||
/// and a user message and arguments.
|
||||
/// </summary>
|
||||
/// <param name="expected"></param>
|
||||
/// <param name="actual"></param>
|
||||
/// <param name="delta"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
public EqualityAsserter( double expected, double actual, double delta, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) |
||||
{ |
||||
this.delta = delta; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Used to compare two objects. Two nulls are equal and null
|
||||
/// is not equal to non-null. Comparisons between the same
|
||||
/// numeric types are fine (Int32 to Int32, or Int64 to Int64),
|
||||
/// but the Equals method fails across different types so we
|
||||
/// use <c>ToString</c> and compare the results.
|
||||
/// </summary>
|
||||
/// <param name="expected"></param>
|
||||
/// <param name="actual"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual bool ObjectsEqual( Object expected, Object actual ) |
||||
{ |
||||
if ( expected == null && actual == null ) return true; |
||||
if ( expected == null || actual == null ) return false; |
||||
|
||||
//if ( expected.GetType().IsArray && actual.GetType().IsArray )
|
||||
// return ArraysEqual( (System.Array)expected, (System.Array)actual );
|
||||
|
||||
if ( expected is double && actual is double ) |
||||
{ |
||||
if ( double.IsNaN((double)expected) && double.IsNaN((double)actual) ) |
||||
return true; |
||||
// handle infinity specially since subtracting two infinite values gives
|
||||
// NaN and the following test fails. mono also needs NaN to be handled
|
||||
// specially although ms.net could use either method.
|
||||
if (double.IsInfinity((double)expected) || double.IsNaN((double)expected) || double.IsNaN((double)actual)) |
||||
return expected.Equals( actual ); |
||||
else |
||||
return Math.Abs((double)expected-(double)actual) <= this.delta; |
||||
} |
||||
|
||||
// if ( expected is float && actual is float )
|
||||
// {
|
||||
// // handle infinity specially since subtracting two infinite values gives
|
||||
// // NaN and the following test fails. mono also needs NaN to be handled
|
||||
// // specially although ms.net could use either method.
|
||||
// if (float.IsInfinity((float)expected) || float.IsNaN((float)expected) || float.IsNaN((float)actual))
|
||||
// return (float)expected == (float)actual;
|
||||
// else
|
||||
// return Math.Abs((float)expected-(float)actual) <= (float)this.delta;
|
||||
// }
|
||||
|
||||
if ( expected.GetType() != actual.GetType() && |
||||
IsNumericType( expected ) && IsNumericType( actual ) ) |
||||
{ |
||||
//
|
||||
// Convert to strings and compare result to avoid
|
||||
// issues with different types that have the same
|
||||
// value
|
||||
//
|
||||
string sExpected = expected.ToString(); |
||||
string sActual = actual.ToString(); |
||||
return sExpected.Equals( sActual ); |
||||
} |
||||
return expected.Equals(actual); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Checks the type of the object, returning true if
|
||||
/// the object is a numeric type.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to check</param>
|
||||
/// <returns>true if the object is a numeric type</returns>
|
||||
private bool IsNumericType( Object obj ) |
||||
{ |
||||
if( null != obj ) |
||||
{ |
||||
if( obj is byte ) return true; |
||||
if( obj is sbyte ) return true; |
||||
if( obj is decimal ) return true; |
||||
if( obj is double ) return true; |
||||
if( obj is float ) return true; |
||||
if( obj is int ) return true; |
||||
if( obj is uint ) return true; |
||||
if( obj is long ) return true; |
||||
if( obj is short ) return true; |
||||
if( obj is ushort ) return true; |
||||
|
||||
if( obj is System.Byte ) return true; |
||||
if( obj is System.SByte ) return true; |
||||
if( obj is System.Decimal ) return true; |
||||
if( obj is System.Double ) return true; |
||||
if( obj is System.Single ) return true; |
||||
if( obj is System.Int32 ) return true; |
||||
if( obj is System.UInt32 ) return true; |
||||
if( obj is System.Int64 ) return true; |
||||
if( obj is System.UInt64 ) return true; |
||||
if( obj is System.Int16 ) return true; |
||||
if( obj is System.UInt16 ) return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Helper method to compare two arrays
|
||||
/// </summary>
|
||||
protected virtual bool ArraysEqual( Array expected, Array actual ) |
||||
{ |
||||
if ( expected.Rank != actual.Rank ) |
||||
return false; |
||||
|
||||
if ( expected.Rank != 1 ) |
||||
throw new ArgumentException( "Multi-dimension array comparison is not supported" ); |
||||
|
||||
int iLength = Math.Min( expected.Length, actual.Length ); |
||||
for( int i = 0; i < iLength; i++ ) |
||||
if ( !ObjectsEqual( expected.GetValue( i ), actual.GetValue( i ) ) ) |
||||
return false; |
||||
|
||||
if ( expected.Length != actual.Length ) |
||||
return false; |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
} |
@ -1,113 +0,0 @@
@@ -1,113 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
|
||||
/// <summary>
|
||||
/// ExpectedExceptionAttribute
|
||||
/// </summary>
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)] |
||||
public sealed class ExpectedExceptionAttribute : Attribute |
||||
{ |
||||
private Type expectedException; |
||||
private string expectedExceptionName; |
||||
private string expectedMessage; |
||||
|
||||
/// <summary>
|
||||
/// Constructor for a given type of exception
|
||||
/// </summary>
|
||||
/// <param name="exceptionType">The type of the expected exception</param>
|
||||
public ExpectedExceptionAttribute(Type exceptionType) |
||||
{ |
||||
this.expectedException = exceptionType; |
||||
this.expectedExceptionName = exceptionType.FullName; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Constructor for a given exception name
|
||||
/// </summary>
|
||||
/// <param name="exceptionName">The full name of the expected exception</param>
|
||||
public ExpectedExceptionAttribute(string exceptionName) |
||||
{ |
||||
this.expectedExceptionName = exceptionName; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Constructor for a given type of exception and expected message text
|
||||
/// </summary>
|
||||
/// <param name="exceptionType">The type of the expected exception</param>
|
||||
/// <param name="expectedMessage">The expected message text</param>
|
||||
public ExpectedExceptionAttribute(Type exceptionType, string expectedMessage) |
||||
{ |
||||
this.expectedException = exceptionType; |
||||
this.expectedMessage = expectedMessage; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Constructor for a given exception name and expected message text
|
||||
/// </summary>
|
||||
/// <param name="exceptionName">The full name of the expected exception</param>
|
||||
/// <param name="expectedMessage">The expected messge text</param>
|
||||
public ExpectedExceptionAttribute(string exceptionName, string expectedMessage) |
||||
{ |
||||
this.expectedExceptionName = exceptionName; |
||||
this.expectedMessage = expectedMessage; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The expected exception type
|
||||
/// </summary>
|
||||
public Type ExceptionType |
||||
{ |
||||
get{ return expectedException; } |
||||
set{ expectedException = value; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The full Type name of the expected exception
|
||||
/// </summary>
|
||||
public string ExceptionName |
||||
{ |
||||
get{ return expectedExceptionName; } |
||||
set{ expectedExceptionName = value; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The expected message
|
||||
/// </summary>
|
||||
public string ExpectedMessage |
||||
{ |
||||
get { return expectedMessage; } |
||||
set { expectedMessage = value; } |
||||
} |
||||
} |
||||
} |
@ -1,21 +0,0 @@
@@ -1,21 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// ExplicitAttribute marks a test or test fixture so that it will
|
||||
/// only be run if explicitly executed from the gui or command line
|
||||
/// or if it is included by use of a filter. The test will not be
|
||||
/// run simply because an enclosing suite is run.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple=false)] |
||||
public sealed class ExplicitAttribute : Attribute |
||||
{ |
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public ExplicitAttribute() |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -1,30 +0,0 @@
@@ -1,30 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// The interface implemented by an asserter. Asserters
|
||||
/// encapsulate a condition test and generation of an
|
||||
/// AssertionException with a tailored message. They
|
||||
/// are used by the Assert class as helper objects.
|
||||
///
|
||||
/// User-defined asserters may be passed to the
|
||||
/// Assert.DoAssert method in order to implement
|
||||
/// extended asserts.
|
||||
/// </summary>
|
||||
public interface IAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Test the condition for the assertion.
|
||||
/// </summary>
|
||||
/// <returns>True if the test succeeds</returns>
|
||||
bool Test(); |
||||
|
||||
/// <summary>
|
||||
/// Return the message giving the failure reason.
|
||||
/// The return value is unspecified if no failure
|
||||
/// has occured.
|
||||
/// </summary>
|
||||
string Message { get; } |
||||
} |
||||
} |
@ -1,67 +0,0 @@
@@ -1,67 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
/// <summary>
|
||||
/// IgnoreAttribute.
|
||||
/// </summary>
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Method|AttributeTargets.Class, AllowMultiple=false)] |
||||
public sealed class IgnoreAttribute : Attribute |
||||
{ |
||||
private string reason; |
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public IgnoreAttribute() |
||||
{ |
||||
this.reason = ""; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Constructor with a reason
|
||||
/// </summary>
|
||||
/// <param name="reason">The reason for ignoring the test</param>
|
||||
public IgnoreAttribute(string reason) |
||||
{ |
||||
this.reason = reason; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The reason for ignoring a test
|
||||
/// </summary>
|
||||
public string Reason |
||||
{ |
||||
get { return reason; } |
||||
} |
||||
} |
||||
} |
@ -1,68 +0,0 @@
@@ -1,68 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
using System.Runtime.Serialization; |
||||
|
||||
/// <summary>
|
||||
/// Thrown when an assertion failed.
|
||||
/// </summary>
|
||||
///
|
||||
[Serializable] |
||||
public class IgnoreException : System.Exception |
||||
{ |
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
public IgnoreException (string message) : base(message) |
||||
{} |
||||
|
||||
/// <summary>
|
||||
/// Standard constructor
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains
|
||||
/// the reason for the exception</param>
|
||||
/// <param name="inner">The exception that caused the
|
||||
/// current exception</param>
|
||||
public IgnoreException(string message, Exception inner) : |
||||
base(message, inner) |
||||
{} |
||||
|
||||
/// <summary>
|
||||
/// Serialization Constructor
|
||||
/// </summary>
|
||||
protected IgnoreException(SerializationInfo info, |
||||
StreamingContext context) : base(info,context) |
||||
{} |
||||
|
||||
} |
||||
} |
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
using System; |
||||
using System.Collections; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// ListContentsAsserter implements an assertion that a given
|
||||
/// item is found in an array or other List.
|
||||
/// </summary>
|
||||
public class ListContentsAsserter : AbstractAsserter |
||||
{ |
||||
private object expected; |
||||
private IList list; |
||||
|
||||
/// <summary>
|
||||
/// Constructs a ListContentsAsserter for a particular list and object.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected object</param>
|
||||
/// <param name="list">The list to be examined</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public ListContentsAsserter( object expected, IList list, string message, params object[] args ) |
||||
: base( message, args ) |
||||
{ |
||||
this.expected = expected; |
||||
this.list = list; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Test that the object is contained in the list
|
||||
/// </summary>
|
||||
/// <returns>True if the object is found</returns>
|
||||
public override bool Test() |
||||
{ |
||||
return list != null && list.Contains( expected ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Error message to display after a failure.
|
||||
/// </summary>
|
||||
public override string Message |
||||
{ |
||||
get |
||||
{ |
||||
FailureMessage.DisplayExpectedValue( expected ); |
||||
FailureMessage.DisplayListElements( "\t but was: ", list, 0, 5 ); |
||||
return FailureMessage.ToString(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,35 +0,0 @@
@@ -1,35 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// NotEqualAsserter is the asserter class that handles
|
||||
/// inequality assertions.
|
||||
/// </summary>
|
||||
public class NotEqualAsserter : EqualityAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructor for NotEqualAsserter
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected object</param>
|
||||
/// <param name="actual">The actual object</param>
|
||||
/// <param name="message">The message to be printed when the two objects are the same object.</param>
|
||||
/// <param name="args">Arguments to be used in formatting the message</param>
|
||||
public NotEqualAsserter( object expected, object actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test that the objects are not equal
|
||||
/// </summary>
|
||||
public override bool Test() |
||||
{ |
||||
if ( expected == null && actual == null ) return false; |
||||
if ( expected == null || actual == null ) return true; |
||||
|
||||
if ( expected.GetType().IsArray && actual.GetType().IsArray ) |
||||
return !ArraysEqual( (Array)expected, (Array)actual ); |
||||
else |
||||
return !ObjectsEqual( expected, actual ); |
||||
} |
||||
} |
||||
} |
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// Asserter that verifies two objects are different.
|
||||
/// </summary>
|
||||
public class NotSameAsserter : ComparisonAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Construct a NotSameAsserter object
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="message">A user-defined message for use in reporting errors</param>
|
||||
/// <param name="args">Arguments to be used in formatting the user-defined message</param>
|
||||
public NotSameAsserter( object expected, object actual, string message, params object[] args) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Tests that the objects are not the same
|
||||
/// </summary>
|
||||
public override bool Test() |
||||
{ |
||||
return !object.ReferenceEquals( expected, actual ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Provides a message in case of failure
|
||||
/// </summary>
|
||||
public override string Message |
||||
{ |
||||
get |
||||
{ |
||||
FailureMessage.Write( "expected not same" ); |
||||
return FailureMessage.ToString(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,58 +0,0 @@
@@ -1,58 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
|
||||
/// <summary>
|
||||
/// TestFixture
|
||||
/// </summary>
|
||||
///
|
||||
[TestFixture] |
||||
[Obsolete("use TestFixture attribute instead of inheritance",false)] |
||||
public class TestCase : Assertion |
||||
{ |
||||
/// <summary>
|
||||
/// SetUp method
|
||||
/// </summary>
|
||||
[SetUp] |
||||
[Obsolete("use SetUp attribute instead of naming convention",false)] |
||||
protected virtual void SetUp() |
||||
{} |
||||
|
||||
/// <summary>
|
||||
/// TearDown method
|
||||
/// </summary>
|
||||
[TearDown] |
||||
[Obsolete("use TearDown attribute instead of naming convention",false)] |
||||
protected virtual void TearDown() |
||||
{} |
||||
} |
||||
} |
@ -1,51 +0,0 @@
@@ -1,51 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// PlatformAttribute is used to mark a test fixture or an
|
||||
/// individual method as applying to a particular platform only.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple=false)] |
||||
public sealed class PlatformAttribute : Attribute |
||||
{ |
||||
private string include; |
||||
private string exclude; |
||||
|
||||
/// <summary>
|
||||
/// Constructor with no platforms specified, for use
|
||||
/// with named property syntax.
|
||||
/// </summary>
|
||||
public PlatformAttribute() { } |
||||
|
||||
/// <summary>
|
||||
/// Constructor taking one or more platforms
|
||||
/// </summary>
|
||||
/// <param name="platforms">Comma-deliminted list of platforms</param>
|
||||
public PlatformAttribute( string platforms ) |
||||
{ |
||||
this.include = platforms; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Name of the platform that is needed in order for
|
||||
/// a test to run. Multiple platforms may be given,
|
||||
/// separated by a comma.
|
||||
/// </summary>
|
||||
public string Include |
||||
{ |
||||
get { return this.include; } |
||||
set { include = value; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Name of the platform to be excluded. Multiple platforms
|
||||
/// may be given, separated by a comma.
|
||||
/// </summary>
|
||||
public string Exclude |
||||
{ |
||||
get { return this.exclude; } |
||||
set { this.exclude = value; } |
||||
} |
||||
} |
||||
} |
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// Asserter that verifies two objects are the same.
|
||||
/// </summary>
|
||||
public class SameAsserter : ComparisonAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Construct a SameAsserter object
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="message">A user-defined message for use in reporting errors</param>
|
||||
/// <param name="args">Arguments to be used in formatting the user-defined message</param>
|
||||
public SameAsserter( object expected, object actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test that actual and expected reference the same object
|
||||
/// </summary>
|
||||
public override bool Test() |
||||
{ |
||||
return object.ReferenceEquals( expected, actual ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Provide error message when the objects are different.
|
||||
/// </summary>
|
||||
public override string Message |
||||
{ |
||||
get |
||||
{ |
||||
FailureMessage.Write( "expected same" ); |
||||
return FailureMessage.ToString(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
/// <summary>
|
||||
/// SetUpAttribute.
|
||||
/// </summary>
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)] |
||||
public sealed class SetUpAttribute : Attribute |
||||
{} |
||||
} |
@ -1,12 +0,0 @@
@@ -1,12 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// SetUpFixtureAttribute is used to identify a SetUpFixture
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] |
||||
public sealed class SetUpFixtureAttribute : Attribute |
||||
{ |
||||
} |
||||
} |
@ -1,155 +0,0 @@
@@ -1,155 +0,0 @@
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// Basic Asserts on strings.
|
||||
/// </summary>
|
||||
public class StringAssert |
||||
{ |
||||
#region Contains
|
||||
|
||||
/// <summary>
|
||||
/// Asserts that a string is found within another string.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The string to be examined</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
/// <param name="args">Arguments used in formatting the message</param>
|
||||
static public void Contains( string expected, string actual, string message, params object[] args ) |
||||
{ |
||||
Assert.DoAssert( new ContainsAsserter( expected, actual, message, args ) ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Asserts that a string is found within another string.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The string to be examined</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
static public void Contains( string expected, string actual, string message ) |
||||
{ |
||||
Contains( expected, actual, message, null ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Asserts that a string is found within another string.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The string to be examined</param>
|
||||
static public void Contains( string expected, string actual ) |
||||
{ |
||||
Contains( expected, actual, string.Empty, null ); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region StartsWith
|
||||
|
||||
/// <summary>
|
||||
/// Asserts that a string starts with another string.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The string to be examined</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
/// <param name="args">Arguments used in formatting the message</param>
|
||||
static public void StartsWith( string expected, string actual, string message, params object[] args ) |
||||
{ |
||||
Assert.DoAssert( new StartsWithAsserter( expected, actual, message, args ) ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Asserts that a string starts with another string.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The string to be examined</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
static public void StartsWith( string expected, string actual, string message ) |
||||
{ |
||||
StartsWith( expected, actual, message, null ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Asserts that a string starts with another string.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The string to be examined</param>
|
||||
static public void StartsWith( string expected, string actual ) |
||||
{ |
||||
StartsWith( expected, actual, string.Empty, null ); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region EndsWith
|
||||
|
||||
/// <summary>
|
||||
/// Asserts that a string ends with another string.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The string to be examined</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
/// <param name="args">Arguments used in formatting the message</param>
|
||||
static public void EndsWith( string expected, string actual, string message, params object[] args ) |
||||
{ |
||||
Assert.DoAssert( new EndsWithAsserter( expected, actual, message, args ) ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Asserts that a string ends with another string.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The string to be examined</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
static public void EndsWith( string expected, string actual, string message ) |
||||
{ |
||||
EndsWith( expected, actual, message, null ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Asserts that a string ends with another string.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The string to be examined</param>
|
||||
static public void EndsWith( string expected, string actual ) |
||||
{ |
||||
EndsWith( expected, actual, string.Empty, null ); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region AreEqualIgnoringCase
|
||||
/// <summary>
|
||||
/// Asserts that two strings are equal, without regard to case.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The actual string</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
/// <param name="args">Arguments used in formatting the message</param>
|
||||
static public void AreEqualIgnoringCase( string expected, string actual, string message, params object[] args ) |
||||
{ |
||||
Assert.DoAssert( new EqualIgnoringCaseAsserter( expected, actual, message, args ) ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Asserts that two strings are equal, without regard to case.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The actual string</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
static public void AreEqualIgnoringCase( string expected, string actual, string message ) |
||||
{ |
||||
AreEqualIgnoringCase( expected, actual, message, null ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Asserts that two strings are equal, without regard to case.
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The actual string</param>
|
||||
static public void AreEqualIgnoringCase( string expected, string actual ) |
||||
{ |
||||
AreEqualIgnoringCase( expected, actual, string.Empty, null ); |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
@ -1,204 +0,0 @@
@@ -1,204 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
#region StringAsserter
|
||||
/// <summary>
|
||||
/// Abstract class used as a base for asserters that compare
|
||||
/// expected and an actual string values in some way or another.
|
||||
/// </summary>
|
||||
public abstract class StringAsserter : AbstractAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// The expected value, used as the basis for comparison.
|
||||
/// </summary>
|
||||
protected string expected; |
||||
|
||||
/// <summary>
|
||||
/// The actual value to be compared.
|
||||
/// </summary>
|
||||
protected string actual; |
||||
|
||||
/// <summary>
|
||||
/// Constructs a StringAsserter for two strings
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public StringAsserter( string expected, string actual, string message, params object[] args ) |
||||
: base( message, args ) |
||||
{ |
||||
this.expected = expected; |
||||
this.actual = actual; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Message related to a failure. If no failure has
|
||||
/// occured, the result is unspecified.
|
||||
/// </summary>
|
||||
public override string Message |
||||
{ |
||||
get |
||||
{ |
||||
FailureMessage.AddExpectedLine( Expectation ); |
||||
FailureMessage.DisplayActualValue( actual ); |
||||
return FailureMessage.ToString(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// String value that represents what the asserter expected
|
||||
/// to find. Defaults to the expected value itself.
|
||||
/// </summary>
|
||||
protected virtual string Expectation |
||||
{ |
||||
get { return string.Format( "<\"{0}\">", expected ); } |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region ContainsAsserter
|
||||
/// <summary>
|
||||
/// Summary description for ContainsAsserter.
|
||||
/// </summary>
|
||||
public class ContainsAsserter : StringAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructs a ContainsAsserter for two strings
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected substring</param>
|
||||
/// <param name="actual">The actual string to be examined</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public ContainsAsserter( string expected, string actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test the assertion.
|
||||
/// </summary>
|
||||
/// <returns>True if the test succeeds</returns>
|
||||
public override bool Test() |
||||
{ |
||||
return actual.IndexOf( expected ) >= 0; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// String value that represents what the asserter expected
|
||||
/// </summary>
|
||||
protected override string Expectation |
||||
{ |
||||
get { return string.Format( "String containing \"{0}\"", expected ); } |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region StartsWithAsserter
|
||||
/// <summary>
|
||||
/// Summary description for StartsWithAsserter.
|
||||
/// </summary>
|
||||
public class StartsWithAsserter : StringAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructs a StartsWithAsserter for two strings
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected substring</param>
|
||||
/// <param name="actual">The actual string to be examined</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public StartsWithAsserter( string expected, string actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test the assertion.
|
||||
/// </summary>
|
||||
/// <returns>True if the test succeeds</returns>
|
||||
public override bool Test() |
||||
{ |
||||
return actual.StartsWith( expected ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// String value that represents what the asserter expected
|
||||
/// </summary>
|
||||
protected override string Expectation |
||||
{ |
||||
get { return string.Format( "String starting with \"{0}\"", expected ); } |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region EndsWithAsserter
|
||||
/// <summary>
|
||||
/// Summary description for EndsWithAsserter.
|
||||
/// </summary>
|
||||
public class EndsWithAsserter : StringAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructs a EndsWithAsserter for two strings
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected substring</param>
|
||||
/// <param name="actual">The actual string to be examined</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public EndsWithAsserter( string expected, string actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test the assertion.
|
||||
/// </summary>
|
||||
/// <returns>True if the test succeeds</returns>
|
||||
public override bool Test() |
||||
{ |
||||
return actual.EndsWith( expected ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// String value that represents what the asserter expected
|
||||
/// </summary>
|
||||
protected override string Expectation |
||||
{ |
||||
get { return string.Format( "String ending with \"{0}\"", expected ); } |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region EqualIgnoringCaseAsserter
|
||||
/// <summary>
|
||||
/// Asserter that implements AreEqualIgnoringCase
|
||||
/// </summary>
|
||||
public class EqualIgnoringCaseAsserter : StringAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructs an EqualIgnoringCaseAsserter for two strings
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected string</param>
|
||||
/// <param name="actual">The actual string</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public EqualIgnoringCaseAsserter( string expected, string actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test the assertion.
|
||||
/// </summary>
|
||||
/// <returns>True if the test succeeds</returns>
|
||||
public override bool Test() |
||||
{ |
||||
return string.Compare( expected, actual, true ) == 0; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// String value that represents what the asserter expected
|
||||
/// </summary>
|
||||
public override string Message |
||||
{ |
||||
get |
||||
{ |
||||
FailureMessage.DisplayDifferences( expected, actual, true ); |
||||
return FailureMessage.ToString(); |
||||
} |
||||
} |
||||
} |
||||
#endregion
|
||||
} |
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
/// <summary>
|
||||
/// SuiteAttribute.
|
||||
/// </summary>
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple=false)] |
||||
public sealed class SuiteAttribute : Attribute |
||||
{} |
||||
} |
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
/// <summary>
|
||||
/// TearDownAttribute.
|
||||
/// </summary>
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)] |
||||
public sealed class TearDownAttribute : Attribute |
||||
{} |
||||
} |
@ -1,69 +0,0 @@
@@ -1,69 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, |
||||
' Charlie Poole or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
|
||||
/// <summary>
|
||||
/// Adding this attribute to a method within a <seealso cref="TestFixtureAttribute"/>
|
||||
/// class makes the method callable from the NUnit test runner. There is a property
|
||||
/// called Description which is optional which you can provide a more detailed test
|
||||
/// description. This class cannot be inherited.
|
||||
/// </summary>
|
||||
///
|
||||
/// <example>
|
||||
/// [TestFixture]
|
||||
/// public class Fixture
|
||||
/// {
|
||||
/// [Test]
|
||||
/// public void MethodToTest()
|
||||
/// {}
|
||||
///
|
||||
/// [Test(Description = "more detailed description")]
|
||||
/// publc void TestDescriptionMethod()
|
||||
/// {}
|
||||
/// }
|
||||
/// </example>
|
||||
///
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)] |
||||
public sealed class TestAttribute : Attribute |
||||
{ |
||||
private string description; |
||||
|
||||
/// <summary>
|
||||
/// Descriptive text for this test
|
||||
/// </summary>
|
||||
public string Description |
||||
{ |
||||
get { return description; } |
||||
set { description = value; } |
||||
} |
||||
} |
||||
} |
@ -1,56 +0,0 @@
@@ -1,56 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
|
||||
/// <summary>
|
||||
/// TestFixtureAttribute
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// [TestFixture]
|
||||
/// public class ExampleClass
|
||||
/// {}
|
||||
/// </example>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=true)] |
||||
public sealed class TestFixtureAttribute : Attribute |
||||
{ |
||||
private string description; |
||||
|
||||
/// <summary>
|
||||
/// Descriptive text for this fixture
|
||||
/// </summary>
|
||||
public string Description |
||||
{ |
||||
get { return description; } |
||||
set { description = value; } |
||||
} |
||||
} |
||||
} |
@ -1,41 +0,0 @@
@@ -1,41 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
|
||||
/// <summary>
|
||||
/// TestFixtureSetUpAttribute
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)] |
||||
public class TestFixtureSetUpAttribute : Attribute |
||||
{ |
||||
} |
||||
} |
@ -1,42 +0,0 @@
@@ -1,42 +0,0 @@
|
||||
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
|
||||
/************************************************************************************ |
||||
' |
||||
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' This software is provided 'as-is', without any express or implied warranty. In no |
||||
' event will the authors be held liable for any damages arising from the use of this |
||||
' software. |
||||
' |
||||
' Permission is granted to anyone to use this software for any purpose, including |
||||
' commercial applications, and to alter it and redistribute it freely, subject to the |
||||
' following restrictions: |
||||
' |
||||
' 1. The origin of this software must not be misrepresented; you must not claim that |
||||
' you wrote the original software. If you use this software in a product, an |
||||
' acknowledgment (see the following) in the product documentation is required. |
||||
' |
||||
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole |
||||
' or Copyright © 2000-2003 Philip A. Craig |
||||
' |
||||
' 2. Altered source versions must be plainly marked as such, and must not be |
||||
' misrepresented as being the original software. |
||||
' |
||||
' 3. This notice may not be removed or altered from any source distribution. |
||||
' |
||||
'***********************************************************************************/ |
||||
#endregion
|
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
using System; |
||||
|
||||
/// <summary>
|
||||
/// TestFixtureTearDownAttribute
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)] |
||||
public class TestFixtureTearDownAttribute : Attribute |
||||
{ |
||||
} |
||||
} |
||||
|
@ -1,208 +0,0 @@
@@ -1,208 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
#region TypeAsserter
|
||||
/// <summary>
|
||||
/// The abstract asserter from which all specific type asserters
|
||||
/// will inherit from in order to limit code-reproduction.
|
||||
/// </summary>
|
||||
public abstract class TypeAsserter : AbstractAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// The expected Type
|
||||
/// </summary>
|
||||
protected System.Type expected; |
||||
|
||||
/// <summary>
|
||||
/// The actual object to be compared
|
||||
/// </summary>
|
||||
protected object actual; |
||||
|
||||
/// <summary>
|
||||
/// Construct a TypeAsserter
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected Type</param>
|
||||
/// <param name="actual">The object to be examined</param>
|
||||
/// <param name="message">A message to display on failure</param>
|
||||
/// <param name="args">Arguments to be used in formatting the message</param>
|
||||
public TypeAsserter( System.Type expected, object actual, string message, params object[] args ) |
||||
: base( message, args ) |
||||
{ |
||||
this.expected = expected; |
||||
this.actual = actual; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The complete message text in case of a failure.
|
||||
/// </summary>
|
||||
public override string Message |
||||
{ |
||||
get |
||||
{ |
||||
FailureMessage.AddExpectedLine( Expectation ); |
||||
FailureMessage.AddActualLine( actual.GetType().ToString() ); |
||||
return FailureMessage.ToString(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// A string representing what was expected. Used as a part of the message text.
|
||||
/// </summary>
|
||||
protected virtual string Expectation |
||||
{ |
||||
get { return expected.ToString(); } |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region AssignableFromAsserter
|
||||
/// <summary>
|
||||
/// Class to Assert that an object may be assigned from a given Type.
|
||||
/// </summary>
|
||||
public class AssignableFromAsserter : TypeAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Construct an AssignableFromAsserter
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected Type</param>
|
||||
/// <param name="actual">The object being examined</param>
|
||||
/// <param name="message">A message to display in case of failure</param>
|
||||
/// <param name="args">Arguments for use in formatting the message</param>
|
||||
public AssignableFromAsserter( System.Type expected, object actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test the object to determine if it can be assigned from the expected Type
|
||||
/// </summary>
|
||||
/// <returns>True if the object is assignable</returns>
|
||||
public override bool Test() |
||||
{ |
||||
return actual.GetType().IsAssignableFrom(expected); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// A string representing what was expected. Used as a part of the message text.
|
||||
/// </summary>
|
||||
protected override string Expectation |
||||
{ |
||||
get { return string.Format( "Type assignable from {0}", expected ); } |
||||
} |
||||
|
||||
} |
||||
#endregion
|
||||
|
||||
#region NotAssignableFromAsserter
|
||||
/// <summary>
|
||||
/// Class to Assert that an object may not be assigned from a given Type.
|
||||
/// </summary>
|
||||
public class NotAssignableFromAsserter : TypeAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Construct a NotAssignableFromAsserter
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected Type</param>
|
||||
/// <param name="actual">The object to be examined</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
/// <param name="args">Arguments to use in formatting the message</param>
|
||||
public NotAssignableFromAsserter( System.Type expected, object actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test the object to determine if it can be assigned from the expected Type
|
||||
/// </summary>
|
||||
/// <returns>True if the object is not assignable</returns>
|
||||
public override bool Test() |
||||
{ |
||||
return !actual.GetType().IsAssignableFrom(expected); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// A string representing what was expected. Used as a part of the message text.
|
||||
/// </summary>
|
||||
protected override string Expectation |
||||
{ |
||||
get { return string.Format( "Type not assignable from {0}", expected ); } |
||||
} |
||||
|
||||
} |
||||
#endregion
|
||||
|
||||
#region InstanceOfTypeAsserter
|
||||
/// <summary>
|
||||
/// Class to Assert that an object is an instance of a given Type.
|
||||
/// </summary>
|
||||
public class InstanceOfTypeAsserter : TypeAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Construct an InstanceOfTypeAsserter
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected Type</param>
|
||||
/// <param name="actual">The object to be examined</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
/// <param name="args">Arguments to use in formatting the message</param>
|
||||
public InstanceOfTypeAsserter( System.Type expected, object actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test the object to determine if it is an instance of the expected Type
|
||||
/// </summary>
|
||||
/// <returns>True if the object is an instance of the expected Type</returns>
|
||||
public override bool Test() |
||||
{ |
||||
return expected.IsInstanceOfType( actual ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// A string representing what was expected. Used as a part of the message text.
|
||||
/// </summary>
|
||||
protected override string Expectation |
||||
{ |
||||
get |
||||
{ |
||||
return string.Format( "Object to be instance of {0}", expected ); |
||||
} |
||||
} |
||||
|
||||
} |
||||
#endregion
|
||||
|
||||
#region NotInstanceOfTypeAsserter
|
||||
/// <summary>
|
||||
/// Class to Assert that an object is not an instance of a given Type.
|
||||
/// </summary>
|
||||
public class NotInstanceOfTypeAsserter : TypeAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Construct a NotInstanceOfTypeAsserter
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected Type</param>
|
||||
/// <param name="actual">The object to be examined</param>
|
||||
/// <param name="message">The message to display in case of failure</param>
|
||||
/// <param name="args">Arguments to use in formatting the message</param>
|
||||
public NotInstanceOfTypeAsserter( System.Type expected, object actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test the object to determine if it is an instance of the expected Type
|
||||
/// </summary>
|
||||
/// <returns>True if the object is not an instance of the expected Type</returns>
|
||||
public override bool Test() |
||||
{ |
||||
return !expected.IsInstanceOfType( actual ); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// A string representing what was expected. Used as a part of the message text.
|
||||
/// </summary>
|
||||
protected override string Expectation |
||||
{ |
||||
get |
||||
{ |
||||
return string.Format( "Object not an instance of {0}", expected ); |
||||
} |
||||
} |
||||
|
||||
} |
||||
#endregion
|
||||
} |
@ -1,42 +0,0 @@
@@ -1,42 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// Class to assert that the actual value is greater than the expected value.
|
||||
/// </summary>
|
||||
public class GreaterAsserter : ComparisonAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructs a GreaterAsserter for two objects implementing IComparable
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public GreaterAsserter( IComparable expected, IComparable actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test whether the actual is greater than the expected, building up
|
||||
/// the failure message for later use if they are not.
|
||||
/// </summary>
|
||||
/// <returns>True if actual is greater than expected</returns>
|
||||
public override bool Test() |
||||
{ |
||||
if ( ((IComparable)actual).CompareTo(expected) > 0 ) return true; |
||||
|
||||
DisplayDifferences(); |
||||
return false; |
||||
} |
||||
|
||||
|
||||
private void DisplayDifferences() |
||||
{ |
||||
FailureMessage.AddExpectedLine( string.Format( "Value greater than {0}", expected ) ); |
||||
FailureMessage.AddActualLine(actual.ToString()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
@ -1,41 +0,0 @@
@@ -1,41 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace NUnit.Framework |
||||
{ |
||||
/// <summary>
|
||||
/// Class to assert that the actual value is greater than the expected value.
|
||||
/// </summary>
|
||||
public class LessAsserter : ComparisonAsserter |
||||
{ |
||||
/// <summary>
|
||||
/// Constructs a GreaterAsserter for two objects implementing IComparable
|
||||
/// </summary>
|
||||
/// <param name="expected">The expected value</param>
|
||||
/// <param name="actual">The actual value</param>
|
||||
/// <param name="message">The message to issue on failure</param>
|
||||
/// <param name="args">Arguments to apply in formatting the message</param>
|
||||
public LessAsserter( IComparable expected, IComparable actual, string message, params object[] args ) |
||||
: base( expected, actual, message, args ) { } |
||||
|
||||
/// <summary>
|
||||
/// Test whether the actual is greater than the expected, building up
|
||||
/// the failure message for later use if they are not.
|
||||
/// </summary>
|
||||
/// <returns>True if actual is greater than expected</returns>
|
||||
public override bool Test() |
||||
{ |
||||
if ( ((IComparable)expected).CompareTo(actual) < 0 ) return true; |
||||
|
||||
DisplayDifferences(); |
||||
return false; |
||||
} |
||||
|
||||
private void DisplayDifferences() |
||||
{ |
||||
FailureMessage.AddExpectedLine( string.Format( "Value less than {0}", expected ) ); |
||||
FailureMessage.AddActualLine(actual.ToString()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
@ -1,31 +0,0 @@
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0"?> |
||||
<project name="NUnit.Framework" default="build"> |
||||
|
||||
<include buildfile="../../nunit.project.include"/> |
||||
|
||||
<property name="current.build.output" value="nunit.framework"/> |
||||
|
||||
<target name="build" depends="make-build-dir"> |
||||
<csc target="library" |
||||
output="${current.build.dir}/nunit.framework.dll" |
||||
debug="${build.debug}" |
||||
define="${build.defines.csc},StronglyNamedAssembly" |
||||
nowarn="618,672"> |
||||
<sources basedir="."> |
||||
<include name="*.cs"/> |
||||
<include name="../../CommonAssemblyInfo.cs"/> |
||||
</sources> |
||||
</csc> |
||||
</target> |
||||
|
||||
<target name="package"> |
||||
<copy todir="${package.src.dir}/NUnitFramework/framework"> |
||||
<fileset basedir="."> |
||||
<include name="*.csproj"/> |
||||
<include name="*.build"/> |
||||
<include name="*.snk"/> |
||||
<include name="*.cs"/> |
||||
</fileset> |
||||
</copy> |
||||
</target> |
||||
</project> |
@ -1,145 +0,0 @@
@@ -1,145 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<ProjectType>Local</ProjectType> |
||||
<ProductVersion>8.0.50727</ProductVersion> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
<ProjectGuid>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<AssemblyName>nunit.framework</AssemblyName> |
||||
<DefaultClientScript>JScript</DefaultClientScript> |
||||
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> |
||||
<DefaultTargetSchema>IE50</DefaultTargetSchema> |
||||
<DelaySign>false</DelaySign> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>NUnit.Framework</RootNamespace> |
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> |
||||
<SignAssembly>true</SignAssembly> |
||||
<OutputPath>..\..\..\bin\</OutputPath> |
||||
<AssemblyOriginatorKeyFile>nunit.key</AssemblyOriginatorKeyFile> |
||||
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release2005|AnyCPU' "> |
||||
<DefineConstants>TRACE;VS2005</DefineConstants> |
||||
<BaseAddress>285212672</BaseAddress> |
||||
<DocumentationFile>nunit.framework.xml</DocumentationFile> |
||||
<Optimize>true</Optimize> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug2005|AnyCPU' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DefineConstants>TRACE;DEBUG;VS2005</DefineConstants> |
||||
<BaseAddress>285212672</BaseAddress> |
||||
<DocumentationFile>nunit.framework.xml</DocumentationFile> |
||||
<NoWarn>1701;1702;1699</NoWarn> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System"> |
||||
<Name>System</Name> |
||||
</Reference> |
||||
<Reference Include="System.Data"> |
||||
<Name>System.Data</Name> |
||||
</Reference> |
||||
<Reference Include="System.Xml"> |
||||
<Name>System.XML</Name> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="CommonAssemblyInfo.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="AbstractAsserter.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="AssemblyInfo.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Assert.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Assertion.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="AssertionException.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="AssertionFailureMessage.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="CategoryAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="ComparisonAsserter.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="ConditionAsserters.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="EqualAsserter.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="EqualityAsserter.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="ExpectedExceptionAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="ExplicitAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="GreaterAsserter.cs" /> |
||||
<Compile Include="IAsserter.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="IgnoreAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="IgnoreException.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="LessAsserter.cs" /> |
||||
<Compile Include="ListContentsAsserter.cs" /> |
||||
<Compile Include="NotEqualAsserter.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="NotSameAsserter.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="OldTestCase.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="PlatformAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="SameAsserter.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="SetUpAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="SetUpFixtureAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="StringAssert.cs" /> |
||||
<Compile Include="StringAsserters.cs" /> |
||||
<Compile Include="SuiteAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="TearDownAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="TestAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="TestFixtureAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="TestFixtureSetUpAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="TestFixtureTearDownAttribute.cs"> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="TypeAsserters.cs" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
||||
</Project> |
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue