Browse Source

Nunit pad is now working again. Switched to NUnit 2.2.2

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@13 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mike Krüger 21 years ago
parent
commit
46f512d117
  1. 7
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/ApplicationSettings.cs
  3. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildEvents.cs
  4. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.cs
  5. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/DebugOptions.cs
  6. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/Signing.cs
  7. 40
      src/AddIns/Misc/NUnitPad/Project/NUnitPad.csproj
  8. 2
      src/AddIns/Misc/NUnitPad/Project/NUnitPad.csproj.user
  9. 34
      src/AddIns/Misc/NUnitPad/Project/Src/Gui/NUnitPadContent.cs
  10. 4
      src/AddIns/Misc/NUnitPad/Project/Src/Gui/TestTreeView.cs
  11. 2
      src/Libraries/NRefactory/Project/NRefactory.csproj
  12. 38
      src/Libraries/NUnitFramework/license.rtf
  13. BIN
      src/Libraries/NUnitFramework/nunit.key
  14. BIN
      src/Libraries/NUnitFramework/resources/NUnit.Util.Transform.resources
  15. 63
      src/Libraries/NUnitFramework/src/core/AssemblyInfo.cs
  16. 107
      src/Libraries/NUnitFramework/src/core/CategoryFilter.cs
  17. 33
      src/Libraries/NUnitFramework/src/core/CategoryManager.cs
  18. 29
      src/Libraries/NUnitFramework/src/core/EmptyFilter.cs
  19. 89
      src/Libraries/NUnitFramework/src/core/EventListener.cs
  20. 99
      src/Libraries/NUnitFramework/src/core/ExpectedExceptionTestCase.cs
  21. 47
      src/Libraries/NUnitFramework/src/core/Filter.cs
  22. 126
      src/Libraries/NUnitFramework/src/core/ITest.cs
  23. 82
      src/Libraries/NUnitFramework/src/core/ITestEvents.cs
  24. 67
      src/Libraries/NUnitFramework/src/core/InvalidSuiteException.cs
  25. 57
      src/Libraries/NUnitFramework/src/core/InvalidTestFixtureException.cs
  26. 64
      src/Libraries/NUnitFramework/src/core/LegacySuite.cs
  27. 58
      src/Libraries/NUnitFramework/src/core/LongLivingMarshalByRefObject.cs
  28. 58
      src/Libraries/NUnitFramework/src/core/NameFilter.cs
  29. 23
      src/Libraries/NUnitFramework/src/core/NamespaceSuite.cs
  30. 51
      src/Libraries/NUnitFramework/src/core/NoTestFixturesException.cs
  31. 57
      src/Libraries/NUnitFramework/src/core/NormalTestCase.cs
  32. 74
      src/Libraries/NUnitFramework/src/core/NotRunnableTestCase.cs
  33. 62
      src/Libraries/NUnitFramework/src/core/NullListener.cs
  34. 73
      src/Libraries/NUnitFramework/src/core/NunitException.cs
  35. 409
      src/Libraries/NUnitFramework/src/core/Reflect.cs
  36. 558
      src/Libraries/NUnitFramework/src/core/RemoteTestRunner.cs
  37. 42
      src/Libraries/NUnitFramework/src/core/ResultVisitor.cs
  38. 70
      src/Libraries/NUnitFramework/src/core/Results.xsd
  39. 43
      src/Libraries/NUnitFramework/src/core/RootTestSuite.cs
  40. 150
      src/Libraries/NUnitFramework/src/core/StringTextWriter.cs
  41. 47
      src/Libraries/NUnitFramework/src/core/Summary.xslt
  42. 239
      src/Libraries/NUnitFramework/src/core/TemplateTestCase.cs
  43. 311
      src/Libraries/NUnitFramework/src/core/Test.cs
  44. 70
      src/Libraries/NUnitFramework/src/core/TestAssembly.cs
  45. 107
      src/Libraries/NUnitFramework/src/core/TestCase.cs
  46. 177
      src/Libraries/NUnitFramework/src/core/TestCaseBuilder.cs
  47. 77
      src/Libraries/NUnitFramework/src/core/TestCaseResult.cs
  48. 198
      src/Libraries/NUnitFramework/src/core/TestEventArgs.cs
  49. 169
      src/Libraries/NUnitFramework/src/core/TestEventDispatcher.cs
  50. 166
      src/Libraries/NUnitFramework/src/core/TestFixture.cs
  51. 211
      src/Libraries/NUnitFramework/src/core/TestResult.cs
  52. 189
      src/Libraries/NUnitFramework/src/core/TestRunner.cs
  53. 162
      src/Libraries/NUnitFramework/src/core/TestRunnerThread.cs
  54. 275
      src/Libraries/NUnitFramework/src/core/TestSuite.cs
  55. 317
      src/Libraries/NUnitFramework/src/core/TestSuiteBuilder.cs
  56. 111
      src/Libraries/NUnitFramework/src/core/TestSuiteResult.cs
  57. 77
      src/Libraries/NUnitFramework/src/core/nunit.core.build
  58. 328
      src/Libraries/NUnitFramework/src/core/nunit.core.dll.csproj
  59. 63
      src/Libraries/NUnitFramework/src/framework/AssemblyInfo.cs
  60. 781
      src/Libraries/NUnitFramework/src/framework/Assert.cs
  61. 190
      src/Libraries/NUnitFramework/src/framework/Assertion.cs
  62. 68
      src/Libraries/NUnitFramework/src/framework/AssertionException.cs
  63. 758
      src/Libraries/NUnitFramework/src/framework/AssertionFailureMessage.cs
  64. 60
      src/Libraries/NUnitFramework/src/framework/CategoryAttribute.cs
  65. 82
      src/Libraries/NUnitFramework/src/framework/ExpectedExceptionAttribute.cs
  66. 21
      src/Libraries/NUnitFramework/src/framework/ExplicitAttribute.cs
  67. 59
      src/Libraries/NUnitFramework/src/framework/IgnoreAttribute.cs
  68. 68
      src/Libraries/NUnitFramework/src/framework/IgnoreException.cs
  69. 58
      src/Libraries/NUnitFramework/src/framework/OldTestCase.cs
  70. 40
      src/Libraries/NUnitFramework/src/framework/SetUpAttribute.cs
  71. 40
      src/Libraries/NUnitFramework/src/framework/SuiteAttribute.cs
  72. 40
      src/Libraries/NUnitFramework/src/framework/TearDownAttribute.cs
  73. 69
      src/Libraries/NUnitFramework/src/framework/TestAttribute.cs
  74. 56
      src/Libraries/NUnitFramework/src/framework/TestFixtureAttribute.cs
  75. 41
      src/Libraries/NUnitFramework/src/framework/TestFixtureSetUpAttribute.cs
  76. 42
      src/Libraries/NUnitFramework/src/framework/TestFixtureTearDownAttribute.cs
  77. 47
      src/Libraries/NUnitFramework/src/framework/nunit.framework.build
  78. 200
      src/Libraries/NUnitFramework/src/framework/nunit.framework.dll.csproj
  79. 87
      src/Libraries/NUnitFramework/src/util/AssemblyInfo.cs
  80. 107
      src/Libraries/NUnitFramework/src/util/AssemblyList.cs
  81. 75
      src/Libraries/NUnitFramework/src/util/AssemblyListItem.cs
  82. 138
      src/Libraries/NUnitFramework/src/util/AssemblyWatcher.cs
  83. 285
      src/Libraries/NUnitFramework/src/util/CommandLineOptions.cs
  84. 227
      src/Libraries/NUnitFramework/src/util/ConsoleOptions.cs
  85. 73
      src/Libraries/NUnitFramework/src/util/ConsoleWriter.cs
  86. 194
      src/Libraries/NUnitFramework/src/util/FormSettings.cs
  87. 94
      src/Libraries/NUnitFramework/src/util/GuiOptions.cs
  88. 54
      src/Libraries/NUnitFramework/src/util/ITestEvents.cs
  89. 113
      src/Libraries/NUnitFramework/src/util/ITestLoader.cs
  90. 57
      src/Libraries/NUnitFramework/src/util/NUnitGuiSettings.cs
  91. 612
      src/Libraries/NUnitFramework/src/util/NUnitProject.cs
  92. 129
      src/Libraries/NUnitFramework/src/util/NUnitRegistry.cs
  93. 108
      src/Libraries/NUnitFramework/src/util/OptionSettings.cs
  94. 339
      src/Libraries/NUnitFramework/src/util/ProjectConfig.cs
  95. 169
      src/Libraries/NUnitFramework/src/util/ProjectConfigCollection.cs
  96. 81
      src/Libraries/NUnitFramework/src/util/ProjectFormatException.cs
  97. 162
      src/Libraries/NUnitFramework/src/util/ProjectPath.cs
  98. 173
      src/Libraries/NUnitFramework/src/util/RecentFileSettings.cs
  99. 60
      src/Libraries/NUnitFramework/src/util/RecentProjectSettings.cs
  100. 263
      src/Libraries/NUnitFramework/src/util/RegistrySettingsStorage.cs
  101. Some files were not shown because too many files have changed in this diff Show More

7
AddIns/ICSharpCode.SharpDevelop.addin

@ -344,6 +344,13 @@ @@ -344,6 +344,13 @@
label = "${res:ProjectComponent.ContextMenu.Open}"
icon = "Icons.16x16.OpenFileIcon"
class = "ICSharpCode.SharpDevelop.Project.Commands.OpenFileEvent"/>
<Condition name = "Ownerstate" ownerstate = "Missing">
<MenuItem id = "Remove"
label = "Remove"
type = "Item"
icon = "Icons.16x16.DeleteIcon"
class = "ICSharpCode.SharpDevelop.Project.Commands.DeleteProjectBrowserNode"/>
</Condition>
<ComplexCondition>
<Not>
<Condition name = "Ownerstate" ownerstate = "Missing"/>

1
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/ApplicationSettings.cs

@ -75,6 +75,7 @@ namespace CSharpBinding.OptionPanels @@ -75,6 +75,7 @@ namespace CSharpBinding.OptionPanels
project.ApplicationIcon = Get<ComboBox>("applicationIcon").Text;
project.Win32Resource = Get<ComboBox>("win32ResourceFile").Text;
project.Name = Path.GetFileNameWithoutExtension(Get<TextBox>("projectFile").Text);
project.Save();
return true;
}

1
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildEvents.cs

@ -48,6 +48,7 @@ namespace CSharpBinding.OptionPanels @@ -48,6 +48,7 @@ namespace CSharpBinding.OptionPanels
project.PreBuildEvent = Get<TextBox>("preBuildEvent").Text;
project.PostBuildEvent = Get<TextBox>("postBuildEvent").Text;
project.RunPostBuildEvent = (RunPostBuildEvent)Get<ComboBox>("runPostBuildEvent").SelectedIndex;
project.Save();
return true;
}
}

1
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.cs

@ -116,6 +116,7 @@ namespace CSharpBinding.OptionPanels @@ -116,6 +116,7 @@ namespace CSharpBinding.OptionPanels
}
project.SetRegisterForComInterop(Config, Platform, Get<CheckBox>("registerCOMInterop").Checked);
project.Save();
return true;
}

1
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/DebugOptions.cs

@ -79,6 +79,7 @@ namespace CSharpBinding.OptionPanels @@ -79,6 +79,7 @@ namespace CSharpBinding.OptionPanels
} else {
project.SetStartAction(Config, Platform, StartAction.StartURL);
}
project.Save();
return true;
}

1
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/Signing.cs

@ -74,6 +74,7 @@ namespace CSharpBinding.OptionPanels @@ -74,6 +74,7 @@ namespace CSharpBinding.OptionPanels
} else if (Get<RadioButton>("useKeyProvider").Checked) {
project.AssemblyOriginatorKeyMode = AssemblyOriginatorKeyMode.Provider;
}
project.Save();
return true;
}

40
src/AddIns/Misc/NUnitPad/Project/NUnitPad.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -12,6 +12,10 @@ @@ -12,6 +12,10 @@
<NoStdLib>False</NoStdLib>
<NoConfig>False</NoConfig>
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent>
<OutputType>Library</OutputType>
<StartupObject />
<ApplicationIcon />
<Win32Resource />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
@ -30,29 +34,43 @@ @@ -30,29 +34,43 @@
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.core, Version=2.2.2.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<HintPath>..\..\..\..\..\bin\nunit.core.dll</HintPath>
</Reference>
<Reference Include="nunit.extensions, Version=2.2.2.0, Culture=neutral">
<HintPath>..\..\..\..\..\bin\nunit.extensions.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.2.2.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<HintPath>..\..\..\..\..\bin\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="ICSharpCode.Core.dll">
<HintPath>..\..\..\..\..\bin\ICSharpCode.Core.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Gui\NUnitPadContent.cs" />
<Compile Include="Gui\TestTreeView.cs">
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\Commands\MenuCommands.cs" />
<Compile Include="Src\Commands\TestTreeViewContextMenuCommands.cs" />
<Compile Include="Src\Gui\NUnitPadContent.cs" />
<Compile Include="Src\Gui\TestTreeView.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Commands\TestTreeViewContextMenuCommands.cs" />
<Compile Include="Commands\MenuCommands.cs" />
<None Include="NUnitPad.addin">
<CopyToOutputDirectory>True</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Src\ICSharpCode.SharpDevelop.csproj">
<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>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />

2
src/AddIns/Misc/NUnitPad/Project/NUnitPad.csproj.user

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<StartProgram>..\..\..\..\..\bin\SharpDevelop.exe</StartProgram>
</PropertyGroup>

34
src/AddIns/Misc/NUnitPad/Project/Src/Gui/NUnitPadContent.cs

@ -12,7 +12,7 @@ using System.Windows.Forms; @@ -12,7 +12,7 @@ using System.Windows.Forms;
using NUnit.Core;
using NUnit.Framework;
using NUnit.Util;
using NUnit.Extensions;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.Core;
@ -133,16 +133,13 @@ namespace ICSharpCode.NUnitPad @@ -133,16 +133,13 @@ namespace ICSharpCode.NUnitPad
void AddNUnitReference(object sender, EventArgs e)
{
// TODO: Add NUnit reference.
// IProject project = ProjectService.CurrentProject;
// if (project != null) {
// foreach (ProjectReference reference in project.ProjectReferences) {
// if (reference.ReferenceType == ReferenceType.Gac && reference.Reference.ToLower().StartsWith("nunit.framework")) {
// return;
// }
// }
// projectService.AddReferenceToProject(project, new ProjectReference(ReferenceType.Gac, "nunit.framework"));
// }
if (ProjectService.CurrentProject != null) {
Console.WriteLine("Add reference!");
ProjectService.AddReference(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "nunit.framework"));
ProjectService.CurrentProject.Save();
} else {
Console.WriteLine("prj == null");
}
}
void RunItemClick(object sender, EventArgs e)
@ -172,11 +169,11 @@ namespace ICSharpCode.NUnitPad @@ -172,11 +169,11 @@ namespace ICSharpCode.NUnitPad
void UnloadAppDomains()
{
foreach (TestDomain domain in testDomains) {
/*foreach (TestDomain domain in testDomains) {
try {
domain.Unload();
} catch (Exception) {}
}
}*/
testDomains.Clear();
testTreeView.ClearTests();
}
@ -196,15 +193,12 @@ namespace ICSharpCode.NUnitPad @@ -196,15 +193,12 @@ namespace ICSharpCode.NUnitPad
foreach (IProject project in ProjectService.OpenSolution.Projects) {
string outputAssembly = project.OutputAssemblyFullPath;
TestDomain testDomain = new TestDomain();
try {
Test testsFromAssembly = testDomain.Load(outputAssembly);
testTreeView.PrintTests(outputAssembly, testsFromAssembly);
testDomains.Add(testDomain);
TestSuiteBuilder builder = new TestSuiteBuilder();
Test testDomain = builder.Build(outputAssembly);
testTreeView.PrintTests(outputAssembly, testDomain);
} catch (Exception e) {
testDomain.Unload();
Console.WriteLine(e);
testTreeView.PrintTestErrors(outputAssembly);
testTreeView.PrintTestErrors(outputAssembly, e);
}
}

4
src/AddIns/Misc/NUnitPad/Project/Src/Gui/TestTreeView.cs

@ -133,11 +133,11 @@ namespace ICSharpCode.NUnitPad @@ -133,11 +133,11 @@ namespace ICSharpCode.NUnitPad
}
}
public void PrintTestErrors(string assembly)
public void PrintTestErrors(string assembly, Exception e)
{
TreeNode assemblyNode = new TreeNode(Path.GetFileName(assembly));
TreeNode failedNode = new TreeNode(StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.LoadingErrorNode}"));
TreeNode failedNode = new TreeNode(StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.LoadingErrorNode}") + ":" + e.Message);
failedNode.ImageIndex = failedNode.SelectedImageIndex = 5;
assemblyNode.Nodes.Add(failedNode);

2
src/Libraries/NRefactory/Project/NRefactory.csproj

@ -198,4 +198,4 @@ @@ -198,4 +198,4 @@
<Folder Include="Src\Parser\AST\VBNet\Tests\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>
</Project>

38
src/Libraries/NUnitFramework/license.rtf

@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch13\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}{\f13\fnil\fcharset134\fprq2{\*\panose 02010600030101010101}SimSun{\*\falt ???\'a1\'ec??};}{\f36\fnil\fcharset134\fprq2{\*\panose 00000000000000000000}@SimSun;}
{\f39\froman\fcharset238\fprq2 Times New Roman CE;}{\f40\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f42\froman\fcharset161\fprq2 Times New Roman Greek;}{\f43\froman\fcharset162\fprq2 Times New Roman Tur;}
{\f44\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f45\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f46\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f47\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}
{\f59\fmodern\fcharset238\fprq1 Courier New CE;}{\f60\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f62\fmodern\fcharset161\fprq1 Courier New Greek;}{\f63\fmodern\fcharset162\fprq1 Courier New Tur;}{\f64\fmodern\fcharset177\fprq1 Courier New (Hebrew);}
{\f65\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f66\fmodern\fcharset186\fprq1 Courier New Baltic;}{\f67\fmodern\fcharset163\fprq1 Courier New (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;
\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;
\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe2052\loch\f0\hich\af0\dbch\af13\cgrid\langnp1033\langfenp2052 \snext0 Normal;}{\*\cs10
\additive \ssemihidden Default Paragraph Font;}{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\loch\f0\hich\af0\dbch\af13\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}{
\s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1033\langfe2052\loch\f2\hich\af2\dbch\af13\cgrid\langnp1033\langfenp2052 \sbasedon0 \snext15 \styrsid9332467 Plain Text;}}{\*\rsidtbl \rsid610709\rsid818068
\rsid7476632\rsid8721477\rsid9332467\rsid10426157\rsid11172945\rsid15552035}{\*\generator Microsoft Word 10.0.3416;}{\info{\title Copyright (c) 2002 James W}{\author James Newkirk}{\operator James Newkirk}{\creatim\yr2002\mo9\dy11\hr14\min43}
{\revtim\yr2003\mo2\dy28\hr3}{\version6}{\edmins3}{\nofpages1}{\nofwords155}{\nofchars886}{\*\company Nascent Software, Inc.}{\nofcharsws1039}{\vern16453}}\margl1319\margr1319
\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1319\dgvorigin1440\dghshow1\dgvshow1
\jexpand\viewkind1\viewscale120\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct\asianbrkrule\rsidroot15552035 \fet0\sectd
\linex0\endnhere\sectlinegrid360\sectdefaultcl\sectrsid9332467\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}
{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang
{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain
\s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid9332467 \fs20\lang1033\langfe2052\loch\af2\hich\af2\dbch\af13\cgrid\langnp1033\langfenp2052 {\insrsid610709\charrsid9332467 \hich\af2\dbch\af13\loch\f2 Copyright }{
\insrsid10426157 \loch\af2\dbch\af13\hich\f2 \'a9\loch\f2 }{\insrsid610709\charrsid9332467 \hich\af2\dbch\af13\loch\f2 2002}{\insrsid8721477 \hich\af2\dbch\af13\loch\f2 -2003}{\insrsid610709\charrsid9332467 \hich\af2\dbch\af13\loch\f2
James W. Newkirk, Mich}{\insrsid7476632 \hich\af2\dbch\af13\loch\f2 ael C. Two, Alexei A. Vorontsov, Charlie Poole
\par }{\insrsid8721477 \hich\af2\dbch\af13\loch\f2 \hich\f2 Copyright \'a9\loch\f2 2000-2003}{\insrsid610709\charrsid9332467 \hich\af2\dbch\af13\loch\f2 Philip A. Craig
\par
\par \hich\af2\dbch\af13\loch\f2 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.
\par
\par \hich\af2\dbch\af13\loch\f2 Permission is granted to anyone to use this software for any purpose, including \hich\af2\dbch\af13\loch\f2 commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
\par
\par \hich\af2\dbch\af13\loch\f2 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 p\hich\af2\dbch\af13\loch\f2
roduct, an acknowledgment (see the following) in the product documentation is required.
\par
\par \hich\af2\dbch\af13\loch\f2 Portions Copyright }{\insrsid10426157 \loch\af2\dbch\af13\hich\f2 \'a9\loch\f2 2002}{\insrsid8721477 \hich\af2\dbch\af13\loch\f2 -2003}{\insrsid10426157 \hich\af2\dbch\af13\loch\f2 James W. Newkirk, }{
\insrsid610709\charrsid9332467 \hich\af2\dbch\af13\loch\f2 Michael C. Two, Alexei A. Vorontsov, Charlie Poole or Copyright }{\insrsid10426157 \loch\af2\dbch\af13\hich\f2 \'a9}{\insrsid8721477 \hich\af2\dbch\af13\loch\f2 2000-2003}{\insrsid610709\charrsid9332467
\hich\af2\dbch\af13\loch\f2 Philip A. Craig
\par
\par \hich\af2\dbch\af13\loch\f2 2. Altered source versions must be plainly ma\hich\af2\dbch\af13\loch\f2 rked as such, and must not be misrepresented as being the original software.
\par
\par \hich\af2\dbch\af13\loch\f2 3. This notice may not be removed or altered from any source distribution.}{\insrsid9332467
\par }}

BIN
src/Libraries/NUnitFramework/nunit.key

Binary file not shown.

BIN
src/Libraries/NUnitFramework/resources/NUnit.Util.Transform.resources

Binary file not shown.

63
src/Libraries/NUnitFramework/src/core/AssemblyInfo.cs

@ -1,63 +0,0 @@ @@ -1,63 +0,0 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: CLSCompliant(true)]
//
// General Information about an assembly 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("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[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.0.0")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
#if !StronglyNamedAssembly
[assembly: AssemblyDelaySign(false)]
#else
[assembly: AssemblyKeyFile("..\\nunit.key")]
[assembly: AssemblyKeyName("")]
#endif

107
src/Libraries/NUnitFramework/src/core/CategoryFilter.cs

@ -1,107 +0,0 @@ @@ -1,107 +0,0 @@
using System;
using System.Collections;
namespace NUnit.Core
{
/// <summary>
/// Summary description for CategoryFilter.
/// </summary>
///
[Serializable]
public class CategoryFilter : Filter
{
ArrayList categories;
public CategoryFilter() : this( false ) { }
public CategoryFilter( bool exclude ) : base( exclude )
{
categories = new ArrayList();
}
public CategoryFilter( string name ) : this( name, false ) { }
public CategoryFilter( string name, bool exclude ) : base( exclude )
{
categories = new ArrayList();
categories.Add( name );
}
public CategoryFilter( string[] names ) : this( names, false ) { }
public CategoryFilter( string[] names, bool exclude ) : base( exclude )
{
categories = new ArrayList();
categories.AddRange( names );
}
public void AddCategory(string name)
{
categories.Add( name );
}
#region IFilter Members
public override bool Pass(TestSuite suite)
{
// return CheckCategories( suite ) ? !Exclude : Exclude;
if ( categories.Count == 0 ) return true;
bool pass = Exclude;
if (CheckCategories(suite))
return !Exclude;
foreach (Test test in suite.Tests)
{
if ( test.Filter(this) == !Exclude )
{
pass=true;
break;
}
}
return pass;
}
public override bool Pass(TestCase test)
{
if ( categories.Count == 0 )
return true;
return CheckCategories( test ) ? !Exclude : Exclude ;
// if (CheckCategories(test.Parent))
// return true;
//
// return CheckCategories(test);
}
#endregion
/// <summary>
/// Method returns true if the test has a particular
/// category or if an ancestor test does. We don't
/// worry about whether this is an include or an
/// exclude filter at this point because only positive
/// categories are inherited, not their absence.
/// </summary>
private bool CheckCategories(Test test)
{
return test.HasCategory( categories )
|| test.Parent != null
&& test.Parent.HasCategory( categories );
// if (test.Categories != null)
// {
// foreach (string name in categories)
// {
// if (test.Categories.Contains(name))
// return true;
// }
// }
//
// return false;
}
}
}

33
src/Libraries/NUnitFramework/src/core/CategoryManager.cs

@ -1,33 +0,0 @@ @@ -1,33 +0,0 @@
using System;
using System.Collections;
namespace NUnit.Core
{
public class CategoryManager
{
private static Hashtable categories = new Hashtable();
public static void Add(string name)
{
categories[name] = name;
}
public static void Add(IList list)
{
foreach(string name in list)
{
Add(name);
}
}
public static ICollection Categories
{
get { return categories.Values; }
}
public static void Clear()
{
categories = new Hashtable();
}
}
}

29
src/Libraries/NUnitFramework/src/core/EmptyFilter.cs

@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
using System;
namespace NUnit.Core
{
/// <summary>
/// Summary description for EmptyFilter.
/// </summary>
public class EmptyFilter : Filter
{
#region IFilter Members
public override bool Pass(TestSuite suite)
{
return true;
}
public override bool Pass(TestCase test)
{
return true;
}
#endregion
public static EmptyFilter Empty
{
get { return new EmptyFilter(); }
}
}
}

89
src/Libraries/NUnitFramework/src/core/EventListener.cs

@ -1,89 +0,0 @@ @@ -1,89 +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.Core
{
using System;
/// <summary>
/// The EventListener interface is used to receive notifications of
/// significant events while a test is being run.
/// </summary>
public interface EventListener
{
/// <summary>
/// Run is starting
/// </summary>
/// <param name="tests">Array of tests to be run</param>
void RunStarted( Test[] tests );
/// <summary>
/// Run finished successfully
/// </summary>
/// <param name="results">Array of test results</param>
void RunFinished( TestResult[] results );
/// <summary>
/// Run was terminated due to an exception
/// </summary>
/// <param name="exception">Exception that was thrown</param>
void RunFinished( Exception exception );
/// <summary>
/// A single test case is starting
/// </summary>
/// <param name="testCase">The test case</param>
void TestStarted(TestCase testCase);
/// <summary>
/// A test case finished
/// </summary>
/// <param name="result">Result of the test case</param>
void TestFinished(TestCaseResult result);
/// <summary>
/// A suite is starting
/// </summary>
/// <param name="suite">The suite that is starting</param>
void SuiteStarted(TestSuite suite);
/// <summary>
/// A suite finished
/// </summary>
/// <param name="result">Result of the suite</param>
void SuiteFinished(TestSuiteResult result);
/// <summary>
/// An unhandled exception occured while running a test,
/// but the test was not terminated.
/// </summary>
/// <param name="exception"></param>
void UnhandledException( Exception exception );
}
}

99
src/Libraries/NUnitFramework/src/core/ExpectedExceptionTestCase.cs

@ -1,99 +0,0 @@ @@ -1,99 +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.Core
{
using System;
using System.Diagnostics;
using System.Reflection;
/// <summary>
/// Summary description for ExpectedExceptionTestCase.
/// </summary>
public class ExpectedExceptionTestCase : TemplateTestCase
{
private Type expectedException;
private string expectedMessage;
public ExpectedExceptionTestCase(Type fixtureType, MethodInfo method) : base(fixtureType, method)
{
Initialize( method );
}
public ExpectedExceptionTestCase(object fixture, MethodInfo method) : base(fixture, method)
{
Initialize( method );
}
private void Initialize( MethodInfo method )
{
NUnit.Framework.ExpectedExceptionAttribute attribute =
Reflect.GetExpectedExceptionAttribute( method );
if ( attribute == null )
throw new InvalidTestFixtureException( "ExpectedExceptionAttribute not found" );
this.expectedException = attribute.ExceptionType;
this.expectedMessage = attribute.ExpectedMessage;
}
protected override internal void ProcessException(Exception exception, TestCaseResult testResult)
{
if (expectedException.Equals(exception.GetType()))
{
if (expectedMessage != null && !expectedMessage.Equals(exception.Message))
{
string message = string.Format("Expected exception to have message: \"{0}\" but received message \"{1}\"",
expectedMessage, exception.Message);
testResult.Failure(message, exception.StackTrace);
}
else
{
testResult.Success();
}
}
else if (exception is Framework.AssertionException)
{
RecordException(exception,testResult);
}
else
{
string message = "Expected: " + expectedException.Name + " but was " + exception.GetType().Name;
testResult.Failure(message, exception.StackTrace);
}
return;
}
protected override internal void ProcessNoException(TestCaseResult testResult)
{
testResult.Failure(expectedException.Name + " was expected", null);
}
}
}

47
src/Libraries/NUnitFramework/src/core/Filter.cs

@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@
using System;
using System.Collections;
namespace NUnit.Core
{
/// <summary>
/// Summary description for Filter.
/// </summary>
public interface IFilter
{
bool Pass(TestSuite suite);
bool Pass(TestCase test);
}
[Serializable]
public abstract class Filter : IFilter
{
private bool exclude;
public Filter() : this( false ) { }
public Filter( bool exclude )
{
this.exclude = exclude;
}
public bool Exclude
{
get { return exclude; }
set { exclude = value; }
}
public void Negate()
{
exclude = !exclude;
}
#region IFilter Members
public abstract bool Pass(TestSuite suite);
public abstract bool Pass(TestCase test);
#endregion
}
}

126
src/Libraries/NUnitFramework/src/core/ITest.cs

@ -1,126 +0,0 @@ @@ -1,126 +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.Core
{
using System;
using System.Collections;
/// <summary>
/// Common interface supported by all representations
/// of a test. Only includes informational fields.
/// The Run method is specifically excluded to allow
/// for data-only representations of a test.
/// </summary>
public interface ITest
{
/// <summary>
/// Name of the test
/// </summary>
string Name { get; }
/// <summary>
/// Full Name of the test
/// </summary>
string FullName { get; }
/// <summary>
/// Last part of the full name
/// </summary>
string ShortName { get; }
/// <summary>
/// Int used to distinguish suites of the same
/// name across multiple assemblies.
/// </summary>
int AssemblyKey { get; set; }
/// <summary>
/// Key used to look up a test in a hash table
/// </summary>
string UniqueName { get; }
/// <summary>
/// Whether or not the test should be run
/// </summary>
bool ShouldRun { get; set; }
/// <summary>
/// Reason for not running the test, if applicable
/// </summary>
string IgnoreReason { get; set; }
/// <summary>
/// Count of the test cases ( 1 if this is a test case )
/// </summary>
int CountTestCases();
/// <summary>
/// For a test suite, the child tests or suites
/// Null if this is not a test suite
/// </summary>
ArrayList Tests { get; }
/// <summary>
/// Categories available for this test
/// </summary>
IList Categories { get; }
bool HasCategory( string name );
bool HasCategory( IList names );
/// <summary>
/// True if this is a suite
/// </summary>
bool IsSuite { get; }
/// <summary>
/// True if this is a TestFixture
/// </summary>
bool IsFixture { get; }
/// <summary>
/// True if this is a TestCase
/// </summary>
bool IsTestCase { get; }
/// <summary>
/// Return the description field.
/// </summary>
string Description { get; set; }
/// <summary>
/// True if this should only be run explicitly - that is
/// if it was marked with the ExplicitAttribute.
/// </summary>
bool IsExplicit { get; set; }
}
}

82
src/Libraries/NUnitFramework/src/core/ITestEvents.cs

@ -1,82 +0,0 @@ @@ -1,82 +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.Core
{
/// <summary>
/// Defines events related to the loading of tests.
/// </summary>
public interface ILoadEvents
{
event TestEventHandler TestLoading;
event TestEventHandler TestLoaded;
event TestEventHandler TestLoadFailed;
event TestEventHandler TestReloading;
event TestEventHandler TestReloaded;
event TestEventHandler TestReloadFailed;
event TestEventHandler TestUnloading;
event TestEventHandler TestUnloaded;
event TestEventHandler TestUnloadFailed;
}
/// <summary>
/// Defines events related to the running of tests.
/// </summary>
public interface IRunEvents
{
// Events related to a running a set of tests
event TestEventHandler RunStarting;
event TestEventHandler RunFinished;
// Events that arise while a test is running
// These are translated from calls to the runner on the
// EventListener interface.
event TestEventHandler SuiteStarting;
event TestEventHandler SuiteFinished;
event TestEventHandler TestStarting;
event TestEventHandler TestFinished;
/// <summary>
/// An unhandled exception was thrown during a test run,
/// and it cannot be associated with a particular test failure.
/// </summary>
event TestEventHandler TestException;
}
/// <summary>
/// The combined interface, typically implemented by test runners.
/// </summary>
public interface ITestEvents : ILoadEvents, IRunEvents
{
}
}

67
src/Libraries/NUnitFramework/src/core/InvalidSuiteException.cs

@ -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.Core
{
using System;
using System.Runtime.Serialization;
[Serializable]
public class InvalidSuiteException : ApplicationException
{
public InvalidSuiteException () : base()
{}
/// <summary>
/// Standard constructor
/// </summary>
/// <param name="message">The error message that explains
/// the reason for the exception</param>
public InvalidSuiteException(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 InvalidSuiteException(string message, Exception inner) :
base(message, inner)
{}
/// <summary>
/// Serialization Constructor
/// </summary>
protected InvalidSuiteException(SerializationInfo info,
StreamingContext context) : base(info,context){}
}
}

57
src/Libraries/NUnitFramework/src/core/InvalidTestFixtureException.cs

@ -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-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.Core
{
using System;
using System.Runtime.Serialization;
/// <summary>
/// Summary description for NoTestMethodsException.
/// </summary>
///
[Serializable]
public class InvalidTestFixtureException : ApplicationException
{
public InvalidTestFixtureException() : base() {}
public InvalidTestFixtureException(string message) : base(message)
{}
public InvalidTestFixtureException(string message, Exception inner) : base(message, inner)
{}
/// <summary>
/// Serialization Constructor
/// </summary>
protected InvalidTestFixtureException(SerializationInfo info,
StreamingContext context) : base(info,context){}
}
}

64
src/Libraries/NUnitFramework/src/core/LegacySuite.cs

@ -1,64 +0,0 @@ @@ -1,64 +0,0 @@
using System;
using System.Reflection;
namespace NUnit.Core
{
/// <summary>
/// Represents a test suite constructed from a type that has a static Suite property
/// </summary>
public class LegacySuite : TestSuite
{
private PropertyInfo suiteProperty;
#region Constructors
public LegacySuite( Type fixtureType ) : base( fixtureType, 0 )
{
Initialize();
}
public LegacySuite( Type fixtureType, int assemblyKey ) : base( fixtureType, assemblyKey )
{
Initialize();
}
public LegacySuite( object fixture ) : base( fixture, 0 )
{
Initialize();
}
public LegacySuite( object fixture, int assemblyKey ) : base( fixture, assemblyKey )
{
Initialize();
}
private void Initialize()
{
suiteProperty = Reflect.GetSuiteProperty( this.fixtureType );
MethodInfo method = suiteProperty.GetGetMethod(true);
if(method.ReturnType!=typeof(NUnit.Core.TestSuite) || method.GetParameters().Length>0)
{
this.ShouldRun = false;
this.IgnoreReason = "Invalid suite property method signature";
}
else
{
TestSuite suite = (TestSuite)suiteProperty.GetValue(null, new Object[0]);
foreach( Test test in suite.Tests )
this.Add( test );
}
}
#endregion
#region Static methods
public static bool IsValidType( Type type )
{
return Reflect.GetSuiteProperty( type ) != null;
}
#endregion
}
}

58
src/Libraries/NUnitFramework/src/core/LongLivingMarshalByRefObject.cs

@ -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
using System;
namespace NUnit.Core
{
/// <summary>
/// All objects which are marshalled by reference
/// and whose lifetime is manually controlled by
/// the app, should derive from this class rather
/// than MarshalByRefObject.
///
/// This includes the remote test domain objects
/// which are accessed by the client and those
/// client objects which are called back by the
/// remote test domain.
///
/// Objects in this category that already inherit
/// from some other class (e.g. from TextWriter)
/// which in turn inherits from MarshalByRef object
/// should override InitializeLifetimeService to
/// return null to obtain the same effect.
/// </summary>
public class LongLivingMarshalByRefObject : MarshalByRefObject
{
public override Object InitializeLifetimeService()
{
return null;
}
}
}

58
src/Libraries/NUnitFramework/src/core/NameFilter.cs

@ -1,58 +0,0 @@ @@ -1,58 +0,0 @@
using System;
using System.Collections;
namespace NUnit.Core
{
/// <summary>
/// Summary description for NameFilter.
/// </summary>
///
[Serializable]
public class NameFilter : Filter
{
private ArrayList testNodes;
public NameFilter(Test node)
{
testNodes = new ArrayList();
testNodes.Add(node);
}
public NameFilter(ArrayList nodes)
{
testNodes = nodes;
}
public override bool Pass(TestSuite suite)
{
bool passed = Exclude;
foreach (Test node in testNodes)
{
if (suite.IsDescendant(node) || node.IsDescendant(suite) || node == suite)
{
passed = !Exclude;
break;
}
}
return passed;
}
public override bool Pass(TestCase test)
{
bool passed = Exclude;
foreach(Test node in testNodes)
{
if (test.IsDescendant(node) || test == node)
{
passed = !Exclude;
break;
}
}
return passed;
}
}
}

23
src/Libraries/NUnitFramework/src/core/NamespaceSuite.cs

@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
using System;
namespace NUnit.Core
{
/// <summary>
/// TestSuite containing all the test classes in a namespace
///
/// TODO: Add a fixture for holding setup and teardown
/// </summary>
public class NamespaceSuite : TestSuite
{
public NamespaceSuite( string name ) : base( name, 0 ) { }
public NamespaceSuite( string name, int assemblyKey )
: base( name, assemblyKey ) { }
public NamespaceSuite( string parentSuiteName, string name )
: base( parentSuiteName, name, 0 ) { }
public NamespaceSuite( string parentSuiteName, string name, int assemblyKey )
: base( parentSuiteName, name, assemblyKey ) { }
}
}

51
src/Libraries/NUnitFramework/src/core/NoTestFixturesException.cs

@ -1,51 +0,0 @@ @@ -1,51 +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.Core
{
using System;
using System.Runtime.Serialization;
/// <summary>
/// Summary description for NoTestFixtureException.
/// </summary>
[Serializable]
public class NoTestFixturesException : ApplicationException
{
public NoTestFixturesException() : base () {}
public NoTestFixturesException(string message) : base(message)
{}
public NoTestFixturesException(string message, Exception inner) : base(message, inner) {}
protected NoTestFixturesException(SerializationInfo info, StreamingContext context) : base(info, context)
{}
}
}

57
src/Libraries/NUnitFramework/src/core/NormalTestCase.cs

@ -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-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.Core
{
using System;
using System.Reflection;
/// <summary>
/// Summary description for TestCase.
/// </summary>
public class NormalTestCase : TemplateTestCase
{
public NormalTestCase(Type fixtureType, MethodInfo method) : base(fixtureType, method)
{}
public NormalTestCase(object fixture, MethodInfo method) : base(fixture, method)
{}
protected internal override void ProcessNoException(TestCaseResult testResult)
{
testResult.Success();
}
protected internal override void ProcessException(Exception exception, TestCaseResult testResult)
{
RecordException( exception, testResult );
}
}
}

74
src/Libraries/NUnitFramework/src/core/NotRunnableTestCase.cs

@ -1,74 +0,0 @@ @@ -1,74 +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;
using System.Reflection;
using System.Diagnostics;
namespace NUnit.Core
{
/// <summary>
/// Summary description for NotRunnableTestCase.
/// </summary>
public class NotRunnableTestCase : TestCase
{
public NotRunnableTestCase(MethodInfo method, string reason) : base(method.DeclaringType.FullName, method.Name)
{
ShouldRun = false;
IgnoreReason = reason;
}
public NotRunnableTestCase(MethodInfo method) : base(method.DeclaringType.FullName, method.Name)
{
string reason;
if (method.IsAbstract)
reason = "it must not be abstract";
else if (method.IsStatic)
reason = "it must be an instance method";
else if (!method.IsPublic)
reason = "it must be a public method";
else if (method.GetParameters().Length != 0)
reason = "it must not have parameters";
else if (!method.ReturnType.Equals(typeof(void)))
reason = "it must return void";
else
reason = "reason not known";
ShouldRun = false;
IgnoreReason = String.Format("Method {0}'s signature is not correct: {1}.", method.Name, reason);
}
public override void Run(TestCaseResult result)
{
result.NotRun(base.IgnoreReason);
}
}
}

62
src/Libraries/NUnitFramework/src/core/NullListener.cs

@ -1,62 +0,0 @@ @@ -1,62 +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.Core
{
/// <summary>
/// Summary description for NullListener.
/// </summary>
///
[Serializable]
public class NullListener : EventListener
{
public void RunStarted( Test[] tests ){ }
public void RunFinished( TestResult[] results ) { }
public void RunFinished( Exception exception ) { }
public void TestStarted(TestCase testCase){}
public void TestFinished(TestCaseResult result){}
public void SuiteStarted(TestSuite suite){}
public void SuiteFinished(TestSuiteResult result){}
public void UnhandledException( Exception exception ) {}
public static EventListener NULL
{
get { return new NullListener();}
}
}
}

73
src/Libraries/NUnitFramework/src/core/NunitException.cs

@ -1,73 +0,0 @@ @@ -1,73 +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.Core
{
using System;
using System.Runtime.Serialization;
/// <summary>
/// Thrown when an assertion failed. Here to preserve the inner
/// exception and hence its stack trace.
/// </summary>
///
[Serializable]
public class NunitException : ApplicationException
{
public NunitException () : base()
{}
/// <summary>
/// Standard constructor
/// </summary>
/// <param name="message">The error message that explains
/// the reason for the exception</param>
public NunitException(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 NunitException(string message, Exception inner) :
base(message, inner)
{}
/// <summary>
/// Serialization Constructor
/// </summary>
protected NunitException(SerializationInfo info,
StreamingContext context) : base(info,context){}
}
}

409
src/Libraries/NUnitFramework/src/core/Reflect.cs

@ -1,409 +0,0 @@ @@ -1,409 +0,0 @@
using System;
using System.Reflection;
using System.Collections;
using NUnit.Framework;
namespace NUnit.Core
{
/// <summary>
/// Helper methods for inspecting a type by reflection.
///
/// Many of these methods take a MemberInfo as an argument to avoid
/// duplication, even though certain attributes can only appear on
/// specific types of members, like MethodInfo or Type.
///
/// Generally, these methods perform simple utility functions like
/// checking for a given attribute. However, some of the methdods
/// actually implement policies, which might change at some later
/// time. The intent is that policies that may vary among different
/// types of test cases or suites should be handled by those types,
/// while common decisions are handled here.
/// </summary>
public class Reflect
{
#region Attribute types used by reflect
public static readonly Type TestFixtureType = typeof( TestFixtureAttribute );
public static readonly Type TestType = typeof( TestAttribute );
public static readonly Type SetUpType = typeof( SetUpAttribute );
public static readonly Type TearDownType = typeof( TearDownAttribute );
public static readonly Type FixtureSetUpType = typeof( TestFixtureSetUpAttribute );
public static readonly Type FixtureTearDownType = typeof( TestFixtureTearDownAttribute );
public static readonly Type ExplicitType = typeof( ExplicitAttribute );
public static readonly Type CategoryType = typeof( CategoryAttribute );
public static readonly Type IgnoreType = typeof( IgnoreAttribute );
public static readonly Type ExpectedExceptionType = typeof( ExpectedExceptionAttribute );
public static readonly Type SuiteType = typeof( SuiteAttribute );
#endregion
#region Binding flags used by reflect
private static readonly BindingFlags InstanceMethods =
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
private static readonly BindingFlags StaticMethods =
BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly;
private static readonly BindingFlags AllMethods =
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.Static;
private static readonly BindingFlags AllDeclaredMethods =
AllMethods | BindingFlags.DeclaredOnly;
#endregion
#region Check for presence of an attribute
public static bool HasTestFixtureAttribute(Type type)
{
return type.IsDefined( TestFixtureType, true ); // Inheritable
}
public static bool HasTestAttribute(MethodInfo method)
{
return method.IsDefined( TestType, false );
}
public static bool HasExplicitAttribute(MemberInfo member)
{
return member.IsDefined( ExplicitType, false );
}
public static bool HasCategoryAttribute(MemberInfo member)
{
return member.IsDefined( CategoryType, false );
}
public static bool HasExpectedExceptionAttribute(MethodInfo method)
{
return method.IsDefined( ExpectedExceptionType, false );
}
public static bool HasIgnoreAttribute( MemberInfo member )
{
return member.IsDefined( IgnoreType, false );
}
public static bool HasSuiteAttribute( PropertyInfo property )
{
return property.IsDefined( SuiteType, false );
}
#endregion
#region Legacy Checks on Names
public static bool IsObsoleteTestMethod(MethodInfo methodToCheck)
{
if ( methodToCheck.Name.ToLower().StartsWith("test") )
{
object[] attributes = methodToCheck.GetCustomAttributes( false );
foreach( Attribute attribute in attributes )
if( attribute is SetUpAttribute ||
attribute is TestFixtureSetUpAttribute ||
attribute is TearDownAttribute ||
attribute is TestFixtureTearDownAttribute )
{
return false;
}
return true;
}
return false;
}
#endregion
#region Get Attributes
public static TestFixtureAttribute GetTestFixtureAttribute( Type type )
{
object[] attributes = type.GetCustomAttributes( TestFixtureType, true );
return attributes.Length > 0 ? (TestFixtureAttribute) attributes[0] : null;
}
public static TestAttribute GetTestAttribute( MemberInfo member )
{
object[] attributes = member.GetCustomAttributes( TestType, false );
return attributes.Length > 0 ? (TestAttribute)attributes[0] : null;
}
public static IgnoreAttribute GetIgnoreAttribute( MemberInfo member )
{
object[] attributes = member.GetCustomAttributes( IgnoreType, false );
return attributes.Length > 0 ? (IgnoreAttribute) attributes[0] : null;
}
public static ExpectedExceptionAttribute GetExpectedExceptionAttribute( MethodInfo method )
{
object[] attributes = method.GetCustomAttributes( ExpectedExceptionType, false);
return attributes.Length > 0 ? (ExpectedExceptionAttribute) attributes[0] : null;
}
#endregion
#region Get Properties of Attributes
public static string GetIgnoreReason( MemberInfo member )
{
IgnoreAttribute attribute = GetIgnoreAttribute( member );
return attribute == null ? "no reason" : attribute.Reason;
}
public static string GetDescription( MethodInfo method )
{
TestAttribute attribute = GetTestAttribute( method );
return attribute == null ? null : attribute.Description;
}
public static string GetDescription( Type fixtureType )
{
TestFixtureAttribute attribute = GetTestFixtureAttribute( fixtureType );
return attribute == null ? null : attribute.Description;
}
#endregion
#region Methods to check validity of a type and its members
/// <summary>
/// Method to validate that a type is a valid test fixture
/// </summary>
/// <param name="fixtureType">The type to be checked</param>
public static void CheckFixtureType( Type fixtureType )
{
if ( fixtureType.GetConstructor( Type.EmptyTypes ) == null )
throw new InvalidTestFixtureException(fixtureType.FullName + " does not have a valid constructor");
CheckSetUpTearDownMethod( fixtureType, SetUpType );
CheckSetUpTearDownMethod( fixtureType, TearDownType );
CheckSetUpTearDownMethod( fixtureType, FixtureSetUpType );
CheckSetUpTearDownMethod( fixtureType, FixtureTearDownType );
}
/// <summary>
/// This method verifies that a type has no more than one method of a particular
/// SetUp or TearDown type and that the method has a correct signature.
/// </summary>
/// <param name="fixtureType">The type to be checked</param>
/// <param name="attributeType">The attribute to check for</param>
private static void CheckSetUpTearDownMethod( Type fixtureType, Type attributeType )
{
int count = 0;
MethodInfo theMethod = null;
foreach(MethodInfo method in fixtureType.GetMethods( AllDeclaredMethods ))
{
if( method.IsDefined( attributeType, false ) )
{
theMethod = method;
count++;
}
}
if ( count > 1 )
{
string attributeName = attributeType.Name;
if ( attributeName.EndsWith( "Attribute" ) )
attributeName = attributeName.Substring(
0, attributeName.Length - 9 );
throw new InvalidTestFixtureException(
string.Format( "{0} has multiple {1} methods",
fixtureType.Name, attributeName ) );
}
CheckSetUpTearDownSignature( theMethod );
}
private static void CheckSetUpTearDownSignature( MethodInfo method )
{
if ( method != null )
{
if ( !method.IsPublic && !method.IsFamily || method.IsStatic || method.ReturnType != typeof(void) || method.GetParameters().Length > 0 )
throw new InvalidTestFixtureException("Invalid SetUp or TearDown method signature");
}
}
/// <summary>
/// Check the signature of a test method
/// </summary>
/// <param name="methodToCheck">The method signature to check</param>
/// <returns>True if the signature is correct, otherwise false</returns>
public static bool IsTestMethodSignatureCorrect(MethodInfo methodToCheck)
{
return
!methodToCheck.IsStatic
&& !methodToCheck.IsAbstract
&& methodToCheck.IsPublic
&& methodToCheck.GetParameters().Length == 0
&& methodToCheck.ReturnType.Equals(typeof(void));
}
#endregion
#region Get Methods of a type
// These methods all take an object and assume that the type of the
// object was pre-checked so that there are no duplicate methods,
// statics, private methods, etc.
public static ConstructorInfo GetConstructor( Type fixtureType )
{
return fixtureType.GetConstructor( Type.EmptyTypes );
}
public static MethodInfo GetSetUpMethod( Type fixtureType )
{
return GetMethod( fixtureType, SetUpType );
}
public static MethodInfo GetTearDownMethod(Type fixtureType)
{
return GetMethod(fixtureType, TearDownType );
}
public static MethodInfo GetFixtureSetUpMethod( Type fixtureType )
{
return GetMethod( fixtureType, FixtureSetUpType );
}
public static MethodInfo GetFixtureTearDownMethod( Type fixtureType )
{
return GetMethod( fixtureType, FixtureTearDownType );
}
public static MethodInfo GetMethod( Type fixtureType, Type attributeType )
{
foreach(MethodInfo method in fixtureType.GetMethods( InstanceMethods ) )
{
if( method.IsDefined( attributeType, true ) )
return method;
}
return null;
}
public static MethodInfo GetMethod( Type fixtureType, string methodName )
{
foreach(MethodInfo method in fixtureType.GetMethods( InstanceMethods ) )
{
if( method.Name == methodName )
return method;
}
return null;
}
#endregion
#region Get Suite Property
public static PropertyInfo GetSuiteProperty( Type testClass )
{
if( testClass != null )
{
PropertyInfo[] properties = testClass.GetProperties( StaticMethods );
foreach( PropertyInfo property in properties )
{
if( Reflect.HasSuiteAttribute( property ) )
{
try
{
CheckSuiteProperty(property);
}
catch( InvalidSuiteException )
{
return null;
}
return property;
}
}
}
return null;
}
private static void CheckSuiteProperty(PropertyInfo property)
{
MethodInfo method = property.GetGetMethod(true);
if(method.ReturnType!=typeof(NUnit.Core.TestSuite))
throw new InvalidSuiteException("Invalid suite property method signature");
if(method.GetParameters().Length>0)
throw new InvalidSuiteException("Invalid suite property method signature");
}
#endregion
#region Categories
public static IList GetCategories( MemberInfo member )
{
object[] attributes = member.GetCustomAttributes( CategoryType, false );
IList names = new ArrayList();
foreach(CategoryAttribute attribute in attributes)
names.Add(attribute.Name);
return names;
}
#endregion
#region Invoke Methods
public static object Construct( Type type )
{
ConstructorInfo ctor = GetConstructor( type );
if ( ctor == null )
throw new InvalidTestFixtureException(type.FullName + " does not have a valid constructor");
return ctor.Invoke( Type.EmptyTypes );
}
public static void InvokeMethod( MethodInfo method, object fixture )
{
if(method != null)
{
try
{
method.Invoke( fixture, null );
}
catch(TargetInvocationException e)
{
Exception inner = e.InnerException;
throw new NunitException("Rethrown",inner);
}
}
}
public static void InvokeSetUp( object fixture )
{
MethodInfo method = GetSetUpMethod( fixture.GetType() );
if(method != null)
{
InvokeMethod(method, fixture);
}
}
public static void InvokeTearDown( object fixture )
{
MethodInfo method = GetTearDownMethod( fixture.GetType() );
if(method != null)
{
InvokeMethod(method, fixture);
}
}
#endregion
#region Private Constructor for static-only class
private Reflect() { }
#endregion
}
}

558
src/Libraries/NUnitFramework/src/core/RemoteTestRunner.cs

@ -1,558 +0,0 @@ @@ -1,558 +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.Core
{
using System;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Threading;
using System.Runtime.Remoting;
/// <summary>
/// Summary description for RemoteTestRunner.
/// </summary>
///
[Serializable]
public class RemoteTestRunner : LongLivingMarshalByRefObject, TestRunner, EventListener
{
#region Instance variables
/// <summary>
/// The loaded test suite
/// </summary>
private TestSuite suite;
/// <summary>
/// TestRunner thread used for asynchronous running
/// </summary>
private TestRunnerThread runningThread;
/// <summary>
/// Our writer for standard output
/// </summary>
private TextWriter outText;
/// <summary>
/// Our writer for error output
/// </summary>
private TextWriter errorText;
/// <summary>
/// Buffered standard output writer created for each test run
/// </summary>
private BufferedStringTextWriter outBuffer;
/// <summary>
/// Buffered error writer created for each test run
/// </summary>
private BufferedStringTextWriter errorBuffer;
/// <summary>
/// Console standard output to restore after a run
/// </summary>
private TextWriter saveOut;
/// <summary>
/// Console error output to restore after a run
/// </summary>
private TextWriter saveError;
/// <summary>
/// Saved current directory to restore after a run
/// </summary>
private string currentDirectory;
/// <summary>
/// Saved paths of the assemblies we loaded - used to set
/// current directory when we are running the tests.
/// </summary>
private string[] assemblies;
/// <summary>
/// Dispatcher used to put out runner's test events
/// </summary>
private TestEventDispatcher events = new TestEventDispatcher();
private EventListener listener; // Temp
private Version frameworkVersion;
private IFilter filter;
private bool displayTestLabels;
/// <summary>
/// Results from the last test run
/// </summary>
private TestResult[] results;
#endregion
#region Constructors
/// <summary>
/// Construct with stdOut and stdErr writers
/// </summary>
public RemoteTestRunner( TextWriter outText, TextWriter errorText )
{
this.outText = outText;
this.errorText = errorText;
}
/// <summary>
/// Default constructor uses Null writers.
/// </summary>
public RemoteTestRunner() : this( TextWriter.Null, TextWriter.Null ) { }
#endregion
#region Properties
/// <summary>
/// Writer for standard output - this is a public property
/// so that we can set it when creating an instance
/// in another AppDomain.
/// </summary>
public TextWriter Out
{
get { return outText; }
set { outText = value; }
}
/// <summary>
/// Writer for error output - this is a public property
/// so that we can set it when creating an instance
/// in another AppDomain.
/// </summary>
public TextWriter Error
{
get { return errorText; }
set { errorText = value; }
}
/// <summary>
/// Interface to the events sourced by the runner
/// </summary>
public ITestEvents Events
{
get { return events; }
}
public Version FrameworkVersion
{
get { return frameworkVersion; }
}
public bool DisplayTestLabels
{
get { return displayTestLabels; }
set { displayTestLabels = value; }
}
/// <summary>
/// Results from the last test run
/// </summary>
public TestResult[] Results
{
get { return results; }
}
/// <summary>
/// First (or only) result from the last test run
/// </summary>
public TestResult Result
{
get { return results == null ? null : results[0]; }
}
#endregion
#region Methods for Loading Tests
/// <summary>
/// Load an assembly
/// </summary>
/// <param name="assemblyName"></param>
public Test Load( string assemblyName )
{
this.assemblies = new string[] { assemblyName };
TestSuiteBuilder builder = new TestSuiteBuilder();
suite = builder.Build( assemblyName );
frameworkVersion = builder.FrameworkVersion;
return suite;
}
/// <summary>
/// Load a particular test in an assembly
/// </summary>
public Test Load( string assemblyName, string testName )
{
this.assemblies = new string[] { assemblyName };
TestSuiteBuilder builder = new TestSuiteBuilder();
suite = builder.Build( assemblyName, testName );
frameworkVersion = builder.FrameworkVersion;
return suite;
}
/// <summary>
/// Load multiple assemblies
/// </summary>
public Test Load( string projectName, string[] assemblies )
{
this.assemblies = (string[])assemblies.Clone();
TestSuiteBuilder builder = new TestSuiteBuilder();
suite = builder.Build( projectName, assemblies );
frameworkVersion = builder.FrameworkVersion;
return suite;
}
public Test Load( string projectName, string[] assemblies, string testName )
{
this.assemblies = (string[])assemblies.Clone();
TestSuiteBuilder builder = new TestSuiteBuilder();
suite = builder.Build( assemblies, testName );
frameworkVersion = builder.FrameworkVersion;
return suite;
}
public void Unload()
{
suite = null; // All for now
frameworkVersion = null;
}
#endregion
#region Methods for Counting TestCases
public int CountTestCases()
{
return suite.CountTestCases();
}
public int CountTestCases( string testName )
{
Test test = FindTest( suite, testName );
return test == null ? 0 : test.CountTestCases();
}
public int CountTestCases(string[] testNames )
{
int count = 0;
foreach( string testName in testNames)
count += CountTestCases( testName );
return count;
}
public ICollection GetCategories()
{
return CategoryManager.Categories;
}
#endregion
#region Methods for Running Tests
public void SetFilter( IFilter filter )
{
this.filter = filter;
}
public TestResult Run( EventListener listener )
{
return Run( listener, suite );
}
public TestResult Run(NUnit.Core.EventListener listener, string testName )
{
if ( testName == null || testName.Length == 0 )
return Run( listener, suite );
else
return Run( listener, FindTest( suite, testName ) );
}
public TestResult[] Run(NUnit.Core.EventListener listener, string[] testNames)
{
if ( testNames == null || testNames.Length == 0 )
return new TestResult[] { Run( listener, suite ) };
else
return Run( listener, FindTests( suite, testNames ) );
}
public void RunTest(NUnit.Core.EventListener listener )
{
runningThread = new TestRunnerThread( this );
runningThread.Run( listener );
}
public void RunTest(NUnit.Core.EventListener listener, string testName )
{
runningThread = new TestRunnerThread( this );
runningThread.Run( listener, testName );
}
public void RunTest(NUnit.Core.EventListener listener, string[] testNames)
{
runningThread = new TestRunnerThread( this );
runningThread.Run( listener, testNames );
}
public void CancelRun()
{
if ( runningThread != null )
runningThread.Cancel();
CleanUpAfterTestRun();
}
public void Wait()
{
if ( runningThread != null )
runningThread.Wait();
}
#endregion
#region Helper Routines
/// <summary>
/// Private method to run a single test
/// </summary>
private TestResult Run( EventListener listener, Test test )
{
// Create array with the one test
Test[] tests = new Test[] { test };
// Call our workhorse method
results = Run( listener, tests );
// Return the first result we got
return results[0];
}
/// <summary>
/// Private method to run a set of tests. This routine is the workhorse
/// that is called anytime tests are run.
/// </summary>
private TestResult[] Run( EventListener listener, Test[] tests )
{
// Create buffered writers for efficiency
outBuffer = new BufferedStringTextWriter( outText );
errorBuffer = new BufferedStringTextWriter( errorText );
// Save previous state of Console. This is needed because Console.Out and
// Console.Error are static. In the case where the test itself calls this
// method, we can lose output if we don't save and restore their values.
// This is exactly what happens when we are testing NUnit itself.
saveOut = Console.Out;
saveError = Console.Error;
// Set Console to go to our buffers. Note that any changes made by
// the user in the test code or the code it calls will defeat this.
Console.SetOut( outBuffer );
Console.SetError( errorBuffer );
// Save the current directory so we can run each test in
// the same directory as its assembly
currentDirectory = Environment.CurrentDirectory;
try
{
// Create an array for the resuls
results = new TestResult[ tests.Length ];
// Signal that we are starting the run
this.listener = listener;
listener.RunStarted( tests );
// TODO: Get rid of count
int count = 0;
foreach( Test test in tests )
count += filter == null ? test.CountTestCases() : test.CountTestCases( filter );
events.FireRunStarting( tests, count );
// Run each test, saving the results
int index = 0;
foreach( Test test in tests )
{
string assemblyDirectory = Path.GetDirectoryName( this.assemblies[test.AssemblyKey] );
if ( assemblyDirectory != null && assemblyDirectory != string.Empty )
Environment.CurrentDirectory = assemblyDirectory;
results[index++] = test.Run( this, filter );
}
// Signal that we are done
listener.RunFinished( results );
events.FireRunFinished( results );
// Return result array
return results;
}
catch( Exception exception )
{
// Signal that we finished with an exception
listener.RunFinished( exception );
events.FireRunFinished( exception );
// Rethrow - should we do this?
throw;
}
finally
{
CleanUpAfterTestRun();
}
}
private Test FindTest(Test test, string fullName)
{
if(test.UniqueName.Equals(fullName)) return test;
if(test.FullName.Equals(fullName)) return test;
Test result = null;
if(test is TestSuite)
{
TestSuite suite = (TestSuite)test;
foreach(Test testCase in suite.Tests)
{
result = FindTest(testCase, fullName);
if(result != null) break;
}
}
return result;
}
private Test[] FindTests( Test test, string[] names )
{
Test[] tests = new Test[ names.Length ];
int index = 0;
foreach( string name in names )
tests[index++] = FindTest( test, name );
return tests;
}
private void CleanUpAfterTestRun()
{
// Restore the directory we saved
if ( currentDirectory != null )
{
Environment.CurrentDirectory = currentDirectory;
currentDirectory = null;
}
// Close our output buffers
if ( outBuffer != null )
{
outBuffer.Close();
outBuffer = null;
}
if ( errorBuffer != null )
{
errorBuffer.Close();
errorBuffer = null;
}
// Restore previous console values
if ( saveOut != null )
{
Console.SetOut( saveOut );
saveOut = null;
}
if ( saveError != null )
{
Console.SetError( saveError );
saveError = null;
}
}
#endregion
#region EventListener Members
public void RunStarted(Test[] tests)
{
// TODO: Remove
}
void NUnit.Core.EventListener.RunFinished(TestResult[] results)
{
// TODO: Remove
outText.Close();
}
void NUnit.Core.EventListener.RunFinished(Exception exception)
{
// TODO: Remove
outText.Close();
}
public void TestStarted(TestCase testCase)
{
if ( displayTestLabels )
outText.WriteLine("***** {0}", testCase.FullName );
this.listener.TestStarted( testCase );
events.FireTestStarting( testCase );
}
void NUnit.Core.EventListener.TestFinished(TestCaseResult result)
{
listener.TestFinished( result );
events.FireTestFinished( result );
}
public void SuiteStarted(TestSuite suite)
{
listener.SuiteStarted( suite );
events.FireSuiteStarting( suite );
}
void NUnit.Core.EventListener.SuiteFinished(TestSuiteResult result)
{
listener.SuiteFinished( result );
events.FireSuiteFinished( result );
}
public void UnhandledException(Exception exception)
{
listener.UnhandledException( exception );
events.FireTestException( exception );
}
#endregion
}
}

42
src/Libraries/NUnitFramework/src/core/ResultVisitor.cs

@ -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.Core
{
using System;
/// <summary>
///
/// </summary>
public interface ResultVisitor
{
void Visit(TestCaseResult caseResult);
void Visit(TestSuiteResult suiteResult);
}
}

70
src/Libraries/NUnitFramework/src/core/Results.xsd

@ -1,70 +0,0 @@ @@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:complexType name="failureType">
<xs:sequence>
<xs:element ref="message" />
<xs:element ref="stack-trace" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="reasonType">
<xs:sequence>
<xs:element ref="message" />
</xs:sequence>
</xs:complexType>
<xs:element name="message" type="xs:string" />
<xs:complexType name="resultsType">
<xs:choice>
<xs:element name="test-suite" type="test-suiteType" maxOccurs="unbounded" />
<xs:element name="test-case" type="test-caseType" maxOccurs="unbounded" minOccurs="0" />
</xs:choice>
</xs:complexType>
<xs:element name="stack-trace" type="xs:string" />
<xs:element name="test-results" type="resultType" />
<xs:complexType name="categoriesType">
<xs:sequence>
<xs:element name="category" type="categoryType" maxOccurs="unbounded" minOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="categoryType">
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType name="resultType">
<xs:sequence>
<xs:element name="test-suite" type="test-suiteType" />
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="total" type="xs:decimal" use="required" />
<xs:attribute name="failures" type="xs:decimal" use="required" />
<xs:attribute name="not-run" type="xs:decimal" use="required" />
<xs:attribute name="date" type="xs:string" use="required" />
<xs:attribute name="time" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="test-caseType">
<xs:sequence>
<xs:element name="categories" type="categoriesType" minOccurs="0" maxOccurs="1" />
<xs:choice>
<xs:element name="failure" type="failureType" minOccurs="0" />
<xs:element name="reason" type="reasonType" minOccurs="0" />
</xs:choice>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="description" type="xs:string" use="optional" />
<xs:attribute name="success" type="xs:string" use="optional" />
<xs:attribute name="time" type="xs:string" use="optional" />
<xs:attribute name="executed" type="xs:string" use="required" />
<xs:attribute name="asserts" type="xs:string" use="optional" />
</xs:complexType>
<xs:complexType name="test-suiteType">
<xs:sequence>
<xs:element name="categories" type="categoriesType" minOccurs="0" maxOccurs="1" />
<xs:element name="results" type="resultsType" />
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="description" type="xs:string" use="optional" />
<xs:attribute name="success" type="xs:string" use="required" />
<xs:attribute name="time" type="xs:string" use="required" />
<xs:attribute name="asserts" type="xs:string" use="optional" />
</xs:complexType>
</xs:schema>

43
src/Libraries/NUnitFramework/src/core/RootTestSuite.cs

@ -1,43 +0,0 @@ @@ -1,43 +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.Core
{
/// <summary>
/// TestSuite forming the root of a test project
/// </summary>
public class RootTestSuite : TestSuite
{
public RootTestSuite( string projectName ) : base( projectName )
{
}
}
}

150
src/Libraries/NUnitFramework/src/core/StringTextWriter.cs

@ -1,150 +0,0 @@ @@ -1,150 +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;
using System.IO;
using System.Text;
namespace NUnit.Core
{
#region StringTextWriter
/// <summary>
/// Use this wrapper to ensure that only strings get passed accross the AppDomain
/// boundary. Otherwise tests will break when non-remotable objects are passed to
/// Console.Write/WriteLine.
/// </summary>
public class StringTextWriter : TextWriter
{
public StringTextWriter( TextWriter aTextWriter )
{
theTextWriter = aTextWriter;
}
protected TextWriter theTextWriter;
override public void Write(char aChar)
{
theTextWriter.Write(aChar);
}
override public void Write(string aString)
{
theTextWriter.Write(aString);
}
override public void WriteLine(string aString)
{
theTextWriter.WriteLine(aString);
}
override public System.Text.Encoding Encoding
{
get { return theTextWriter.Encoding; }
}
public override void Close()
{
this.Flush();
theTextWriter.Close ();
}
public override void Flush()
{
theTextWriter.Flush ();
}
}
#endregion
#region BufferedStringTextWriter
/// <summary>
/// This wrapper derives from StringTextWriter and adds buffering
/// to improve cross-domain performance. The buffer is flushed whenever
/// it reaches or exceeds a maximum size or when Flush is called.
/// </summary>
public class BufferedStringTextWriter : StringTextWriter
{
public BufferedStringTextWriter( TextWriter aTextWriter ) : base( aTextWriter ){ }
private static readonly int MAX_BUFFER = 1000;
private StringBuilder sb = new StringBuilder( MAX_BUFFER );
override public void Write(char aChar)
{
lock( sb )
{
sb.Append( aChar );
this.CheckBuffer();
}
}
override public void Write(string aString)
{
lock( sb )
{
sb.Append( aString );
this.CheckBuffer();
}
}
override public void WriteLine(string aString)
{
lock( sb )
{
sb.Append( aString );
sb.Append( '\n' );
this.CheckBuffer();
}
}
override public void Flush()
{
if ( sb.Length > 0 )
{
lock( sb )
{
theTextWriter.Write( sb.ToString() );
sb.Length = 0;
}
}
theTextWriter.Flush();
}
private void CheckBuffer()
{
if ( sb.Length >= MAX_BUFFER )
this.Flush();
}
}
#endregion
}

47
src/Libraries/NUnitFramework/src/core/Summary.xslt

@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='text'/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="test-results">
<xsl:text>Tests run: </xsl:text>
<xsl:value-of select="@total"/>
<xsl:text>, Failures: </xsl:text>
<xsl:value-of select="@failures"/>
<xsl:text>, Not run: </xsl:text>
<xsl:value-of select="@not-run"/>
<xsl:text>, Time: </xsl:text>
<xsl:value-of select="test-suite/@time"/>
<xsl:text> seconds
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:if test="//test-case[failure]"><xsl:text>Failures:
</xsl:text></xsl:if>
<xsl:apply-templates select="//test-case[failure]"/>
<xsl:if test="//test-case[@executed='False']"><xsl:text>Tests not run:
</xsl:text></xsl:if>
<xsl:apply-templates select="//test-case[@executed='False']"/>
<xsl:text disable-output-escaping='yes'>&#xD;&#xA;</xsl:text>
</xsl:template>
<xsl:template match="test-case">
<xsl:value-of select="position()"/><xsl:text>) </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text> : </xsl:text>
<xsl:value-of select="child::node()/message"/>
<xsl:text disable-output-escaping='yes'>&#xD;&#xA;</xsl:text>
<xsl:if test="failure">
<xsl:value-of select="failure/stack-trace"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

239
src/Libraries/NUnitFramework/src/core/TemplateTestCase.cs

@ -1,239 +0,0 @@ @@ -1,239 +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.Core
{
using System;
using System.Text;
using System.Reflection;
/// <summary>
/// Summary description for TestCase.
/// </summary>
public abstract class TemplateTestCase : TestCase
{
private MethodInfo method;
public TemplateTestCase(Type fixtureType, MethodInfo method) : base(fixtureType.FullName, method.Name)
{
this.fixtureType = fixtureType;
this.method = method;
}
public TemplateTestCase(object fixture, MethodInfo method) : base(fixture.GetType().FullName, method.Name)
{
this.Fixture = fixture;
this.fixtureType = fixture.GetType();
this.method = method;
}
public override void Run(TestCaseResult testResult)
{
if ( ShouldRun )
{
bool doParentSetUp = false;
if ( Parent != null )
{
doParentSetUp = !Parent.IsSetUp;
}
try
{
if ( doParentSetUp )
Parent.DoSetUp( testResult );
if ( Fixture == null && Parent != null)
Fixture = Parent.Fixture;
if ( !testResult.IsFailure )
doRun( testResult );
}
catch(Exception ex)
{
if ( ex is NunitException )
ex = ex.InnerException;
if ( ex is NUnit.Framework.IgnoreException )
testResult.NotRun( ex.Message );
else
RecordException( ex, testResult );
}
finally
{
if ( doParentSetUp )
Parent.DoTearDown( testResult );
}
}
else
{
testResult.NotRun(this.IgnoreReason);
}
}
/// <summary>
/// The doRun method is used to run a test internally.
/// It assumes that the caller is taking care of any
/// TestFixtureSetUp and TestFixtureTearDown needed.
/// </summary>
/// <param name="testResult">The result in which to record success or failure</param>
public void doRun( TestCaseResult testResult )
{
DateTime start = DateTime.Now;
try
{
Reflect.InvokeSetUp( this.Fixture );
doTestCase( testResult );
}
catch(Exception ex)
{
if ( ex is NunitException )
ex = ex.InnerException;
if ( ex is NUnit.Framework.IgnoreException )
testResult.NotRun( ex.Message );
else
RecordException( ex, testResult );
}
finally
{
doTearDown( testResult );
DateTime stop = DateTime.Now;
TimeSpan span = stop.Subtract(start);
testResult.Time = (double)span.Ticks / (double)TimeSpan.TicksPerSecond;
}
}
#region Invoke Methods by Reflection, Recording Errors
private void doTearDown( TestCaseResult testResult )
{
try
{
Reflect.InvokeTearDown( this.Fixture );
}
catch(Exception ex)
{
if ( ex is NunitException )
ex = ex.InnerException;
RecordException(ex, testResult, true);
}
}
private void doTestCase( TestCaseResult testResult )
{
try
{
Reflect.InvokeMethod( this.method, this.Fixture );
ProcessNoException(testResult);
}
catch( Exception ex )
{
if ( ex is NunitException )
ex = ex.InnerException;
if ( ex is NUnit.Framework.IgnoreException )
testResult.NotRun( ex.Message );
else
ProcessException(ex, testResult);
}
}
#endregion
#region Record Info About An Exception
protected void RecordException( Exception exception, TestCaseResult testResult )
{
RecordException( exception, testResult, false );
}
protected void RecordException( Exception exception, TestCaseResult testResult, bool inTearDown )
{
StringBuilder msg = new StringBuilder();
StringBuilder st = new StringBuilder();
if ( inTearDown )
{
msg.Append( testResult.Message );
msg.Append( Environment.NewLine );
msg.Append( "TearDown : " );
st.Append( testResult.StackTrace );
st.Append( Environment.NewLine );
st.Append( "--TearDown" );
st.Append( Environment.NewLine );
}
msg.Append( BuildMessage( exception ) );
st.Append( BuildStackTrace( exception ) );
testResult.Failure( msg.ToString(), st.ToString() );
}
private string BuildMessage(Exception exception)
{
StringBuilder sb = new StringBuilder();
if ( exception is NUnit.Framework.AssertionException )
sb.Append( exception.Message );
else
sb.AppendFormat( "{0} : {1}", exception.GetType().ToString(), exception.Message );
Exception inner = exception.InnerException;
while( inner != null )
{
sb.Append( Environment.NewLine );
sb.AppendFormat( " ----> {0} : {1}", inner.GetType().ToString(), inner.Message );
inner = inner.InnerException;
}
return sb.ToString();
}
private string BuildStackTrace(Exception exception)
{
if(exception.InnerException!=null)
return exception.StackTrace + Environment.NewLine +
"--" + exception.GetType().Name + Environment.NewLine +
BuildStackTrace(exception.InnerException);
else
return exception.StackTrace;
}
#endregion
#region Abstract Methods
protected internal abstract void ProcessNoException(TestCaseResult testResult);
protected internal abstract void ProcessException(Exception exception, TestCaseResult testResult);
#endregion
}
}

311
src/Libraries/NUnitFramework/src/core/Test.cs

@ -1,311 +0,0 @@ @@ -1,311 +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.Core
{
using System;
using System.Collections;
/// <summary>
/// Test Class.
/// </summary>
public abstract class Test : LongLivingMarshalByRefObject, ITest, IComparable
{
#region Private Fields
/// <summary>
/// Name of the test
/// </summary>
private string testName;
/// <summary>
/// Full Name of the test
/// </summary>
private string fullName;
/// <summary>
/// Int used to distinguish suites of the same
/// name across multiple assemblies.
/// </summary>
private int assemblyKey;
/// <summary>
/// The Type of the fixture associated with this test, or null
/// </summary>
protected Type fixtureType;
/// <summary>
/// The fixture object, to be used with this test, or null
/// </summary>
private object fixture;
/// <summary>
/// Whether or not the test should be run
/// </summary>
private bool shouldRun;
/// <summary>
/// Reason for not running the test, if applicable
/// </summary>
private string ignoreReason;
/// <summary>
/// Description for this test
/// </summary>
private string description;
/// <summary>
/// Test suite containing this test, or null
/// </summary>
private TestSuite parent;
/// <summary>
/// List of categories applying to this test
/// </summary>
private IList categories;
/// <summary>
/// True if the test had the Explicit attribute
/// </summary>
private bool isExplicit;
#endregion
#region Constructors
public Test( string name ) : this( name, 0 ) { }
public Test( string name, int assemblyKey )
{
fullName = testName = name;
this.assemblyKey = assemblyKey;
}
protected Test( string pathName, string testName )
: this( pathName, testName, 0 ) { }
protected Test( string pathName, string testName, int assemblyKey )
{
fullName = pathName == null || pathName == string.Empty ? testName : pathName + "." + testName;
this.testName = testName;
this.assemblyKey = assemblyKey;
shouldRun = true;
}
protected Test( Type fixtureType ) : this( fixtureType, 0 ) { }
protected Test( Type fixtureType, int assemblyKey )
{
this.fixtureType = fixtureType;
this.fullName = this.testName = fixtureType.FullName;
this.assemblyKey = assemblyKey;
this.shouldRun = true;
if ( fixtureType.Namespace != null )
testName = testName.Substring( Name.LastIndexOf( '.' ) + 1 );
}
// TODO: Currently, these two are only used by our tests. Remove?
protected Test( object fixture ) : this( fixture, 0 ) { }
protected Test( object fixture, int assemblyKey ) : this( fixture.GetType(), assemblyKey )
{
this.fixture = fixture;
}
#endregion
#region Properties
public string Name
{
get { return testName; }
}
public string FullName
{
get { return fullName; }
}
/// <summary>
/// If the name is a path, this just returns the file part
/// </summary>
public string ShortName
{
get
{
string name = Name;
int val = name.LastIndexOf("\\");
if(val != -1)
name = name.Substring(val+1);
return name;
}
}
/// <summary>
/// Int used to distinguish suites of the same
/// name across multiple assemblies.
/// </summary>
public int AssemblyKey
{
get { return assemblyKey; }
set { assemblyKey = value; }
}
/// <summary>
/// Key used to look up a test in a hash table
/// </summary>
public string UniqueName
{
get { return string.Format( "[{0}]{1}", assemblyKey, fullName ); }
}
public object Fixture
{
get { return fixture; }
set { fixture = value; }
}
/// <summary>
/// Whether or not the test should be run
/// </summary>
public virtual bool ShouldRun
{
get { return shouldRun; }
set { shouldRun = value; }
}
/// <summary>
/// Reason for not running the test, if applicable
/// </summary>
public string IgnoreReason
{
get { return ignoreReason; }
set { ignoreReason = value; }
}
public TestSuite Parent
{
get { return parent; }
set { parent = value; }
}
public string TestPath
{
get
{
string testPath = "";
if (parent != null)
testPath = parent.TestPath;
return testPath + FullName;
}
}
public IList Categories
{
get { return categories; }
set { categories = value; }
}
public bool HasCategory( string name )
{
return categories != null && categories.Contains( name );
}
public bool HasCategory( IList names )
{
if ( categories == null )
return false;
foreach( string name in names )
if ( categories.Contains( name ) )
return true;
return false;
}
public bool IsDescendant(Test test)
{
if (parent != null)
{
return parent == test || parent.IsDescendant(test);
}
return false;
}
public String Description
{
get { return description; }
set { description = value; }
}
public bool IsExplicit
{
get { return isExplicit; }
set { isExplicit = value; }
}
#endregion
#region Abstract Methods and Properties
/// <summary>
/// Count of the test cases ( 1 if this is a test case )
/// </summary>
public abstract int CountTestCases();
public abstract int CountTestCases(IFilter filter);
public abstract bool IsSuite { get; }
public abstract bool IsFixture{ get; }
public abstract bool IsTestCase{ get; }
public abstract ArrayList Tests { get; }
public abstract bool Filter(IFilter filter);
public abstract TestResult Run( EventListener listener );
public abstract TestResult Run(EventListener listener, IFilter filter);
#endregion
#region IComparable Members
public int CompareTo(object obj)
{
Test other = obj as Test;
if ( other == null )
return -1;
return this.FullName.CompareTo( other.FullName );
}
#endregion
}
}

70
src/Libraries/NUnitFramework/src/core/TestAssembly.cs

@ -1,70 +0,0 @@ @@ -1,70 +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;
using System.IO;
namespace NUnit.Core
{
/// <summary>
/// Test Suite formed from an assembly.
/// Class name changed from TestAssembly
/// to avoid conflict with namespace.
/// </summary>
public class AssemblyTestSuite : TestSuite
{
public AssemblyTestSuite( string assembly ) : this( assembly, 0 )
{
}
public AssemblyTestSuite( string assembly, int key) : base( assembly, key )
{
}
public override TestResult Run(EventListener listener)
{
string directoryName = Path.GetDirectoryName( this.Name );
if ( directoryName != null && directoryName != string.Empty )
Environment.CurrentDirectory = directoryName;
return base.Run( listener );
}
public override TestResult Run(EventListener listener, IFilter filter)
{
string directoryName = Path.GetDirectoryName( this.Name );
if ( directoryName != null && directoryName != string.Empty )
Environment.CurrentDirectory = directoryName;
return base.Run( listener, filter );
}
}
}

107
src/Libraries/NUnitFramework/src/core/TestCase.cs

@ -1,107 +0,0 @@ @@ -1,107 +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.Core
{
using System;
using System.Collections;
using System.Reflection;
/// <summary>
/// Summary description for TestCase.
/// </summary>
public abstract class TestCase : Test
{
public TestCase( string path, string name ) : base( path, name ) { }
public override int CountTestCases()
{
return 1;
}
public override int CountTestCases(IFilter filter)
{
if (Filter(filter))
return 1;
return 0;
}
public override TestResult Run(EventListener listener, IFilter filter)
{
return Run( listener ); // Ignore filter for now
}
public override TestResult Run( EventListener listener )
{
TestCaseResult testResult = new TestCaseResult(this);
listener.TestStarted(this);
long startTime = DateTime.Now.Ticks;
Run( testResult );
testResult.AssertCount = NUnit.Framework.Assert.Counter;
long stopTime = DateTime.Now.Ticks;
double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
testResult.Time = time;
listener.TestFinished(testResult);
return testResult;
}
public override bool IsSuite
{
get { return false; }
}
public override bool IsFixture
{
get { return false; }
}
public override bool IsTestCase
{
get { return true; }
}
public override ArrayList Tests
{
get { return null; }
}
public override bool Filter(IFilter filter)
{
return filter.Pass(this);
}
public abstract void Run(TestCaseResult result);
}
}

177
src/Libraries/NUnitFramework/src/core/TestCaseBuilder.cs

@ -1,177 +0,0 @@ @@ -1,177 +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.Core
{
using System;
using System.Reflection;
using System.Collections;
/// <summary>
/// Summary description for TestCaseBuilder.
/// </summary>
public class TestCaseBuilder
{
private static Hashtable builders;
private static ITestBuilder normalBuilder = new NormalBuilder();
private static void InitBuilders()
{
builders = new Hashtable();
builders[typeof(NUnit.Framework.ExpectedExceptionAttribute)] = new ExpectedExceptionBuilder();
}
private static ITestBuilder GetBuilder(MethodInfo method)
{
if (builders == null)
InitBuilders();
object[] attributes = method.GetCustomAttributes(false);
foreach (object attribute in attributes)
{
ITestBuilder builder = (ITestBuilder) builders[attribute.GetType()];
if (builder != null)
return builder;
}
return normalBuilder;
}
/// <summary>
/// Make a test case from a given fixture type and method
/// </summary>
/// <param name="fixtureType">The fixture type</param>
/// <param name="method">MethodInfo for the particular method</param>
/// <returns>A test case or null</returns>
public static TestCase Make(Type fixtureType, MethodInfo method)
{
TestCase testCase = null;
if( Reflect.HasTestAttribute(method) || Reflect.IsObsoleteTestMethod( method ) )
{
if( Reflect.IsTestMethodSignatureCorrect( method ) )
{
ITestBuilder builder = GetBuilder(method);
testCase = builder.Make(fixtureType, method);
if(Reflect.HasIgnoreAttribute(method))
{
testCase.ShouldRun = false;
testCase.IgnoreReason = Reflect.GetIgnoreReason(method);
}
if (Reflect.HasCategoryAttribute(method))
{
IList categories = Reflect.GetCategories(method);
CategoryManager.Add(categories);
testCase.Categories = categories;
}
testCase.IsExplicit = Reflect.HasExplicitAttribute(method);
testCase.Description = Reflect.GetDescription(method);
}
else
{
testCase = new NotRunnableTestCase(method);
}
}
return testCase;
}
#region Make Test Cases with pre-created fixtures
// TODO: These methods are only used by our tests, since we no longer
// create the fixture in advance. They should be phased out.
public static TestCase Make(object fixture, MethodInfo method)
{
TestCase testCase = Make( fixture.GetType(), method );
testCase.Fixture = fixture;
return testCase;
}
public static TestCase Make(object fixture, string methodName)
{
MethodInfo method = Reflect.GetMethod( fixture.GetType(), methodName );
if ( method != null )
return Make(fixture, method);
return null;
}
#endregion
}
internal interface ITestBuilder
{
TestCase Make(Type fixtureType, MethodInfo method);
TestCase Make(object fixture, MethodInfo method);
}
internal class ExpectedExceptionBuilder : ITestBuilder
{
#region ITestBuilder Members
public TestCase Make(Type fixtureType, MethodInfo method)
{
return new ExpectedExceptionTestCase( fixtureType, method );
}
public TestCase Make(object fixture, MethodInfo method)
{
return new ExpectedExceptionTestCase( fixture, method );
}
#endregion
}
internal class NormalBuilder : ITestBuilder
{
#region ITestBuilder Members
public TestCase Make(Type fixtureType, MethodInfo method)
{
return new NormalTestCase(fixtureType, method);
}
public TestCase Make(object fixture, MethodInfo method)
{
return new NormalTestCase(fixture, method);
}
#endregion
}
}

77
src/Libraries/NUnitFramework/src/core/TestCaseResult.cs

@ -1,77 +0,0 @@ @@ -1,77 +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.Core
{
using System;
using System.Text;
/// <summary>
///
/// </summary>
//
[Serializable]
public class TestCaseResult : TestResult
{
public TestCaseResult(ITest testCase):base(testCase, testCase.FullName)
{
Executed = false;
}
public TestCaseResult(string testCaseString) : base(null, testCaseString)
{
Executed = false;
}
public void Success()
{
Executed = true;
IsFailure = false;
}
public override string ToString()
{
StringBuilder builder = new StringBuilder();
string name = Name;
if ( Test != null )
name = Test.FullName;
builder.AppendFormat("{0} : " , name);
if(!IsSuccess)
builder.Append(messageString);
return builder.ToString();
}
public override void Accept(ResultVisitor visitor)
{
visitor.Visit(this);
}
}
}

198
src/Libraries/NUnitFramework/src/core/TestEventArgs.cs

@ -1,198 +0,0 @@ @@ -1,198 +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.Core
{
/// <summary>
/// The delegate for all events related to running tests
/// </summary>
public delegate void TestEventHandler ( object sender, TestEventArgs args );
/// <summary>
/// Enumeration used to distiguish test events
/// </summary>
public enum TestAction
{
// Test Load Events
TestLoading,
TestLoaded,
TestLoadFailed,
TestReloading,
TestReloaded,
TestReloadFailed,
TestUnloading,
TestUnloaded,
TestUnloadFailed,
// Test Run Events
RunStarting,
RunFinished,
SuiteStarting,
SuiteFinished,
TestStarting,
TestFinished,
TestException
}
/// <summary>
/// Argument used for all test events
/// </summary>
public class TestEventArgs : EventArgs
{
#region Instance Variables
// The action represented by the event
private TestAction action;
// The name of the test or other item
private string name;
// The tests we are running
private Test[] tests;
// The results from our tests
private TestResult[] results;
// The exception causing a failure
private Exception exception;
// TODO: Remove this count of test cases
private int count;
#endregion
#region Constructors
public TestEventArgs( TestAction action,
string name, Test test )
{
this.action = action;
this.name = name;
this.tests = new Test[] { test };
}
public TestEventArgs( TestAction action, string name )
{
this.action = action;
this.name = name;
}
public TestEventArgs( TestAction action,
string name, Exception exception )
{
this.action = action;
this.name = name;
this.exception = exception;
}
public TestEventArgs( TestAction action, Test test )
{
this.action = action;
this.tests = new Test[] { test };
this.count = test.CountTestCases();
}
public TestEventArgs( TestAction action, TestResult result )
{
this.action = action;
this.results = new TestResult[] { result };
}
public TestEventArgs( TestAction action, TestResult[] results )
{
this.action = action;
this.results = results;
}
public TestEventArgs( TestAction action, Exception exception )
{
this.action = action;
this.exception = exception;
}
public TestEventArgs( TestAction action, Test[] tests, int count)
{
this.action = action;
this.tests = tests;
this.count = count;
}
#endregion
#region Properties
public TestAction Action
{
get { return action; }
}
public string Name
{
get { return name; }
}
// public bool IsProjectFile
// {
// get { return NUnitProject.IsProjectFile( testFileName ); }
// }
public Test Test
{
get { return tests == null || tests.Length == 0 ? null : tests[0]; }
}
public Test[] Tests
{
get { return tests; }
}
public int TestCount
{
get { return count; }
}
public TestResult Result
{
get { return results == null || results.Length == 0 ? null : results[0]; }
}
public TestResult[] Results
{
get { return results; }
}
public Exception Exception
{
get { return exception; }
}
#endregion
}
}

169
src/Libraries/NUnitFramework/src/core/TestEventDispatcher.cs

@ -1,169 +0,0 @@ @@ -1,169 +0,0 @@
using System;
namespace NUnit.Core
{
/// <summary>
/// Helper class used by runner to dispatch test events
/// </summary>
public class TestEventDispatcher : ITestEvents
{
#region Events
// Test loading events
public event TestEventHandler TestLoading;
public event TestEventHandler TestLoaded;
public event TestEventHandler TestLoadFailed;
public event TestEventHandler TestReloading;
public event TestEventHandler TestReloaded;
public event TestEventHandler TestReloadFailed;
public event TestEventHandler TestUnloading;
public event TestEventHandler TestUnloaded;
public event TestEventHandler TestUnloadFailed;
// Test running events
public event TestEventHandler RunStarting;
public event TestEventHandler RunFinished;
public event TestEventHandler SuiteStarting;
public event TestEventHandler SuiteFinished;
public event TestEventHandler TestStarting;
public event TestEventHandler TestFinished;
public event TestEventHandler TestException;
#endregion
#region Methods for Firing Events
private void Fire(
TestEventHandler handler, TestEventArgs e )
{
if ( handler != null )
handler( this, e );
}
public void FireTestLoading( string fileName )
{
Fire(
TestLoading,
new TestEventArgs( TestAction.TestLoading, fileName ) );
}
public void FireTestLoaded( string fileName, Test test )
{
Fire(
TestLoaded,
new TestEventArgs( TestAction.TestLoaded, fileName, test ) );
}
public void FireTestLoadFailed( string fileName, Exception exception )
{
Fire(
TestLoadFailed,
new TestEventArgs( TestAction.TestLoadFailed, fileName, exception ) );
}
public void FireTestUnloading( string fileName, Test test )
{
Fire(
TestUnloading,
new TestEventArgs( TestAction.TestUnloading, fileName, test ) );
}
public void FireTestUnloaded( string fileName, Test test )
{
Fire(
TestUnloaded,
new TestEventArgs( TestAction.TestUnloaded, fileName, test ) );
}
public void FireTestUnloadFailed( string fileName, Exception exception )
{
Fire(
TestUnloadFailed,
new TestEventArgs( TestAction.TestUnloadFailed, fileName, exception ) );
}
public void FireTestReloading( string fileName, Test test )
{
Fire(
TestReloading,
new TestEventArgs( TestAction.TestReloading, fileName, test ) );
}
public void FireTestReloaded( string fileName, Test test )
{
Fire(
TestReloaded,
new TestEventArgs( TestAction.TestReloaded, fileName, test ) );
}
public void FireTestReloadFailed( string fileName, Exception exception )
{
Fire(
TestReloadFailed,
new TestEventArgs( TestAction.TestReloadFailed, fileName, exception ) );
}
public void FireRunStarting( Test[] tests, int count )
{
Fire(
RunStarting,
new TestEventArgs( TestAction.RunStarting, tests, count ) );
}
public void FireRunFinished( TestResult[] results )
{
Fire(
RunFinished,
new TestEventArgs( TestAction.RunFinished, results ) );
}
public void FireRunFinished( Exception exception )
{
Fire(
RunFinished,
new TestEventArgs( TestAction.RunFinished, exception ) );
}
public void FireTestStarting( Test test )
{
Fire(
TestStarting,
new TestEventArgs( TestAction.TestStarting, test ) );
}
public void FireTestFinished( TestResult result )
{
Fire(
TestFinished,
new TestEventArgs( TestAction.TestFinished, result ) );
}
public void FireSuiteStarting( Test test )
{
Fire(
SuiteStarting,
new TestEventArgs( TestAction.SuiteStarting, test ) );
}
public void FireSuiteFinished( TestResult result )
{
Fire(
SuiteFinished,
new TestEventArgs( TestAction.SuiteFinished, result ) );
}
public void FireTestException( Exception exception )
{
Fire(
TestException,
new TestEventArgs( TestAction.TestException, exception ) );
}
#endregion
}
}

166
src/Libraries/NUnitFramework/src/core/TestFixture.cs

@ -1,166 +0,0 @@ @@ -1,166 +0,0 @@
using System;
using System.Collections;
using System.Reflection;
namespace NUnit.Core
{
/// <summary>
/// A TestSuite that wraps a class marked with TestFixtureAttribute
/// </summary>
public class TestFixture : TestSuite
{
private const string FIXTURE_SETUP_FAILED = "Fixture setup failed";
#region Constructors
public TestFixture( object fixture ) : base( fixture, 0 )
{
Initialize();
}
public TestFixture( object fixture, int assemblyKey ) : base( fixture, assemblyKey )
{
Initialize();
}
public TestFixture( Type fixtureType ) : base( fixtureType, 0 )
{
Initialize();
}
public TestFixture( Type fixtureType, int assemblyKey ) : base( fixtureType, assemblyKey )
{
Initialize();
}
private void Initialize()
{
try
{
Reflect.CheckFixtureType( fixtureType );
IList categories = Reflect.GetCategories( fixtureType );
CategoryManager.Add( categories );
this.Categories = categories;
this.fixtureSetUp = Reflect.GetFixtureSetUpMethod( fixtureType );
this.fixtureTearDown = Reflect.GetFixtureTearDownMethod( fixtureType );
this.IsExplicit = Reflect.HasExplicitAttribute( fixtureType );
if ( Reflect.HasIgnoreAttribute( fixtureType ) )
{
this.ShouldRun = false;
this.IgnoreReason = Reflect.GetIgnoreReason( fixtureType );
}
this.Description = Reflect.GetDescription( fixtureType );
MethodInfo [] methods = fixtureType.GetMethods(BindingFlags.Public|BindingFlags.Instance|BindingFlags.Static|BindingFlags.NonPublic);
foreach(MethodInfo method in methods)
{
TestCase testCase = TestCaseBuilder.Make( fixtureType, method );
if(testCase != null)
{
testCase.AssemblyKey = this.AssemblyKey;
this.Add( testCase );
}
}
if( this.CountTestCases() == 0 )
{
this.ShouldRun = false;
this.IgnoreReason = this.Name + " does not have any tests";
}
}
catch( InvalidTestFixtureException exception )
{
this.ShouldRun = false;
this.IgnoreReason = exception.Message;
}
}
#endregion
#region Static Methods
public static bool IsValidType( Type type )
{
return !type.IsAbstract && Reflect.HasTestFixtureAttribute( type );
}
#endregion
public override void DoSetUp( TestResult suiteResult )
{
try
{
if ( Fixture == null )
Fixture = Reflect.Construct( fixtureType );
if (this.fixtureSetUp != null)
Reflect.InvokeMethod(fixtureSetUp, Fixture);
IsSetUp = true;
}
catch (Exception ex)
{
// Error in TestFixtureSetUp causes the suite and
// all contained suites to be ignored.
// TODO: Change this to be a failure?
NunitException nex = ex as NunitException;
if (nex != null)
ex = nex.InnerException;
if ( ex is NUnit.Framework.IgnoreException )
{
this.ShouldRun = false;
suiteResult.NotRun(ex.Message);
suiteResult.StackTrace = ex.StackTrace;
this.IgnoreReason = ex.Message;
}
else
{
suiteResult.Failure( ex.Message, ex.StackTrace, true );
}
}
finally
{
suiteResult.AssertCount = NUnit.Framework.Assert.Counter;
}
}
public override void DoTearDown( TestResult suiteResult )
{
if (this.ShouldRun)
{
try
{
IsSetUp = false;
if (this.fixtureTearDown != null)
Reflect.InvokeMethod(fixtureTearDown, Fixture);
}
catch (Exception ex)
{
// Error in TestFixtureTearDown causes the
// suite to be marked as a failure, even if
// all the contained tests passed.
NunitException nex = ex as NunitException;
if (nex != null)
ex = nex.InnerException;
suiteResult.Failure( ex.Message, ex.StackTrace);
}
finally
{
suiteResult.AssertCount += NUnit.Framework.Assert.Counter;
}
}
if (this.IgnoreReason == FIXTURE_SETUP_FAILED)
{
this.ShouldRun = true;
this.IgnoreReason = null;
}
}
}
}

211
src/Libraries/NUnitFramework/src/core/TestResult.cs

@ -1,211 +0,0 @@ @@ -1,211 +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.Core
{
using System;
/// <summary>
/// Summary description for TestResult.
/// </summary>
///
[Serializable]
public abstract class TestResult
{
#region Fields
/// <summary>
/// True if the test executed
/// </summary>
private bool executed;
/// <summary>
/// True if the test was marked as a failure
/// </summary>
private bool isFailure;
/// <summary>
/// True if the setup failed: This means SetUp for a test case,
/// or TestFixtureSetUp for a fixture.
/// </summary>
private bool setupFailure;
/// <summary>
/// The elapsed time for executing this test
/// </summary>
private double time;
/// <summary>
/// The name of the test
/// </summary>
private string name;
/// <summary>
/// The test that this result pertains to
/// </summary>
private ITest test;
/// <summary>
/// The stacktrace at the point of failure
/// </summary>
private string stackTrace;
/// <summary>
/// Description of this test
/// </summary>
private string description;
/// <summary>
/// Message giving the reason for failure
/// </summary>
protected string messageString;
/// <summary>
/// Number of asserts executed by this test
/// </summary>
private int assertCount;
#endregion
#region Protected Constructor
protected TestResult(ITest test, string name)
{
this.name = name;
this.test = test;
if(test != null)
this.description = test.Description;
}
#endregion
#region Properties
public bool Executed
{
get { return executed; }
set { executed = value; }
}
public virtual bool AllTestsExecuted
{
get { return executed; }
}
public virtual string Name
{
get{ return name;}
}
public ITest Test
{
get{ return test;}
}
public virtual bool IsSuccess
{
get { return !(isFailure); }
}
public virtual bool IsFailure
{
get { return isFailure; }
set { isFailure = value; }
}
public bool SetupFailure
{
get { return setupFailure; }
set { setupFailure = value; }
}
public virtual string Description
{
get { return description; }
set { description = value; }
}
public double Time
{
get{ return time; }
set{ time = value; }
}
public string Message
{
get { return messageString; }
}
public virtual string StackTrace
{
get
{
return stackTrace;
}
set
{
stackTrace = value;
}
}
public int AssertCount
{
get { return assertCount; }
set { assertCount = value; }
}
#endregion
#region Public Methods
public void NotRun(string reason)
{
this.executed = false;
this.messageString = reason;
}
public void Failure(string message, string stackTrace )
{
Failure( message, stackTrace, false );
}
public void Failure(string message, string stackTrace, bool setupFailure)
{
this.executed = true;
this.isFailure = true;
this.messageString = message;
this.stackTrace = stackTrace;
this.setupFailure = setupFailure;
}
#endregion
public abstract void Accept(ResultVisitor visitor);
}
}

189
src/Libraries/NUnitFramework/src/core/TestRunner.cs

@ -1,189 +0,0 @@ @@ -1,189 +0,0 @@
using System;
using System.Collections;
using System.IO;
using System.Threading;
namespace NUnit.Core
{
/// <summary>
/// The TestRunner Interface is allows client code, such as the NUnit console and
/// gui runners, to load and run tests. This is the lowest level interface generally
/// supported for running tests and is implemented by the RemoteTestRunner class in
/// the NUnit core as well as by other classes running on the client side.
///
/// The Load family of methods is used to load a suite of tests from one or more
/// assemblies, returning the resulting test suite to the caller.
///
/// The CountTestCases family of methods returns the number of test cases in the
/// loaded suite, either in its entirety or by taking a subset of tests as roots.
///
/// The Run family of methods performs a test run synchronously, returning a TestResult
/// or TestResult[] to the caller. If provided, an EventListener interface will be
/// notified of significant events in the running of the tests.
///
/// The RunTest family of methods uses the same set of signatures as Run but operates
/// asynchronously. The final result of the run may be obtained through the user of an
/// EventListener or through the Results property.
/// </summary>
public interface TestRunner
{
#region Properties
/// <summary>
/// IsTestRunning indicates whether a test is in progress. MayTo retrieve the
/// results from an asynchronous test run, wait till IsTestRunning is false.
/// </summary>
// bool IsTestRunning
// {
// get;
// }
Version FrameworkVersion
{
get;
}
/// <summary>
/// Setting to show a header line for each test case in
/// the console output.
/// </summary>
bool DisplayTestLabels
{
get; set;
}
/// <summary>
/// Results from the last test run
/// </summary>
TestResult[] Results
{
get;
}
/// <summary>
/// First (or only) result from the last test run
/// </summary>
TestResult Result
{
get;
}
#endregion
/// <summary>
/// Load all tests from an assembly
/// </summary>
/// <param name="assemblyName">The assembly from which tests are to be loaded</param>
Test Load( string assemblyName );
/// <summary>
/// Load a particular test in an assembly
/// </summary>
/// <param name="assemblyName">The assembly from which tests are to be loaded</param>
/// <param name="testName">The name of the test fixture or suite to be loaded</param>
Test Load( string assemblyName, string testName );
/// <summary>
/// Load multiple assemblies
/// </summary>
/// <param name="projectName">The project name to use for the root test node</param>
/// <param name="assemblies">The assemblies from which tests are to be loaded</param>
Test Load( string projectName, string[] assemblies );
/// <summary>
/// Load a particular test in a set of assemblies
/// </summary>
/// <param name="projectName">The project name to use for the root test node</param>
/// <param name="assemblies">The assemblies from which tests are to be loaded</param>
/// <param name="testName">The name of the test fixture or suite to be loaded</param>
Test Load( string projectName, string[] assemblies, string testName );
/// <summary>
/// Unload all tests previously loaded
/// </summary>
void Unload();
void SetFilter( IFilter filter );
/// <summary>
/// Count test cases previously loaded
/// </summary>
/// <returns>The number of test cases found</returns>
int CountTestCases();
/// <summary>
/// Count Test Cases under a given test name
/// </summary>
/// <param name="testName">The name of a test case, fixture or suite</param>
/// <returns>The number of test cases found</returns>
int CountTestCases(string testName );
/// <summary>
/// Count test cases starting at a set of roots
/// </summary>
/// <param name="testNames">An array of names of test cases, fixtures or suites</param>
/// <returns>The number of test cases found</returns>
int CountTestCases(string[] testNames);
/// <summary>
/// Get the collectiion of categories used by the runner;
/// </summary>
/// <returns></returns>
ICollection GetCategories();
/// <summary>
/// Run the loaded tests using a test filter
/// </summary>
// TestResult Run(NUnit.Core.EventListener listener, IFilter filter);
/// <summary>
/// Run all loaded tests and return a test result. The test is run synchronously,
/// and the listener interface is notified as it progresses.
/// </summary>
/// <param name="listener">Interface to receive EventListener notifications.</param>
TestResult Run(NUnit.Core.EventListener listener);
/// <summary>
/// Run a particular loaded test and return a test result. The test is run
/// synchronously and the listener interface is notified as it progresses.
/// </summary>
/// <param name="listener">Interface to receive EventListener notifications</param>
/// <param name="testName">The name of the test case, fixture or suite to be run</param>
TestResult Run(NUnit.Core.EventListener listener, string testName);
/// <summary>
/// Run a set of loaded tests and return a set of results. The test is run
/// synchronously and the listener interface is notified as it progresses.
/// </summary>
/// <param name="listener">Interface to receive EventListener notifications</param>
/// <param name="testNames">The names of the test cases, fixtures or suites to be run</param>
TestResult[] Run(NUnit.Core.EventListener listener, string[] testNames);
/// <summary>
/// Run all loaded tests. The test is run asynchronously and the listener
/// interface is notified as it progresses.
/// </summary>
/// <param name="listener">Interface to an object to receive EventListener notifications</param>
void RunTest(NUnit.Core.EventListener listener);
/// <summary>
/// Run a particular loaded test. The test is run asynchronously and the
/// listener interface is notified as it progresses.
/// </summary>
/// <param name="listener">Interface to an object to receive EventListener notifications</param>
/// <param name="testName">The name of the test case, fixture or suite to be run</param>
void RunTest(NUnit.Core.EventListener listener, string testName);
/// <summary>
/// Run a set of loaded tests. The tests are run asynchronously and the
/// listener interface is notified as it progresses.
/// </summary>
/// <param name="listener">Interface to an object to receive EventListener notifications</param>
/// <param name="testNames">The names of the test cases, fixtures or suites to be run</param>
void RunTest(NUnit.Core.EventListener listener, string[] testNames);
void CancelRun();
void Wait();
}
}

162
src/Libraries/NUnitFramework/src/core/TestRunnerThread.cs

@ -1,162 +0,0 @@ @@ -1,162 +0,0 @@
using System;
using System.IO;
using System.Threading;
using System.Configuration;
using System.Collections.Specialized;
namespace NUnit.Core
{
/// <summary>
/// Summary description for TestRunnerThread.
/// </summary>
public class TestRunnerThread
{
#region Private Fields
/// <summary>
/// The Test runner to be used in running tests on the thread
/// </summary>
private TestRunner runner;
/// <summary>
/// The System.Threading.Thread created by the object
/// </summary>
private Thread thread;
/// <summary>
/// Collection of TestRunner settings from the config file
/// </summary>
private NameValueCollection settings;
/// <summary>
/// The exception that terminated a test run
/// </summary>
private Exception lastException;
/// <summary>
/// The EventListener interface to receive test events
/// </summary>
private NUnit.Core.EventListener listener;
/// <summary>
/// Array of test names for ues by the thread proc
/// </summary>
private string[] testNames;
/// <summary>
/// Array of returned results
/// </summary>
private TestResult[] results;
#endregion
#region Properties
/// <summary>
/// Array of returned results
/// </summary>
public TestResult[] Results
{
get { return results; }
}
#endregion
#region Constructor
public TestRunnerThread( TestRunner runner )
{
this.runner = runner;
this.thread = new Thread( new ThreadStart( TestRunnerThreadProc ) );
this.settings = (NameValueCollection)
ConfigurationSettings.GetConfig( "NUnit/TestRunner" );
try
{
string apartment = (string)settings["ApartmentState"];
if ( apartment == "STA" )
thread.ApartmentState = ApartmentState.STA;
else if ( apartment == "MTA" )
thread.ApartmentState = ApartmentState.MTA;
string priority = (string)settings["ThreadPriority"];
if ( priority != null )
thread.Priority = (ThreadPriority)
System.Enum.Parse( typeof( ThreadPriority ), priority, true );
}
catch
{
// Ignore any problems for now - test will run using default settings
}
}
#endregion
#region Public Methods
public void Wait()
{
if ( this.thread.IsAlive )
this.thread.Join();
}
public void Cancel()
{
this.thread.Abort();
this.thread.Join();
}
public void Run( EventListener listener )
{
this.listener = listener;
thread.Start();}
public void Run( EventListener listener, string testName )
{
this.listener = listener;
this.testNames = new string[] { testName };
thread.Start(); }
public void Run( EventListener listener, string[] testNames )
{
this.listener = listener;
this.testNames = testNames;
thread.Start();
}
#endregion
#region Thread Proc
/// <summary>
/// The thread proc for our actual test run
/// </summary>
private void TestRunnerThreadProc()
{
try
{
//TODO: do we need a run started event?
results = runner.Run(listener, testNames );
//TODO: do we need a run finished event?
}
catch( Exception exception )
{
lastException = exception;
//TODO: do we need a run finished event?
}
finally
{
testNames = null; // Do we need this?
//runningThread = null; // Ditto
}
}
#endregion
}
}

275
src/Libraries/NUnitFramework/src/core/TestSuite.cs

@ -1,275 +0,0 @@ @@ -1,275 +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.Core
{
using System;
using System.Collections;
using System.Reflection;
using System.Text;
/// <summary>
/// Summary description for TestSuite.
/// </summary>
///
[Serializable]
public class TestSuite : Test
{
private static readonly string EXPLICIT_SELECTION_REQUIRED = "Explicit selection required";
#region Fields
/// <summary>
/// Our collection of child tests
/// </summary>
private ArrayList tests = new ArrayList();
/// <summary>
/// The fixture setup method for this suite
/// </summary>
protected MethodInfo fixtureSetUp;
/// <summary>
/// The fixture teardown method for this suite
/// </summary>
protected MethodInfo fixtureTearDown;
/// <summary>
/// True if the fixture has been set up
/// </summary>
private bool isSetUp;
#endregion
#region Constructors
public TestSuite( string name ) : this( name, 0 ) { }
public TestSuite( string name, int assemblyKey )
: base( name, assemblyKey )
{
ShouldRun = true;
}
public TestSuite( string parentSuiteName, string name )
: this( parentSuiteName, name, 0 ) { }
public TestSuite( string parentSuiteName, string name, int assemblyKey )
: base( parentSuiteName, name, assemblyKey )
{
ShouldRun = true;
}
public TestSuite( Type fixtureType ) : base( fixtureType, 0 ) { }
public TestSuite( Type fixtureType, int assemblyKey ) : base( fixtureType, assemblyKey ) { }
protected TestSuite( object fixture ) : base( fixture, 0 ) { }
protected TestSuite( object fixture, int assemblyKey ) : base( fixture, assemblyKey ) { }
#endregion
public void Sort()
{
this.Tests.Sort();
foreach( Test test in Tests )
{
TestSuite suite = test as TestSuite;
if ( suite != null )
suite.Sort();
}
}
public void Add( Test test )
{
if(test.ShouldRun)
{
test.ShouldRun = ShouldRun;
test.IgnoreReason = IgnoreReason;
}
test.Parent = this;
tests.Add(test);
}
//Keep this in for testing for the time being
public void Add( object fixture )
{
Add( new TestFixture( fixture ) );
}
#region Properties
public override ArrayList Tests
{
get { return tests; }
}
public override bool IsSuite
{
get { return true; }
}
public override bool IsTestCase
{
get { return false; }
}
public bool IsSetUp
{
get { return isSetUp; }
set { isSetUp = value; }
}
#endregion
/// <summary>
/// True if this is a fixture. May populate the test's
/// children as a side effect.
/// TODO: An easier way to tell this?
/// </summary>
public override bool IsFixture
{
get
{
// We have no way of constructing an empty suite unless it's a fixture
if ( Tests.Count == 0 ) return true;
// Any suite with children is a fixture if the children are test cases
Test firstChild = (Test)Tests[0];
return !firstChild.IsSuite;
}
}
public override int CountTestCases()
{
int count = 0;
foreach(Test test in Tests)
{
count += test.CountTestCases();
}
return count;
}
public override int CountTestCases(IFilter filter)
{
int count = 0;
if(this.Filter(filter))
{
foreach(Test test in Tests)
{
count += test.CountTestCases(filter);
}
}
return count;
}
public override TestResult Run(EventListener listener)
{
return Run( listener, null );
}
public override TestResult Run(EventListener listener, IFilter filter)
{
TestSuiteResult suiteResult = new TestSuiteResult(this, Name);
listener.SuiteStarted(this);
long startTime = DateTime.Now.Ticks;
if ( ShouldRun )
{
suiteResult.Executed = true;
DoSetUp( suiteResult );
RunAllTests( suiteResult, listener, filter );
DoTearDown( suiteResult );
}
else
suiteResult.NotRun(this.IgnoreReason);
long stopTime = DateTime.Now.Ticks;
double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
suiteResult.Time = time;
listener.SuiteFinished(suiteResult);
return suiteResult;
}
public virtual void DoSetUp( TestResult suiteResult )
{
}
public virtual void DoTearDown( TestResult suiteResult )
{
}
protected virtual void RunAllTests(
TestSuiteResult suiteResult, EventListener listener, IFilter filter )
{
foreach(Test test in ArrayList.Synchronized(Tests))
{
bool saveShouldRun = test.ShouldRun;
if (test.ShouldRun)
{
if (this.ShouldRun == false)
{
test.ShouldRun = false;
test.IgnoreReason = this.IgnoreReason;
}
else if ( test.IsExplicit && filter == null )
{
test.ShouldRun = false;
test.IgnoreReason = EXPLICIT_SELECTION_REQUIRED;
}
}
if ( filter == null || test.Filter( filter ) )
{
suiteResult.AddResult( test.Run( listener, filter ) );
}
if ( saveShouldRun && !test.ShouldRun )
{
test.ShouldRun = true;
test.IgnoreReason = null;
}
}
}
public override bool Filter(IFilter filter)
{
return filter.Pass(this);
}
}
}

317
src/Libraries/NUnitFramework/src/core/TestSuiteBuilder.cs

@ -1,317 +0,0 @@ @@ -1,317 +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.Core
{
using System;
using System.IO;
using System.Reflection;
using System.Collections;
/// <summary>
/// Summary description for TestSuiteBuilder.
/// </summary>
public class TestSuiteBuilder
{
#region Private Fields
/// <summary>
/// Hashtable of all test suites we have created to represent namespaces.
/// Used to locate namespace parent suites for fixtures.
/// </summary>
Hashtable namespaceSuites = new Hashtable();
/// <summary>
/// The root of the test suite being created by this builder. This
/// may be a simple TestSuite, an AssemblyTestSuite or a RootTestSuite
/// encompassing multiple assemblies.
/// </summary>
TestSuite rootSuite;
/// <summary>
/// The version of the nunit framework referenced by the loaded assembly.
/// </summary>
Version frameworkVersion = null;
#endregion
#region Properties
public Version FrameworkVersion
{
get { return frameworkVersion; }
}
#endregion
#region Public Methods
public Assembly Load(string assemblyName)
{
// Change currentDirectory in case assembly references unmanaged dlls
string currentDirectory = Environment.CurrentDirectory;
string assemblyDirectory = Path.GetDirectoryName( assemblyName );
bool swap = assemblyDirectory != null && assemblyDirectory != string.Empty;
try
{
if ( swap )
Environment.CurrentDirectory = assemblyDirectory;
Assembly assembly = AppDomain.CurrentDomain.Load(Path.GetFileNameWithoutExtension(assemblyName));
foreach( AssemblyName refAssembly in assembly.GetReferencedAssemblies() )
{
if ( refAssembly.Name == "nunit.framework" )
this.frameworkVersion = refAssembly.Version;
}
return assembly;
}
finally
{
if ( swap )
Environment.CurrentDirectory = currentDirectory;
}
}
public TestSuite Build(string projectName, IList assemblies)
{
RootTestSuite rootSuite = new RootTestSuite( projectName );
int assemblyKey = 0;
foreach(string assembly in assemblies)
{
TestSuite suite = Build( assembly, assemblyKey++ );
rootSuite.Add( suite );
}
return rootSuite;
}
public TestSuite Build( string assemblyName )
{
return Build( assemblyName, 0 );
}
public TestSuite Build(string assemblyName, string testName )
{
TestSuite suite = null;
Assembly assembly = Load(assemblyName);
if(assembly != null)
{
Type testType = assembly.GetType(testName);
if( testType != null )
return MakeSuite( testType );
// Assume that testName is a namespace
string prefix = testName + '.';
Type[] testTypes = assembly.GetExportedTypes();
int testFixtureCount = 0;
foreach(Type type in testTypes)
{
if( CanMakeSuite( type ) && type.Namespace != null )
{
if( type.Namespace == testName || type.Namespace.StartsWith(prefix) )
{
suite = BuildFromNameSpace(testName, 0);
//suite.Add( new TestFixture( type ) );
suite.Add( MakeSuite( type ) );
testFixtureCount++;
}
}
}
return testFixtureCount == 0 ? null : rootSuite;
}
return suite;
}
public TestSuite Build( IList assemblies, string testName )
{
TestSuite suite = null;
foreach(string assemblyName in assemblies)
{
suite = Build( assemblyName, testName );
if ( suite != null ) break;
}
return suite;
}
// TODO: Only used in tests
public object BuildTestFixture( Type fixtureType )
{
Reflect.CheckFixtureType( fixtureType );
object testFixture;
ConstructorInfo ctor = Reflect.GetConstructor( fixtureType );
try
{
testFixture = ctor.Invoke( Type.EmptyTypes );
}
catch( Exception ex )
{
throw new InvalidTestFixtureException( ctor.Name + " threw a exception", ex );
}
if(testFixture == null) throw new InvalidTestFixtureException(ctor.Name + " cannot be invoked");
return testFixture;
}
#endregion
#region Nested TypeFilter Class
private class TypeFilter
{
private string rootNamespace;
TypeFilter( string rootNamespace )
{
this.rootNamespace = rootNamespace;
}
public bool Include( Type type )
{
if ( type.Namespace == rootNamespace )
return true;
return type.Namespace.StartsWith( rootNamespace + '.' );
}
}
#endregion
#region Helper Methods
private TestSuite BuildFromNameSpace( string nameSpace, int assemblyKey )
{
if( nameSpace == null || nameSpace == "" ) return rootSuite;
TestSuite suite = (TestSuite)namespaceSuites[nameSpace];
if(suite!=null) return suite;
int index = nameSpace.LastIndexOf(".");
string prefix = string.Format( "[{0}]", assemblyKey );
if( index == -1 )
{
suite = new NamespaceSuite( nameSpace, assemblyKey );
if ( rootSuite == null )
rootSuite = suite;
else
rootSuite.Add(suite);
namespaceSuites[nameSpace]=suite;
}
else
{
string parentNameSpace = nameSpace.Substring( 0,index );
TestSuite parent = BuildFromNameSpace( parentNameSpace, assemblyKey );
string suiteName = nameSpace.Substring( index+1 );
suite = new NamespaceSuite( parentNameSpace, suiteName, assemblyKey );
parent.Add( suite );
namespaceSuites[nameSpace] = suite;
}
return suite;
}
private TestSuite Build( string assemblyName, int assemblyKey )
{
TestSuiteBuilder builder = new TestSuiteBuilder();
Assembly assembly = Load( assemblyName );
builder.rootSuite = new AssemblyTestSuite( assemblyName, assemblyKey );
int testFixtureCount = 0;
Type[] testTypes = assembly.GetExportedTypes();
foreach(Type testType in testTypes)
{
if( CanMakeSuite( testType ) )
{
testFixtureCount++;
string namespaces = testType.Namespace;
TestSuite suite = builder.BuildFromNameSpace( namespaces, assemblyKey );
//suite.Add( new TestFixture( testType ) );
suite.Add( MakeSuite( testType ) );
}
}
if(testFixtureCount == 0)
{
builder.rootSuite.ShouldRun = false;
builder.rootSuite.IgnoreReason = "Has no TestFixtures";
}
return builder.rootSuite;
}
/// <summary>
/// Helper routine that makes a suite from either a TestFixture or
/// a legacy Suite property.
/// </summary>
/// <param name="testType"></param>
/// <returns></returns>
private TestSuite MakeSuite( Type testType )
{
TestSuite suite = null;
if(testType != null)
{
if( TestFixture.IsValidType( testType ) )
{
suite = new TestFixture( testType );
}
else if( LegacySuite.IsValidType( testType ) )
{
suite = new LegacySuite( testType );
}
}
return suite;
}
private bool CanMakeSuite( Type testType )
{
//return TestFixture.IsValidType( testType ) || LegacySuite.IsValidType( testType );
return TestFixture.IsValidType( testType );
}
}
#endregion
}

111
src/Libraries/NUnitFramework/src/core/TestSuiteResult.cs

@ -1,111 +0,0 @@ @@ -1,111 +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.Core
{
using System;
using System.Collections;
/// <summary>
/// TestSuiteResult
/// </summary>
///
[Serializable]
public class TestSuiteResult : TestResult
{
private ArrayList results = new ArrayList();
public TestSuiteResult(ITest test, string name) : base(test, name)
{
Executed = false;
}
public void AddResult(TestResult result)
{
results.Add(result);
}
public override bool IsSuccess
{
get
{
bool result = true;
foreach(TestResult testResult in results)
result &= testResult.IsSuccess;
return result;
}
}
/// <summary>
/// A suite is considered as failing if it is marked as a failure - usually
/// because TestFixtureSetUp or TestFixtureTearDown failed - or if one of the
/// tests it contains failed.
/// </summary>
public override bool IsFailure
{
get
{
if ( base.IsFailure )
return true;
foreach(TestResult testResult in results)
if ( testResult.IsFailure )
return true;
return false;
}
}
public override bool AllTestsExecuted
{
get
{
if (!this.Executed)
return false;
foreach( TestResult testResult in results )
{
if ( !testResult.AllTestsExecuted )
return false;
}
return true;
}
}
public IList Results
{
get { return results; }
}
public override void Accept(ResultVisitor visitor)
{
visitor.Visit(this);
}
}
}

77
src/Libraries/NUnitFramework/src/core/nunit.core.build

@ -1,77 +0,0 @@ @@ -1,77 +0,0 @@
<?xml version="1.0"?>
<project name="NUnit.Core" default="build">
<!--
Required properties:
* bin.dir - bin directory
* src.dir - source location(build) or target(copy)
* build.debug - (true|false) debug build?
* build.defines.csc - build defines for build config
-->
<target name="build" depends="copy">
<csc target="library" output="${bin.dir}/nunit.core.dll"
debug="${build.debug}" define="${build.defines.csc},StronglyNamedAssembly">
<sources basedir="${src.dir}/core">
<include name="*.cs"/>
</sources>
<references>
<include name="${bin.dir}/nunit.framework.dll"/>
</references>
</csc>
</target>
<target name="copy">
<copy todir="${src.dir}/core">
<fileset basedir=".">
<include name="nunit.core.dll.csproj"/>
<include name="nunit.core.build"/>
<include name="AssemblyInfo.cs"/>
<include name="CategoryFilter.cs"/>
<include name="CategoryManager.cs"/>
<include name="EmptyFilter.cs"/>
<include name="EventListener.cs"/>
<include name="ExpectedExceptionTestCase.cs"/>
<include name="Filter.cs"/>
<include name="InvalidSuiteException.cs"/>
<include name="InvalidTestFixtureException.cs"/>
<include name="ITest.cs"/>
<include name="ITestEvents.cs"/>
<include name="LegacySuite.cs"/>
<include name="LongLivingMarshalByRefObject.cs"/>
<include name="NameFilter.cs"/>
<include name="NamespaceSuite.cs"/>
<include name="NormalTestCase.cs"/>
<include name="NoTestFixturesException.cs"/>
<include name="NotRunnableTestCase.cs"/>
<include name="NullListener.cs"/>
<include name="NunitException.cs"/>
<include name="Reflect.cs"/>
<include name="RemoteTestRunner.cs"/>
<include name="Results.xsd"/>
<include name="ResultVisitor.cs"/>
<include name="RootTestSuite.cs"/>
<include name="StringTextWriter.cs"/>
<include name="Summary.xslt"/>
<include name="TemplateTestCase.cs"/>
<include name="Test.cs"/>
<include name="TestAssembly.cs"/>
<include name="TestCase.cs"/>
<include name="TestCaseBuilder.cs"/>
<include name="TestCaseResult.cs"/>
<include name="TestEventArgs.cs"/>
<include name="TestEventDispatcher.cs"/>
<include name="TestFixture.cs"/>
<include name="TestResult.cs"/>
<include name="TestRunner.cs"/>
<include name="TestRunnerThread.cs"/>
<include name="TestSuite.cs"/>
<include name="TestSuiteBuilder.cs"/>
<include name="TestSuiteResult.cs"/>
</fileset>
</copy>
</target>
</project>

328
src/Libraries/NUnitFramework/src/core/nunit.core.dll.csproj

@ -1,328 +0,0 @@ @@ -1,328 +0,0 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{EBD43A7F-AFCA-4281-BB53-5CDD91F966A3}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "nunit.core"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "NUnit.Core"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE;StronglyNamedAssembly"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Debug-Strong"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE;StronglyNamedAssembly"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "E:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "E:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "E:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
<Reference
Name = "nunit.framework.dll"
Project = "{83DD7E12-A705-4DBA-9D71-09C8973D9382}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "CategoryFilter.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "CategoryManager.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "EmptyFilter.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "EventListener.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ExpectedExceptionTestCase.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Filter.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "InvalidSuiteException.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "InvalidTestFixtureException.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ITest.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ITestEvents.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "LegacySuite.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "LongLivingMarshalByRefObject.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NameFilter.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NamespaceSuite.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NormalTestCase.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NoTestFixturesException.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NotRunnableTestCase.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NullListener.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NunitException.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Reflect.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "RemoteTestRunner.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Results.xsd"
BuildAction = "Content"
/>
<File
RelPath = "Results.xsx"
DependentUpon = "Results.xsd"
BuildAction = "None"
/>
<File
RelPath = "ResultVisitor.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "RootTestSuite.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "StringTextWriter.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Summary.xslt"
BuildAction = "Content"
/>
<File
RelPath = "TemplateTestCase.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Test.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestAssembly.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestCase.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestCaseBuilder.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestCaseResult.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestEventArgs.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestEventDispatcher.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestFixture.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestResult.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestRunner.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestRunnerThread.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestSuite.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestSuiteBuilder.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestSuiteResult.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

63
src/Libraries/NUnitFramework/src/framework/AssemblyInfo.cs

@ -1,63 +0,0 @@ @@ -1,63 +0,0 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: CLSCompliant(true)]
//
// General Information about an assembly 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("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[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.0.0")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
#if !StronglyNamedAssembly
[assembly: AssemblyDelaySign(false)]
#else
[assembly: AssemblyKeyFile("..\\nunit.key")]
[assembly: AssemblyKeyName("")]
#endif

781
src/Libraries/NUnitFramework/src/framework/Assert.cs

@ -1,781 +0,0 @@ @@ -1,781 +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;
using System.Collections;
using System.ComponentModel;
namespace NUnit.Framework
{
/// <summary>
/// A set of Assert methods
/// </summary>
public class Assert
{
private static int counter = 0;
/// <summary>
/// Gets the number of assertions executed so far and
/// resets the counter to zero.
/// </summary>
public static int Counter
{
get
{
int cnt = counter;
counter = 0;
return cnt;
}
}
/// <summary>
/// A private constructor disallows any instances of this object.
/// </summary>
private Assert()
{}
/// <summary>
/// Asserts that a condition is true. If the condition is false the method throws
/// an <see cref="AssertionException"/>.
/// </summary>
/// <param name="condition">The evaluated condition</param>
/// <param name="message">The message to display if the condition is false</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void IsTrue(bool condition, string message, params object[] args)
{
++counter;
if (!condition)
Assert.Fail(message, args);
}
/// <summary>
/// Asserts that a condition is true. If the condition is false the method throws
/// an <see cref="AssertionException"/>.
/// </summary>
/// <param name="condition">The evaluated condition</param>
/// <param name="message">The message to display if the condition is false</param>
static public void IsTrue(bool condition, string message)
{
Assert.IsTrue(condition, message, null);
}
/// <summary>
/// Asserts that a condition is true. If the condition is false the method throws
/// an <see cref="AssertionException"/>.
/// </summary>
/// <param name="condition">The evaluated condition</param>
static public void IsTrue(bool condition)
{
Assert.IsTrue(condition, string.Empty, null);
}
/// <summary>
/// Asserts that a condition is false. If the condition is true the method throws
/// an <see cref="AssertionException"/>.
/// </summary>
/// <param name="condition">The evaluated condition</param>
/// <param name="message">The message to display if the condition is true</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void IsFalse(bool condition, string message, params object[] args)
{
++counter;
if (condition)
Assert.Fail(message, args);
}
/// <summary>
/// Asserts that a condition is false. If the condition is true the method throws
/// an <see cref="AssertionException"/>.
/// </summary>
/// <param name="condition">The evaluated condition</param>
/// <param name="message">The message to display if the condition is true</param>
static public void IsFalse(bool condition, string message)
{
Assert.IsFalse( condition, message, null );
}
/// <summary>
/// Asserts that a condition is false. If the condition is true the method throws
/// an <see cref="AssertionException"/>.
/// </summary>
/// <param name="condition">The evaluated condition</param>
static public void IsFalse(bool condition)
{
Assert.IsFalse(condition, string.Empty, null);
}
/// <summary>
/// Verifies that two doubles are equal considering a delta. If the
/// expected value is infinity then the delta value is ignored. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </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>
/// <param name="message">The message that will be printed on failure</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void AreEqual(double expected,
double actual, double delta, string message, params object[] args)
{
++counter;
// 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(expected) || double.IsNaN(expected) || double.IsNaN(actual))
{
if (!(expected == actual))
Assert.FailNotEquals(expected, actual, message, args);
}
else if (!(Math.Abs(expected-actual) <= delta))
Assert.FailNotEquals(expected, actual, message, args);
}
/// <summary>
/// Verifies that two doubles are equal considering a delta. If the
/// expected value is infinity then the delta value is ignored. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </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>
/// <param name="message">The message that will be printed on failure</param>
static public void AreEqual(double expected,
double actual, double delta, string message)
{
Assert.AreEqual( expected, actual, delta, message, null );
}
/// <summary>
/// Verifies that two doubles are equal considering a delta. If the
/// expected value is infinity then the delta value is ignored. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </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 AreEqual(double expected, double actual, double delta)
{
Assert.AreEqual(expected, actual, delta, string.Empty, null);
}
/// <summary>
/// Verifies that two floats are equal considering a delta. If the
/// expected value is infinity then the delta value is ignored. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </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>
/// <param name="message">The message printed out upon failure</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void AreEqual(float expected,
float actual, float delta, string message, params object[] args)
{
++counter;
// 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(expected) || float.IsNaN(expected) || float.IsNaN(actual))
{
if (!(expected == actual))
Assert.FailNotEquals(expected, actual, message, args);
}
else if (!(Math.Abs(expected-actual) <= delta))
Assert.FailNotEquals(expected, actual, message, args);
}
/// <summary>
/// Verifies that two floats are equal considering a delta. If the
/// expected value is infinity then the delta value is ignored. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </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>
/// <param name="message">The message printed out upon failure</param>
static public void AreEqual(float expected, float actual, float delta, string message)
{
Assert.AreEqual(expected, actual, delta, message, null);
}
/// <summary>
/// Verifies that two floats are equal considering a delta. If the
/// expected value is infinity then the delta value is ignored. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </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 AreEqual(float expected, float actual, float delta)
{
Assert.AreEqual(expected, actual, delta, string.Empty, null);
}
/// <summary>
/// Verifies that two decimals are equal. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message printed out upon failure</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void AreEqual(decimal expected, decimal actual, string message, params object[] args)
{
++counter;
if(!(expected == actual))
Assert.FailNotEquals(expected, actual, message, args);
}
/// <summary>
/// Verifies that two decimals are equal. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message printed out upon failure</param>
static public void AreEqual(decimal expected, decimal actual, string message)
{
Assert.AreEqual(expected, actual, message, null);
}
/// <summary>
/// Verifies that two decimals are equal. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
static public void AreEqual(decimal expected, decimal actual)
{
Assert.AreEqual(expected, actual, string.Empty, null);
}
/// <summary>
/// Verifies that two ints are equal. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message printed out upon failure</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void AreEqual(int expected, int actual, string message, params object[] args)
{
++counter;
if(!(expected == actual))
Assert.FailNotEquals(expected, actual, message, args);
}
/// <summary>
/// Verifies that two ints are equal. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message printed out upon failure</param>
static public void AreEqual(int expected, int actual, string message)
{
Assert.AreEqual(expected, actual, message, null);
}
/// <summary>
/// Verifies that two ints are equal. If
/// they are not equals then an <see cref="AssertionException"/> is
/// thrown.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
static public void AreEqual(int expected, int actual)
{
Assert.AreEqual(expected, actual, string.Empty, null);
}
/// <summary>
/// Verifies that two arrays are equal. If they are not,
/// then an <see cref="AssertionException"/> is thrown.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message printed out upon failure</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void AreEqual( System.Array expected, System.Array actual, string message, params object[] args )
{
++counter;
if ( expected == null && actual == null ) return;
if ( expected == null || actual == null )
Assert.FailNotEquals( expected, actual, message, args );
if ( expected.Rank != actual.Rank )
Assert.FailNotEquals( expected, actual, message, args );
if ( expected.Rank != 1 )
Assert.Fail( "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 ) ) )
{
Assert.FailArraysNotEqual(i, expected, actual, message, args );
}
if ( expected.Length != actual.Length )
Assert.FailArraysNotEqual( iLength, expected, actual, message, args );
return;
}
/// <summary>
/// Verifies that two arrays are equal. If they are not,
/// then an <see cref="AssertionException"/> is thrown.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message printed out upon failure</param>
static public void AreEqual( System.Array expected, System.Array actual, string message )
{
Assert.AreEqual( expected, actual, message, null );
}
/// <summary>
/// Verifies that two arrays are equal. If they are not,
/// then an <see cref="AssertionException"/> is thrown.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
static public void AreEqual( System.Array expected, System.Array actual )
{
Assert.AreEqual( expected, actual, string.Empty, null );
}
/// <summary>
/// Verifies that two objects are equal. Two objects are considered
/// equal if both are null, or if both have the same value. All
/// non-numeric types are compared by using the <c>Equals</c> method.
/// Arrays are compared by comparing each element using the same rules.
/// If they are not equal an <see cref="AssertionException"/> is thrown.
/// </summary>
/// <param name="expected">The value that is expected</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message to display if objects are not equal</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void AreEqual(Object expected, Object actual, string message, params object[] args)
{
if ( expected == null && actual == null ) return;
if ( expected == null || actual == null )
Assert.FailNotEquals( expected, actual, message, args );
// 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 )
Assert.AreEqual( (System.Array)expected, (System.Array)actual, message, args );
else
{
++counter;
if ( !ObjectsEqual( expected, actual ) )
Assert.FailNotEquals( expected, actual, message, args );
}
}
/// <summary>
/// Verifies that two objects are equal. Two objects are considered
/// equal if both are null, or if both have the same value. 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>
/// <param name="expected">The value that is expected</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message to display if objects are not equal</param>
static public void AreEqual(Object expected, Object actual, string message)
{
Assert.AreEqual(expected, actual, message, null);
}
/// <summary>
/// Verifies that two objects are equal. Two objects are considered
/// equal if both are null, or if both have the same value. 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>
/// <param name="expected">The value that is expected</param>
/// <param name="actual">The actual value</param>
static public void AreEqual(Object expected, Object actual)
{
Assert.AreEqual(expected, actual, string.Empty, null);
}
/// <summary>
/// The Equals method throws an AssertionException. This is done
/// to make sure there is no mistake by calling this function.
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
[EditorBrowsable(EditorBrowsableState.Never)]
public static new bool Equals(object a, object b)
{
throw new AssertionException("Assert.Equals should not be used for Assertions");
}
/// <summary>
/// override the default ReferenceEquals to throw an AssertionException. This
/// implementation makes sure there is no mistake in calling this function
/// as part of Assert.
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
public static new void ReferenceEquals(object a, object b)
{
throw new AssertionException("Assert.ReferenceEquals should not be used for Assertions");
}
/// <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>
static protected 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>
/// 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>
static protected bool ObjectsEqual( Object expected, Object actual )
{
if ( expected == null && actual == null ) return true;
if ( expected == null || actual == null ) return false;
if( 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>
/// Verifies that the object that is passed in is not equal to <code>null</code>
/// If the object is not <code>null</code> then an <see cref="AssertionException"/>
/// is thrown.
/// </summary>
/// <param name="anObject">The object that is to be tested</param>
/// <param name="message">The message to be printed when the object is null</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void IsNotNull(Object anObject, string message, params object[] args)
{
Assert.IsTrue(anObject != null, message, args);
}
/// <summary>
/// Verifies that the object that is passed in is not equal to <code>null</code>
/// If the object is not <code>null</code> then an <see cref="AssertionException"/>
/// is thrown.
/// </summary>
/// <param name="anObject">The object that is to be tested</param>
static public void IsNotNull(Object anObject, string message)
{
Assert.IsNotNull(anObject, message, null);
}
/// <summary>
/// Verifies that the object that is passed in is not equal to <code>null</code>
/// If the object is not <code>null</code> then an <see cref="AssertionException"/>
/// is thrown.
/// </summary>
/// <param name="anObject">The object that is to be tested</param>
static public void IsNotNull(Object anObject)
{
Assert.IsNotNull(anObject, string.Empty, null);
}
/// <summary>
/// Verifies that the object that is passed in is equal to <code>null</code>
/// If the object is <code>null</code> then an <see cref="AssertionException"/>
/// is thrown.
/// </summary>
/// <param name="anObject">The object that is to be tested</param>
/// <param name="message">The message to be printed when the object is not null</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void IsNull(Object anObject, string message, params object[] args)
{
Assert.IsTrue(anObject == null, message, args);
}
/// <summary>
/// Verifies that the object that is passed in is equal to <code>null</code>
/// If the object is <code>null</code> then an <see cref="AssertionException"/>
/// is thrown.
/// </summary>
/// <param name="anObject">The object that is to be tested</param>
static public void IsNull(Object anObject, string message)
{
Assert.IsNull(anObject, message, null);
}
/// <summary>
/// Verifies that the object that is passed in is equal to <code>null</code>
/// If the object is <code>null</code> then an <see cref="AssertionException"/>
/// is thrown.
/// </summary>
/// <param name="anObject">The object that is to be tested</param>
static public void IsNull(Object anObject)
{
Assert.IsNull(anObject, string.Empty, null);
}
/// <summary>
/// Asserts that two objects refer to the same object. If they
/// are not the same an <see cref="AssertionException"/> is thrown.
/// </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 not the same object.</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void AreSame(Object expected, Object actual, string message, params object[] args)
{
++counter;
if (object.ReferenceEquals(expected, actual)) return;
Assert.FailNotSame(expected, actual, message, args);
}
/// <summary>
/// Asserts that two objects refer to the same object. If they
/// are not the same an <see cref="AssertionException"/> is thrown.
/// </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 object is null</param>
static public void AreSame(Object expected, Object actual, string message)
{
Assert.AreSame(expected, actual, message, null);
}
/// <summary>
/// Asserts that two objects refer to the same object. If they
/// are not the same an <see cref="AssertionException"/> is thrown.
/// </summary>
/// <param name="expected">The expected object</param>
/// <param name="actual">The actual object</param>
static public void AreSame(Object expected, Object actual)
{
Assert.AreSame(expected, actual, string.Empty, null);
}
/// <summary>
/// Throws an <see cref="AssertionException"/> with the message and arguments
/// that are passed in. This is used by the other Assert functions.
/// </summary>
/// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void Fail(string message, params object[] args )
{
if (message == null) message = string.Empty;
else if ( args != null && args.Length > 0 )
message = string.Format( message, args );
throw new AssertionException(message);
}
/// <summary>
/// Throws an <see cref="AssertionException"/> with the message that is
/// passed in. This is used by the other Assert functions.
/// </summary>
/// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
static public void Fail(string message)
{
Assert.Fail(message, null);
}
/// <summary>
/// Throws an <see cref="AssertionException"/>.
/// This is used by the other Assert functions.
/// </summary>
static public void Fail()
{
Assert.Fail(string.Empty, null);
}
/// <summary>
/// Throws an <see cref="IgnoreException"/> with the message and arguments
/// that are passed in. This causes the test to be reported as ignored.
/// </summary>
/// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static public void Ignore( string message, object[] args )
{
if (message == null) message = string.Empty;
else if ( args != null && args.Length > 0 )
message = string.Format( message, args );
throw new IgnoreException(message);
}
/// <summary>
/// Throws an <see cref="IgnoreException"/> with the message that is
/// passed in. This causes the test to be reported as ignored.
/// </summary>
/// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
static public void Ignore( string message )
{
Assert.Ignore( message, null );
}
/// <summary>
/// Throws an <see cref="IgnoreException"/>.
/// This causes the test to be reported as ignored.
/// </summary>
/// <param name="message">The message to initialize the <see cref="AssertionException"/> with.</param>
static public void Ignore()
{
Assert.Ignore( string.Empty, null );
}
/// <summary>
/// This method is called when two objects have been compared and found to be
/// different. This prints a nice message to the screen.
/// </summary>
/// <param name="message">The message that is to be printed prior to the comparison failure</param>
/// <param name="expected">The expected object</param>
/// <param name="actual">The actual object</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static protected void FailNotEquals(Object expected, Object actual, string message,
params object[] args)
{
Assert.Fail(
AssertionFailureMessage.FormatMessageForFailNotEquals(
expected,
actual,
message,
args));
}
/// <summary>
/// This method is called when two arrays have been compared and found to be
/// different. This prints a nice message to the screen.
/// </summary>
/// <param name="index">The index at which the failure occured</param>
/// <param name="expected">The expected array</param>
/// <param name="actual">The actual array</param>
/// <param name="message">The message that is to be printed prior to the comparison failure</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static protected void FailArraysNotEqual(int index, Array expected, Array actual,
string message, params object[] args)
{
Assert.Fail(
AssertionFailureMessage.FormatMessageForFailArraysNotEqual(
index,
expected,
actual,
message,
args));
}
/// <summary>
/// This method is called when the two objects are not the same.
/// </summary>
/// <param name="message">The message to be printed on the screen</param>
/// <param name="expected">The expected object</param>
/// <param name="actual">The actual object</param>
/// <param name="args">Arguments to be used in formatting the message</param>
static protected void FailNotSame(Object expected, Object actual, string message, params object[] args)
{
string formatted = string.Empty;
if ( message != null )
{
if (args != null && args.Length > 0 )
formatted = string.Format( message+" ", args );
else
formatted = message+" ";
}
Assert.Fail(formatted+"expected same");
}
}
}

190
src/Libraries/NUnitFramework/src/framework/Assertion.cs

@ -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);
}
}
}

68
src/Libraries/NUnitFramework/src/framework/AssertionException.cs

@ -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)
{}
}
}

758
src/Libraries/NUnitFramework/src/framework/AssertionFailureMessage.cs

@ -1,758 +0,0 @@ @@ -1,758 +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;
namespace NUnit.Framework
{
/// <summary>
/// Summary description for AssertionFailureMessage.
/// </summary>
public class AssertionFailureMessage
{
/// <summary>
/// Protected constructor, used since this class is only used via
/// static methods
/// </summary>
protected AssertionFailureMessage()
{}
/// <summary>
/// Number of characters before a highlighted position before
/// clipping will occur. Clipped text is replaced with an
/// elipses "..."
/// </summary>
static protected int PreClipLength
{
get
{
return 35;
}
}
/// <summary>
/// Number of characters after a highlighted position before
/// clipping will occur. Clipped text is replaced with an
/// elipses "..."
/// </summary>
static protected int PostClipLength
{
get
{
return 35;
}
}
/// <summary>
/// Called to test if the position will cause clipping
/// to occur in the early part of a string.
/// </summary>
/// <param name="iPosition"></param>
/// <returns></returns>
static private bool IsPreClipped( int iPosition )
{
if( iPosition > PreClipLength )
{
return true;
}
return false;
}
/// <summary>
/// Called to test if the position will cause clipping
/// to occur in the later part of a string past the
/// specified position.
/// </summary>
/// <param name="sString"></param>
/// <param name="iPosition"></param>
/// <returns></returns>
static private bool IsPostClipped( string sString, int iPosition )
{
if( sString.Length - iPosition > PostClipLength )
{
return true;
}
return false;
}
/// <summary>
/// Property called to insert newline characters into a string
/// </summary>
static private string NewLine
{
get
{
return "\r\n\t";
}
}
/// <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( null == sString || 0 == sString.Length )
{
return "";
}
return BuildBefore( sString, iPosition ) + BuildAfter( sString, iPosition );
}
/// <summary>
/// Clips the string before the specified position, and appends
/// ellipses (...) to show that clipping has occurred
/// </summary>
/// <param name="sString"></param>
/// <param name="iPosition"></param>
/// <returns></returns>
static protected string PreClip( string sString, int iPosition )
{
return "..." + sString.Substring( iPosition - PreClipLength, PreClipLength );
}
/// <summary>
/// Clips the string after the specified position, and appends
/// ellipses (...) to show that clipping has occurred
/// </summary>
/// <param name="sString"></param>
/// <param name="iPosition"></param>
/// <returns></returns>
static protected string PostClip( string sString, int iPosition )
{
return sString.Substring( iPosition, PostClipLength ) + "...";
}
/// <summary>
/// Builds the first half of a string, limiting the number of
/// characters before the position, and removing newline
/// characters. If the leading string is truncated, the
/// ellipses (...) characters are appened.
/// </summary>
/// <param name="sString"></param>
/// <param name="iPosition"></param>
/// <returns></returns>
static private string BuildBefore( string sString, int iPosition )
{
if( IsPreClipped(iPosition) )
{
return PreClip( sString, iPosition );
}
return sString.Substring( 0, iPosition );
}
/// <summary>
/// Builds the last half of a string, limiting the number of
/// characters after the position, and removing newline
/// characters. If the string is truncated, the
/// ellipses (...) characters are appened.
/// </summary>
/// <param name="sString"></param>
/// <param name="iPosition"></param>
/// <returns></returns>
static private string BuildAfter( string sString, int iPosition )
{
if( IsPostClipped(sString, iPosition) )
{
return PostClip( sString, iPosition );
}
return sString.Substring( iPosition );
}
/// <summary>
/// Text that is rendered for the expected value
/// </summary>
/// <returns></returns>
static protected string ExpectedText()
{
return "expected:<";
}
/// <summary>
/// Text rendered for the actual value. This text should
/// be the same length as the Expected text, so leading
/// spaces should pad this string to ensure they match.
/// </summary>
/// <returns></returns>
static protected string ButWasText()
{
return " but was:<";
}
/// <summary>
/// Raw line that communicates the expected value, and the actual value
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="expected"></param>
/// <param name="actual"></param>
static protected void AppendExpectedAndActual( StringBuilder sbOutput, Object expected, Object actual )
{
sbOutput.Append( NewLine );
sbOutput.Append( ExpectedText() );
sbOutput.Append( DisplayString( expected ) );
sbOutput.Append( ">" );
sbOutput.Append( NewLine );
sbOutput.Append( ButWasText() );
sbOutput.Append( DisplayString( actual ) );
sbOutput.Append( ">" );
}
/// <summary>
/// Display an object as a string
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
static protected string DisplayString( object obj )
{
if ( obj == null )
return "(null)";
else if ( obj is string )
return Quoted( (string)obj );
else
return obj.ToString();
}
/// <summary>
/// Quote a string
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
static protected string Quoted( string text )
{
return string.Format( "\"{0}\"", text );
}
/// <summary>
/// Draws a marker under the expected/actual strings that highlights
/// where in the string a mismatch occurred.
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="iPosition"></param>
static protected void AppendPositionMarker( StringBuilder sbOutput, int iPosition )
{
sbOutput.Append( new String( '-', ButWasText().Length + 1 ) );
if( iPosition > 0 )
{
sbOutput.Append( new string( '-', iPosition ) );
}
sbOutput.Append( "^" );
}
/// <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 )
{
if( null != expected &&
null != actual &&
expected is string &&
actual is string )
{
return true;
}
return false;
}
/// <summary>
/// Tests if two strings are different lengths.
/// </summary>
/// <param name="sExpected"></param>
/// <param name="sActual"></param>
/// <returns>True if string lengths are different</returns>
static protected bool LengthsDifferent( string sExpected, string sActual )
{
if( sExpected.Length != sActual.Length )
{
return true;
}
return false;
}
/// <summary>
/// Tests if two arrays are different lengths.
/// </summary>
/// <param name="sExpected"></param>
/// <param name="sActual"></param>
/// <returns>True if array lengths are different</returns>
static protected bool LengthsDifferent( object[] expected, object[] actual )
{
if( expected.Length != actual.Length )
{
return true;
}
return false;
}
/// <summary>
/// Used to construct a message when the lengths of two strings are
/// different. Also includes the strings themselves, to allow them
/// to be compared visually.
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="sExpected"></param>
/// <param name="sActual"></param>
static protected void BuildLengthsDifferentMessage( StringBuilder sbOutput, string sExpected, string sActual )
{
BuildContentDifferentMessage( sbOutput, sExpected, sActual );
}
/// <summary>
/// Reports the length of two strings that are different lengths
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="sExpected"></param>
/// <param name="sActual"></param>
static protected void BuildStringLengthDifferentReport( StringBuilder sbOutput, string sExpected, string sActual )
{
sbOutput.Append( "String lengths differ. Expected length=" );
sbOutput.Append( sExpected.Length );
sbOutput.Append( ", but was length=" );
sbOutput.Append( sActual.Length );
sbOutput.Append( "." );
sbOutput.Append( NewLine );
}
/// <summary>
/// Reports the length of two strings that are the same length
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="sExpected"></param>
/// <param name="sActual"></param>
static protected void BuildStringLengthSameReport( StringBuilder sbOutput, string sExpected, string sActual )
{
sbOutput.Append( "String lengths are both " );
sbOutput.Append( sExpected.Length );
sbOutput.Append( "." );
sbOutput.Append( NewLine );
}
/// <summary>
/// Reports whether the string lengths are the same or different, and
/// what the string lengths are.
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="sExpected"></param>
/// <param name="sActual"></param>
static protected void BuildStringLengthReport( StringBuilder sbOutput, string sExpected, string sActual )
{
if( sExpected.Length != sActual.Length )
{
BuildStringLengthDifferentReport( sbOutput, sExpected, sActual );
}
else
{
BuildStringLengthSameReport( sbOutput, sExpected, sActual );
}
}
/// <summary>
/// Reports the length of two arrays that are different lengths
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="expected"></param>
/// <param name="actual"></param>
static protected void BuildArrayLengthDifferentReport( StringBuilder sbOutput, Array expected, Array actual )
{
sbOutput.Append( "Array lengths differ. Expected length=" );
sbOutput.Append( expected.Length );
sbOutput.Append( ", but was length=" );
sbOutput.Append( actual.Length );
sbOutput.Append( "." );
sbOutput.Append( NewLine );
}
/// <summary>
/// Reports the length of two arrays that are the same length
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="expected"></param>
/// <param name="actual"></param>
static protected void BuildArrayLengthSameReport( StringBuilder sbOutput, Array expected, Array actual )
{
sbOutput.Append( "Array lengths are both " );
sbOutput.Append( expected.Length );
sbOutput.Append( "." );
sbOutput.Append( NewLine );
}
/// <summary>
/// Reports whether the array lengths are the same or different, and
/// what the array lengths are.
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="expected"></param>
/// <param name="actual"></param>
static protected void BuildArrayLengthReport( StringBuilder sbOutput, Array expected, Array actual )
{
if( expected.Length != actual.Length )
{
BuildArrayLengthDifferentReport( sbOutput, expected, actual );
}
else
{
BuildArrayLengthSameReport( sbOutput, expected, actual );
}
}
/// <summary>
///
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="sExpected"></param>
/// <param name="sActual"></param>
/// <param name="iPosition"></param>
static private void BuildContentDifferentAtPosition( StringBuilder sbOutput, string sExpected, string sActual, int iPosition )
{
BuildStringLengthReport( sbOutput, sExpected, sActual );
sbOutput.Append( "Strings differ at index " );
sbOutput.Append( iPosition );
sbOutput.Append( "." );
sbOutput.Append( NewLine );
//
// Clips the strings, then turns any hidden whitespace into visible
// characters
//
string sClippedExpected = ConvertWhitespace(ClipAroundPosition( sExpected, iPosition ));
string sClippedActual = ConvertWhitespace(ClipAroundPosition( sActual, iPosition ));
AppendExpectedAndActual(
sbOutput,
sClippedExpected,
sClippedActual );
sbOutput.Append( NewLine );
// Add a line showing where they differ. If the string lengths are
// different, they start differing just past the length of the
// shorter string
AppendPositionMarker(
sbOutput,
FindMismatchPosition( sClippedExpected, sClippedActual, 0 ) );
sbOutput.Append( NewLine );
}
/// <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;
}
/// <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>
/// 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="sbOutput"></param>
/// <param name="sExpected"></param>
/// <param name="sActual"></param>
static protected void BuildContentDifferentMessage( StringBuilder sbOutput, string sExpected, string sActual )
{
//
// If they mismatch at a specified position, report the
// difference.
//
int iMismatch = FindMismatchPosition( sExpected, sActual, 0 );
if( -1 != iMismatch )
{
BuildContentDifferentAtPosition(
sbOutput,
sExpected,
sActual,
iMismatch );
return;
}
//
// If the lengths differ, but they match up to the length,
// show the difference just past the length of the shorter
// string
//
if( sExpected.Length != sActual.Length )
{
BuildContentDifferentAtPosition(
sbOutput,
sExpected,
sActual,
Math.Min(sExpected.Length, sActual.Length) );
}
}
/// <summary>
/// Called to append a message when the input strings are different.
/// A different message is rendered when the lengths are mismatched,
/// and when the lengths match but content is mismatched.
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="expected"></param>
/// <param name="actual"></param>
static private void BuildStringsDifferentMessage( StringBuilder sbOutput, string expected, string actual )
{
sbOutput.Append( NewLine );
if( LengthsDifferent( expected, actual ) )
{
BuildLengthsDifferentMessage( sbOutput, expected, actual );
}
else
{
BuildContentDifferentMessage( sbOutput, expected, actual );
}
}
/// <summary>
/// Called to append a message when the input arrays are different.
/// A different message is rendered when the lengths are mismatched,
/// and when the lengths match but content is mismatched.
/// </summary>
/// <param name="sbOutput"></param>
/// <param name="expected"></param>
/// <param name="actual"></param>
static private void BuildArraysDifferentMessage( StringBuilder sbOutput, int index, Array expected, Array actual )
{
sbOutput.Append( NewLine );
BuildArrayLengthReport( sbOutput, expected, actual );
sbOutput.Append( "Arrays differ at index " );
sbOutput.Append( index );
sbOutput.Append( "." );
sbOutput.Append( NewLine );
if ( index < expected.Length && index < actual.Length )
{
if( InputsAreStrings( expected.GetValue(index), actual.GetValue(index) ) )
{
BuildStringsDifferentMessage(
sbOutput,
(string)expected.GetValue(index),
(string)actual.GetValue(index) );
}
else
{
AppendExpectedAndActual( sbOutput, expected.GetValue(index), actual.GetValue(index) );
}
}
else if( expected.Length < actual.Length )
{
sbOutput.Append( NewLine );
sbOutput.Append( " extra:<" );
DisplayElements( sbOutput, actual, index, 3 );
sbOutput.Append( ">" );
}
else
{
sbOutput.Append( NewLine );
sbOutput.Append( " missing:<" );
DisplayElements( sbOutput, expected, index, 3 );
sbOutput.Append( ">" );
}
return;
}
static private void DisplayElements( StringBuilder sbOutput, Array array, int index, int max )
{
for( int i = 0; i < max; i++ )
{
sbOutput.Append( DisplayString( array.GetValue(index++) ) );
if ( index >= array.Length )
return;
sbOutput.Append( "," );
}
sbOutput.Append( "..." );
}
/// <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>
/// <returns></returns>
static protected StringBuilder CreateStringBuilder( string message, params object[] args )
{
StringBuilder sbOutput;
if (message != null)
{
if ( args != null && args.Length > 0 )
sbOutput = new StringBuilder( string.Format( message, args ) );
else
sbOutput = new StringBuilder( message );
}
else
{
sbOutput = new StringBuilder();
}
return sbOutput;
}
/// <summary>
/// Called to create a message 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"></param>
/// <param name="actual"></param>
/// <param name="message"></param>
/// <param name="args"></param>
/// <returns></returns>
static public string FormatMessageForFailNotEquals(Object expected, Object actual,
string message, params object[] args)
{
StringBuilder sbOutput = CreateStringBuilder( message, args );
if( null != message )
{
if( message.Length > 0 )
{
sbOutput.Append( " " );
}
}
if( InputsAreStrings( expected, actual ) )
{
BuildStringsDifferentMessage(
sbOutput,
(string)expected,
(string)actual );
}
else
{
AppendExpectedAndActual( sbOutput, expected, actual );
}
return sbOutput.ToString();
}
/// <summary>
/// Called to create a message when two arrays are not equal.
/// </summary>
/// <param name="message"></param>
/// <param name="expected"></param>
/// <param name="actual"></param>
/// <returns></returns>
static public string FormatMessageForFailArraysNotEqual(int index, Array expected, Array actual,
string message, params object[] args)
{
StringBuilder sbOutput = CreateStringBuilder( message, args );
if( null != message )
{
if( message.Length > 0 )
{
sbOutput.Append( " " );
}
}
BuildArraysDifferentMessage(
sbOutput,
index,
expected,
actual );
return sbOutput.ToString();
}
}
}

60
src/Libraries/NUnitFramework/src/framework/CategoryAttribute.cs

@ -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; }
}
}
}

82
src/Libraries/NUnitFramework/src/framework/ExpectedExceptionAttribute.cs

@ -1,82 +0,0 @@ @@ -1,82 +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>
/// ExpectedAttributeException.
/// </summary>
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)]
public sealed class ExpectedExceptionAttribute : Attribute
{
private Type expectedException;
private string expectedMessage;
/// <summary>
/// Constructor for a given type of exception
/// </summary>
/// <param name="exceptionType"></param>
public ExpectedExceptionAttribute(Type exceptionType)
{
expectedException = exceptionType;
}
/// <summary>
/// Constructor for a given type of exception and expected message text
/// </summary>
/// <param name="exceptionType"></param>
/// <param name="expectedMessage"></param>
public ExpectedExceptionAttribute(Type exceptionType, string expectedMessage)
{
expectedException = exceptionType;
this.expectedMessage = expectedMessage;
}
/// <summary>
/// The expected exception type
/// </summary>
public Type ExceptionType
{
get{ return expectedException; }
set{ expectedException = value; }
}
/// <summary>
/// The expected message
/// </summary>
public string ExpectedMessage
{
get { return expectedMessage; }
set { expectedMessage = value; }
}
}
}

21
src/Libraries/NUnitFramework/src/framework/ExplicitAttribute.cs

@ -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()
{
}
}
}

59
src/Libraries/NUnitFramework/src/framework/IgnoreAttribute.cs

@ -1,59 +0,0 @@ @@ -1,59 +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>
/// Constructor
/// </summary>
/// <param name="reason"></param>
public IgnoreAttribute(string reason)
{
this.reason = reason;
}
/// <summary>
/// The reason for ignoring a test
/// </summary>
public string Reason
{
get { return reason; }
}
}
}

68
src/Libraries/NUnitFramework/src/framework/IgnoreException.cs

@ -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)
{}
}
}

58
src/Libraries/NUnitFramework/src/framework/OldTestCase.cs

@ -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()
{}
}
}

40
src/Libraries/NUnitFramework/src/framework/SetUpAttribute.cs

@ -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
{}
}

40
src/Libraries/NUnitFramework/src/framework/SuiteAttribute.cs

@ -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
{}
}

40
src/Libraries/NUnitFramework/src/framework/TearDownAttribute.cs

@ -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
{}
}

69
src/Libraries/NUnitFramework/src/framework/TestAttribute.cs

@ -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; }
}
}
}

56
src/Libraries/NUnitFramework/src/framework/TestFixtureAttribute.cs

@ -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; }
}
}
}

41
src/Libraries/NUnitFramework/src/framework/TestFixtureSetUpAttribute.cs

@ -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
{
}
}

42
src/Libraries/NUnitFramework/src/framework/TestFixtureTearDownAttribute.cs

@ -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
{
}
}

47
src/Libraries/NUnitFramework/src/framework/nunit.framework.build

@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@
<?xml version="1.0"?>
<project name="NUnit.Framework" default="build">
<!--
Required properties:
* bin.dir - bin directory
* src.dir - source location(build) or target(copy)
* build.debug - (true|false) debug build?
* build.defines.csc - build defines for build config
-->
<target name="build" depends="copy">
<csc target="library" output="${bin.dir}/nunit.framework.dll"
debug="${build.debug}" define="${build.defines.csc},StronglyNamedAssembly">
<sources basedir="${src.dir}/framework">
<include name="*.cs"/>
</sources>
</csc>
</target>
<target name="copy">
<copy todir="${src.dir}/framework">
<fileset basedir=".">
<include name="nunit.framework.dll.csproj"/>
<include name="nunit.framework.build"/>
<include name="AssemblyInfo.cs"/>
<include name="Assert.cs"/>
<include name="Assertion.cs"/>
<include name="AssertionException.cs"/>
<include name="AssertionFailureMessage.cs"/>
<include name="CategoryAttribute.cs"/>
<include name="ExpectedExceptionAttribute.cs"/>
<include name="ExplicitAttribute.cs"/>
<include name="IgnoreAttribute.cs"/>
<include name="IgnoreException.cs"/>
<include name="OldTestCase.cs"/>
<include name="SetUpAttribute.cs"/>
<include name="SuiteAttribute.cs"/>
<include name="TearDownAttribute.cs"/>
<include name="TestAttribute.cs"/>
<include name="TestFixtureAttribute.cs"/>
<include name="TestFixtureSetUpAttribute.cs"/>
<include name="TestFixtureTearDownAttribute.cs"/>
</fileset>
</copy>
</target>
</project>

200
src/Libraries/NUnitFramework/src/framework/nunit.framework.dll.csproj

@ -1,200 +0,0 @@ @@ -1,200 +0,0 @@
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{83DD7E12-A705-4DBA-9D71-09C8973D9382}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "nunit.framework"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "NUnit.Framework"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = "bin\Debug\nunit.framework.xml"
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE;StronglyNamedAssembly"
DocumentationFile = "bin\Release\nunit.framework.xml"
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Debug-Strong"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE;StronglyNamedAssembly"
DocumentationFile = "bin\Debug\nunit.framework.xml"
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Assert.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Assertion.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "AssertionException.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "AssertionFailureMessage.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "CategoryAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ExpectedExceptionAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "ExplicitAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "IgnoreAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "IgnoreException.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "OldTestCase.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "SetUpAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "SuiteAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TearDownAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestFixtureAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestFixtureSetUpAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "TestFixtureTearDownAttribute.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>

87
src/Libraries/NUnitFramework/src/util/AssemblyInfo.cs

@ -1,87 +0,0 @@ @@ -1,87 +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;
using System.Runtime.CompilerServices;
//
// General Information about an assembly 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("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[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.0.0")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

107
src/Libraries/NUnitFramework/src/util/AssemblyList.cs

@ -1,107 +0,0 @@ @@ -1,107 +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;
using System.IO;
using System.Collections;
namespace NUnit.Util
{
/// <summary>
/// Represents a list of assemblies. It stores paths
/// that are added and marks it's ProjectContainer
/// as dirty whenever it changes. All paths must
/// be added as absolute paths.
/// </summary>
public class AssemblyList : CollectionBase
{
private ProjectConfig config;
public AssemblyList( ProjectConfig config )
{
this.config = config;
}
#region Properties
public ProjectConfig Config
{
get { return config; }
}
/// <summary>
/// Our indexer
/// </summary>
public AssemblyListItem this[int index]
{
get { return (AssemblyListItem)List[index]; }
// set { List[index] = value; }
}
#endregion
#region Methods
public void Add( string assemblyPath, bool hasTests )
{
List.Add( new AssemblyListItem( this.config, assemblyPath, hasTests ) );
}
public void Add( string assemblyPath )
{
Add( assemblyPath, true );
}
public void Remove( string assemblyPath )
{
for( int index = 0; index < this.Count; index++ )
{
if ( this[index].FullPath == assemblyPath )
RemoveAt( index );
}
}
protected override void OnRemoveComplete(int index, object value)
{
config.IsDirty = true;
}
protected override void OnInsertComplete(int index, object value)
{
config.IsDirty = true;
}
protected override void OnSetComplete(int index, object oldValue, object newValue )
{
config.IsDirty = true;
}
#endregion
}
}

75
src/Libraries/NUnitFramework/src/util/AssemblyListItem.cs

@ -1,75 +0,0 @@ @@ -1,75 +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;
using System.IO;
namespace NUnit.Util
{
/// <summary>
/// Holds an absolute assembly path and a flag that
/// indicates if the assembly is a test assembly.
/// </summary>
public class AssemblyListItem
{
private string path;
private bool hasTests;
private ProjectConfig config;
public AssemblyListItem( ProjectConfig config, string path, bool hasTests )
{
if ( !Path.IsPathRooted( path ) )
throw new ArgumentException( "Assembly path must be absolute" );
this.config = config;
this.path = path;
this.hasTests = hasTests;
}
public string FullPath
{
get { return path; }
set
{
path = value;
config.IsDirty = true;
}
}
public bool HasTests
{
get { return hasTests; }
set
{
hasTests = value;
config.IsDirty = true;
}
}
}
}

138
src/Libraries/NUnitFramework/src/util/AssemblyWatcher.cs

@ -1,138 +0,0 @@ @@ -1,138 +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;
using System.IO;
using System.Text;
using System.Timers;
using System.Collections;
using NUnit.Core;
namespace NUnit.Util
{
/// <summary>
/// AssemblyWatcher keeps track of one or more assemblies to
/// see if they have changed. It incorporates a delayed notification
/// and uses a standard event to notify any interested parties
/// about the change. The path to the assembly is provided as
/// an argument to the event handler so that one routine can
/// be used to handle events from multiple watchers.
/// </summary>
public class AssemblyWatcher
{
FileSystemWatcher[] fileWatcher;
FileInfo[] fileInfo;
protected System.Timers.Timer timer;
protected string changedAssemblyPath;
public delegate void AssemblyChangedHandler(String fullPath);
public event AssemblyChangedHandler AssemblyChangedEvent;
public AssemblyWatcher( int delay, string assemblyFileName )
: this( delay, new string[]{ assemblyFileName } ) { }
public AssemblyWatcher( int delay, IList assemblies )
{
fileInfo = new FileInfo[assemblies.Count];
fileWatcher = new FileSystemWatcher[assemblies.Count];
for( int i = 0; i < assemblies.Count; i++ )
{
fileInfo[i] = new FileInfo( (string)assemblies[i] );
fileWatcher[i] = new FileSystemWatcher();
fileWatcher[i].Path = fileInfo[i].DirectoryName;
fileWatcher[i].Filter = fileInfo[i].Name;
fileWatcher[i].NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite;
fileWatcher[i].Changed+=new FileSystemEventHandler(OnChanged);
fileWatcher[i].EnableRaisingEvents = false;
}
timer = new System.Timers.Timer( delay );
timer.AutoReset=false;
timer.Enabled=false;
timer.Elapsed+=new ElapsedEventHandler(OnTimer);
}
public FileInfo GetFileInfo( int index )
{
return fileInfo[index];
}
public void Start()
{
EnableWatchers( true );
}
public void Stop()
{
EnableWatchers( false );
}
private void EnableWatchers( bool enable )
{
foreach( FileSystemWatcher watcher in fileWatcher )
watcher.EnableRaisingEvents = enable;
}
protected void OnTimer(Object source, ElapsedEventArgs e)
{
lock(this)
{
PublishEvent();
timer.Enabled=false;
}
}
protected void OnChanged(object source, FileSystemEventArgs e)
{
changedAssemblyPath = e.FullPath;
if ( timer != null )
{
lock(this)
{
if(!timer.Enabled)
timer.Enabled=true;
timer.Start();
}
}
else
{
PublishEvent();
}
}
protected void PublishEvent()
{
if ( AssemblyChangedEvent != null )
AssemblyChangedEvent( changedAssemblyPath );
}
}
}

285
src/Libraries/NUnitFramework/src/util/CommandLineOptions.cs

@ -1,285 +0,0 @@ @@ -1,285 +0,0 @@
// File: CommandLineOptions.cs
//
// This is a re-usable component to be used when you
// need to parse command-line options/parameters.
//
// Separates command line parameters from command line options.
// Uses reflection to populate member variables the derived class with the values
// of the options.
//
// An option can start with "/", "-" or "--".
//
// I define 3 types of "options":
// 1. Boolean options (yes/no values), e.g: /r to recurse
// 2. Value options, e.g: /loglevel=3
// 2. Parameters: standalone strings like file names
//
// An example to explain:
// csc /nologo /t:exe myfile.cs
// | | |
// | | + parameter
// | |
// | + value option
// |
// + boolean option
//
// Please see a short description of the CommandLineOptions class
// at http://codeblast.com/~gert/dotnet/sells.html
//
// Gert Lombard (gert@codeblast.com)
// James Newkirk (jim@nunit.org)
namespace Codeblast
{
using System;
using System.Reflection;
using System.Collections;
using System.Text;
//
// The Attributes
//
[AttributeUsage(AttributeTargets.Field)]
public class OptionAttribute : Attribute
{
protected object optValue;
protected string optName;
protected string description;
public string Short
{
get { return optName; }
set { optName = value; }
}
public object Value
{
get { return optValue; }
set { optValue = value; }
}
public string Description
{
get { return description; }
set { description = value; }
}
}
//
// The CommandLineOptions members
//
public abstract class CommandLineOptions
{
protected ArrayList parameters;
private int optionCount;
public CommandLineOptions(string[] args)
{
optionCount = Init(args);
}
public bool NoArgs
{
get
{
return ParameterCount == 0 && optionCount == 0;
}
}
public int Init(string[] args)
{
int count = 0;
int n = 0;
while (n < args.Length)
{
int pos = IsOption(args[n]);
if (pos > 0)
{
// It's an option:
if (GetOption(args, ref n, pos))
count++;
else
InvalidOption(args[Math.Min(n, args.Length-1)]);
}
else
{
// It's a parameter:
if (parameters == null) parameters = new ArrayList();
parameters.Add(args[n]);
}
n++;
}
return count;
}
// An option starts with "/", "-" or "--":
protected virtual int IsOption(string opt)
{
char[] c = null;
if (opt.Length < 2)
{
return 0;
}
else if (opt.Length > 2)
{
c = opt.ToCharArray(0, 3);
if (c[0] == '-' && c[1] == '-' && IsOptionNameChar(c[2])) return 2;
}
else
{
c = opt.ToCharArray(0, 2);
}
if ((c[0] == '-' || c[0] == '/') && IsOptionNameChar(c[1])) return 1;
return 0;
}
protected virtual bool IsOptionNameChar(char c)
{
return Char.IsLetterOrDigit(c) || c == '?';
}
protected abstract void InvalidOption(string name);
protected virtual bool MatchShortName(FieldInfo field, string name)
{
object[] atts = field.GetCustomAttributes(typeof(OptionAttribute), true);
foreach (OptionAttribute att in atts)
{
if (string.Compare(att.Short, name, true) == 0) return true;
}
return false;
}
protected virtual FieldInfo GetMemberField(string name)
{
Type t = this.GetType();
FieldInfo[] fields = t.GetFields(BindingFlags.Instance|BindingFlags.Public);
foreach (FieldInfo field in fields)
{
if (string.Compare(field.Name, name, true) == 0) return field;
if (MatchShortName(field, name)) return field;
}
return null;
}
protected virtual object GetOptionValue(FieldInfo field)
{
object[] atts = field.GetCustomAttributes(typeof(OptionAttribute), true);
if (atts.Length > 0)
{
OptionAttribute att = (OptionAttribute)atts[0];
return att.Value;
}
return null;
}
protected virtual bool GetOption(string[] args, ref int index, int pos)
{
try
{
object cmdLineVal = null;
string opt = args[index].Substring(pos, args[index].Length-pos);
SplitOptionAndValue(ref opt, ref cmdLineVal);
FieldInfo field = GetMemberField(opt);
if (field != null)
{
object value = GetOptionValue(field);
if (value == null)
{
if (field.FieldType == typeof(bool))
value = true; // default for bool values is true
else if(field.FieldType == typeof(string))
{
value = cmdLineVal != null ? cmdLineVal : args[++index];
field.SetValue(this, Convert.ChangeType(value, field.FieldType));
string stringValue = (string)value;
if(stringValue == null || stringValue.Length == 0) return false;
return true;
}
else
value = cmdLineVal != null ? cmdLineVal : args[++index];
}
field.SetValue(this, Convert.ChangeType(value, field.FieldType));
return true;
}
}
catch (Exception)
{
// Ignore exceptions like type conversion errors.
}
return false;
}
protected virtual void SplitOptionAndValue(ref string opt, ref object val)
{
// Look for ":" or "=" separator in the option:
int pos = opt.IndexOfAny( new char[] { ':', '=' } );
if (pos < 1) return;
val = opt.Substring(pos+1);
opt = opt.Substring(0, pos);
}
// Parameter accessor:
public string this[int index]
{
get
{
if (parameters != null) return (string)parameters[index];
return null;
}
}
public ArrayList Parameters
{
get { return parameters; }
}
public int ParameterCount
{
get
{
return parameters == null ? 0 : parameters.Count;
}
}
public virtual void Help()
{
Console.WriteLine(GetHelpText());
}
public virtual string GetHelpText()
{
StringBuilder helpText = new StringBuilder();
Type t = this.GetType();
FieldInfo[] fields = t.GetFields(BindingFlags.Instance|BindingFlags.Public);
foreach (FieldInfo field in fields)
{
object[] atts = field.GetCustomAttributes(typeof(OptionAttribute), true);
if (atts.Length > 0)
{
OptionAttribute att = (OptionAttribute)atts[0];
if (att.Description != null)
{
string valType = "";
if (att.Value == null)
{
if (field.FieldType == typeof(float)) valType = "=FLOAT";
else if (field.FieldType == typeof(string)) valType = "=STR";
else if (field.FieldType != typeof(bool)) valType = "=X";
}
helpText.AppendFormat("/{0,-20}{1}", field.Name+valType, att.Description);
if (att.Short != null)
helpText.AppendFormat(" (Short format: /{0}{1})", att.Short, valType);
helpText.Append( Environment.NewLine );
}
}
}
return helpText.ToString();
}
}
}

227
src/Libraries/NUnitFramework/src/util/ConsoleOptions.cs

@ -1,227 +0,0 @@ @@ -1,227 +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
namespace NUnit.Util
{
using System;
using Codeblast;
public class ConsoleOptions : CommandLineOptions
{
[Option(Description = "Fixture to test")]
public string fixture;
[Option(Description = "Project configuration to load")]
public string config;
[Option(Description = "Name of XML output file")]
public string xml;
[Option(Description = "Name of transform file")]
public string transform;
[Option(Description = "Display XML to the console")]
public bool xmlConsole;
[Option(Short="out", Description = "File to receive test output")]
public string output;
[Option(Description = "File to receive test error output")]
public string err;
[Option(Description = "Label each test in stdOut")]
public bool labels = false;
[Option(Description = "List of categories to include")]
public string include;
[Option(Description = "List of categories to exclude")]
public string exclude;
// [Option(Description = "Run in a separate process")]
// public bool process;
// [Option(Description = "Run in a separate AppDomain")]
// public bool domain;
// [Option(Description = "Disable shadow copy when running in separate domain")]
[Option(Description = "Disable shadow copy")]
public bool noshadow;
[Option (Description = "Run tests on a separate thread")]
public bool thread;
[Option(Description = "Wait for input before closing console window")]
public bool wait = false;
[Option(Description = "Do not display the logo")]
public bool nologo = false;
[Option(Short="?", Description = "Display help")]
public bool help = false;
private bool isInvalid = false;
public ConsoleOptions(String[] args) : base(args)
{}
protected override void InvalidOption(string name)
{
isInvalid = true;
}
public bool Validate()
{
if(isInvalid) return false;
if(HasInclude && HasExclude) return false;
if(NoArgs) return true;
if(IsFixture) return true;
if(ParameterCount >= 1) return true;
return false;
}
public bool IsAssembly
{
get
{
return ParameterCount >= 1 && !IsFixture;
}
}
public bool IsTestProject
{
get
{
return ParameterCount == 1 && NUnitProject.CanLoadAsProject( (string)Parameters[0] );
}
}
public bool IsFixture
{
get
{
return ParameterCount >= 1 &&
((fixture != null) && (fixture.Length > 0));
}
}
public bool IsXml
{
get
{
return (xml != null) && (xml.Length != 0);
}
}
public bool isOut
{
get
{
return (output != null) && (output.Length != 0);
}
}
public bool isErr
{
get
{
return (err != null) && (err.Length != 0);
}
}
public bool IsTransform
{
get
{
return (transform != null) && (transform.Length != 0);
}
}
public bool HasInclude
{
get
{
return include != null && include.Length != 0;
}
}
public bool HasExclude
{
get
{
return exclude != null && exclude.Length != 0;
}
}
public string[] IncludedCategories
{
get
{
if (HasInclude)
return include.Split( new char[] {';', ','});
return null;
}
}
public string[] ExcludedCategories
{
get
{
if (HasExclude)
return exclude.Split( new char[] {';', ','});
return null;
}
}
public override void Help()
{
Console.WriteLine();
Console.WriteLine( "NUNIT-CONSOLE [inputfiles] [options]" );
Console.WriteLine();
Console.WriteLine( "Runs a set of NUnit tests from the console." );
Console.WriteLine();
Console.WriteLine( "You may specify one or more assemblies or a single" );
Console.WriteLine( "project file of type .nunit." );
Console.WriteLine();
Console.WriteLine( "Options:" );
base.Help();
Console.WriteLine();
Console.WriteLine( "Options that take values may use an equal sign, a colon" );
Console.WriteLine( "or a space to separate the option from its value." );
Console.WriteLine();
}
}
}

73
src/Libraries/NUnitFramework/src/util/ConsoleWriter.cs

@ -1,73 +0,0 @@ @@ -1,73 +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.Util
{
using System;
using System.IO;
using System.Text;
/// <summary>
/// Class used for receiving console output from the running test and displaying it.
/// </summary>
public class ConsoleWriter : TextWriter
{
private TextWriter console;
public ConsoleWriter(TextWriter console)
{
this.console = console;
}
public override void Write(char c)
{
console.Write(c);
}
public override void Write(String s)
{
console.Write(s);
}
public override void WriteLine(string s)
{
console.WriteLine(s);
}
public override Encoding Encoding
{
get { return Encoding.Default; }
}
public override Object InitializeLifetimeService()
{
return null;
}
}
}

194
src/Libraries/NUnitFramework/src/util/FormSettings.cs

@ -1,194 +0,0 @@ @@ -1,194 +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
namespace NUnit.Util
{
using System;
using System.Drawing;
/// <summary>
/// FormSettings holds settings for NUnitForm
/// </summary>
public class FormSettings : SettingsGroup
{
private static readonly string NAME = "Form";
private static readonly string MAXIMIZED = "maximized";
private static readonly string WIDTH = "width";
private static readonly string HEIGHT = "height";
private static readonly string XLOCATION = "x-location";
private static readonly string YLOCATION = "y-location";
private static readonly string TREE_SPLITTER_POSITION = "tree-splitter-position";
private static readonly string TAB_SPLITTER_POSITION = "tab-splitter-position";
public static readonly int DEFAULT_WIDTH = 756;
public static readonly int MIN_WIDTH = 160;
public static readonly int DEFAULT_HEIGHT = 512;
public static readonly int MIN_HEIGHT = 32;
public static readonly int DEFAULT_XLOCATION = 10;
public static readonly int DEFAULT_YLOCATION = 10;
public static readonly int TREE_DEFAULT_POSITION = 300;
public static readonly int TREE_MIN_POSITION = 240;
public static readonly int TAB_DEFAULT_POSITION = 119;
public static readonly int TAB_MIN_POSITION = 100;
public FormSettings( ) : base( NAME, UserSettings.GetStorageImpl( NAME ) ) { }
public FormSettings( SettingsStorage storage ) : base( NAME, storage ) { }
public FormSettings( SettingsGroup parent ) : base( NAME, parent ) { }
private Point location = Point.Empty;
private Size size = Size.Empty;
private int treeSplitterPosition = -1;
private int tabSplitterPosition = -1;
public bool IsMaximized
{
get
{
return LoadIntSetting( MAXIMIZED, 0 ) == 1 ? true : false;
}
set
{
SaveIntSetting( MAXIMIZED, value ? 1 : 0 );
}
}
public Point Location
{
get
{
if ( location == Point.Empty )
{
int x = LoadIntSetting( XLOCATION, DEFAULT_XLOCATION );
int y = LoadIntSetting( YLOCATION, DEFAULT_YLOCATION );
location = new Point(x, y);
if ( !IsValidLocation( location ) )
location = new Point( DEFAULT_XLOCATION, DEFAULT_YLOCATION );
}
return location;
}
set
{
location = value;
SaveSetting( XLOCATION, location.X );
SaveSetting( YLOCATION, location.Y );
}
}
private bool IsValidLocation( Point location )
{
Rectangle myArea = new Rectangle( location, this.Size );
bool intersect = false;
foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
{
intersect |= myArea.IntersectsWith(screen.WorkingArea);
}
return intersect;
}
public Size Size
{
get
{
if ( size == Size.Empty )
{
int width = LoadIntSetting( WIDTH, DEFAULT_WIDTH );
if ( width < MIN_WIDTH ) width = MIN_WIDTH;
int height = LoadIntSetting( HEIGHT, DEFAULT_HEIGHT );
if ( height < MIN_HEIGHT ) height = MIN_HEIGHT;
size = new Size(width, height);
}
return size;
}
set
{
size = value;
SaveIntSetting( WIDTH, size.Width );
SaveIntSetting( HEIGHT, size.Height );
}
}
public int TreeSplitterPosition
{
get
{
if ( treeSplitterPosition == -1 )
{
treeSplitterPosition =
LoadIntSetting( TREE_SPLITTER_POSITION, TREE_DEFAULT_POSITION );
if ( treeSplitterPosition < TREE_MIN_POSITION || treeSplitterPosition > this.Size.Width )
treeSplitterPosition = TREE_MIN_POSITION;
}
return treeSplitterPosition;
}
set
{
treeSplitterPosition = value;
SaveSetting( TREE_SPLITTER_POSITION, treeSplitterPosition );
}
}
public int TabSplitterPosition
{
get
{
if ( tabSplitterPosition == -1 )
{
tabSplitterPosition =
LoadIntSetting( TAB_SPLITTER_POSITION, TAB_DEFAULT_POSITION );
if ( tabSplitterPosition < TAB_MIN_POSITION || tabSplitterPosition > this.Size.Height )
tabSplitterPosition = TAB_MIN_POSITION;
}
return tabSplitterPosition;
}
set
{
tabSplitterPosition = value;
SaveSetting( TAB_SPLITTER_POSITION, tabSplitterPosition );
}
}
}
}

94
src/Libraries/NUnitFramework/src/util/GuiOptions.cs

@ -1,94 +0,0 @@ @@ -1,94 +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
namespace NUnit.Util
{
using System;
using System.Text;
using Codeblast;
public class GuiOptions : CommandLineOptions
{
private bool isInvalid = false;
[Option(Short="?", Description = "Display help")]
public bool help = false;
[Option(Description = "Project configuration to load")]
public string config;
[Option(Description = "Suppress loading of last project")]
public bool noload;
[Option(Description = "Automatically run the loaded project")]
public bool run;
[Option(Description = "Fixture to test")]
public string fixture;
public GuiOptions(String[] args) : base(args)
{}
protected override void InvalidOption(string name)
{ isInvalid = true; }
public string Assembly
{
get
{
return (string)Parameters[0];
}
}
public bool IsAssembly
{
get
{
return ParameterCount == 1;
}
}
public bool Validate()
{
return (NoArgs || ParameterCount <= 1) && !isInvalid;
}
public override string GetHelpText()
{
const string initialText =
"NUNIT-GUI [inputfile] [options]\r\rRuns a set of NUnit tests from the console. You may specify\ran assembly or a project file of type .nunit as input.\r\rOptions:\r";
const string finalText =
"\rOptions that take values may use an equal sign, a colon\ror a space to separate the option from its value.";
return initialText + base.GetHelpText() + finalText;
}
}
}

54
src/Libraries/NUnitFramework/src/util/ITestEvents.cs

@ -1,54 +0,0 @@ @@ -1,54 +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;
using NUnit.Core;
//TODO: rename this file
namespace NUnit.Util
{
/// <summary>
/// IProjectEvents interface extends NUnit.Core.ITestEvents adding
/// events that are fired as projects are loaded and unloaded.
/// </summary>
public interface IProjectEvents : ITestEvents
{
// Events related to the loading and unloading
// of projects - including wrapper projects
// created in order to load assemblies. This
// occurs separately from the loading of tests
// for the assemblies in the project.
event TestProjectEventHandler ProjectLoading;
event TestProjectEventHandler ProjectLoaded;
event TestProjectEventHandler ProjectLoadFailed;
event TestProjectEventHandler ProjectUnloading;
event TestProjectEventHandler ProjectUnloaded;
event TestProjectEventHandler ProjectUnloadFailed;
}
}

113
src/Libraries/NUnitFramework/src/util/ITestLoader.cs

@ -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-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;
using System.Collections;
using NUnit.Core;
namespace NUnit.Util
{
/// <summary>
/// The ITestLoader interface supports the loading and running
/// of tests in a remote domain. In addition to methods for
/// performing these operations, it inherits from the ITestEvents
/// interface to provide appropriate events. The two interfaces
/// are kept separate so that client objects not intended to
/// issue commands can just handle the first interface.
/// </summary>
public interface ITestLoader
{
#region Properties
// See if a project is loaded
bool IsProjectLoaded { get; }
// See if a test has been loaded from the project
bool IsTestLoaded { get; }
// See if a test is running
bool IsTestRunning { get; }
// The loaded test project
NUnitProject TestProject { get; set; }
string TestFileName { get; }
// Our last test results
TestResult[] Results { get; }
#endregion
#region Methods
// Create a new empty project using a default name
void NewProject();
// Create a new project given a filename
void NewProject( string filename );
// Load a project given a filename
void LoadProject( string filename );
// Load a project given a filename and config
void LoadProject( string filename, string configname );
// Load a project given an array of assemblies
void LoadProject( string[] assemblies );
// Unload current project
void UnloadProject();
// Load tests for current project and config
void LoadTest();
// Load a specific test for current project and config
void LoadTest( string testName );
// Unload current test
void UnloadTest();
// Reload current test
void ReloadTest();
// Set a filter for running tests
void SetFilter( IFilter filter );
// Run a test suite
void RunTest( ITest test );
// Run a collection of tests
void RunTests(ITest[] tests);
// Cancel the running test
void CancelTestRun();
#endregion
}
}

57
src/Libraries/NUnitFramework/src/util/NUnitGuiSettings.cs

@ -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;
namespace NUnit.Util
{
/// <summary>
/// NUnitGuiSettings hods settings for the GUI test runner
/// </summary>
public class NUnitGuiSettings : SettingsGroup
{
private static readonly string NAME = "NUnitGui";
public NUnitGuiSettings( ) : base( NAME, UserSettings.GetStorageImpl( NAME ) ) { }
public NUnitGuiSettings( SettingsStorage storage ) : base( NAME, storage ) { }
public NUnitGuiSettings( SettingsGroup parent ) : base( NAME, parent ) { }
public FormSettings Form
{
get { return new FormSettings( this ); }
}
// public GuiOptionsSettings Options
// {
// get { return new GuiOptionsSettings( this ); }
// }
}
}

612
src/Libraries/NUnitFramework/src/util/NUnitProject.cs

@ -1,612 +0,0 @@ @@ -1,612 +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;
using System.Collections;
using System.Xml;
using System.Xml.Schema;
using System.IO;
using System.Threading;
using NUnit.Core;
namespace NUnit.Util
{
/// <summary>
/// Types of changes that may occur to a config
/// </summary>
public enum ProjectChangeType
{
ActiveConfig,
AddConfig,
RemoveConfig,
UpdateConfig,
Other
}
/// <summary>
/// Arguments for a project event
/// </summary>
public class ProjectEventArgs : EventArgs
{
public ProjectChangeType type;
public string configName;
public ProjectEventArgs( ProjectChangeType type, string configName )
{
this.type = type;
this.configName = configName;
}
}
/// <summary>
/// Delegate to be used to handle project events
/// </summary>
public delegate void ProjectEventHandler( object sender, ProjectEventArgs e );
/// <summary>
/// Class that represents an NUnit test project
/// </summary>
public class NUnitProject
{
#region Static and instance variables
/// <summary>
/// Used to generate default names for projects
/// </summary>
private static int projectSeed = 0;
/// <summary>
/// The extension used for test projects
/// </summary>
private static readonly string nunitExtension = ".nunit";
/// <summary>
/// Path to the file storing this project
/// </summary>
protected string projectPath;
/// <summary>
/// Whether the project is dirty
/// </summary>
protected bool isDirty = false;
/// <summary>
/// Collection of configs for the project
/// </summary>
protected ProjectConfigCollection configs;
/// <summary>
/// The currently active configuration
/// </summary>
private ProjectConfig activeConfig;
/// <summary>
/// Flag indicating that this project is a
/// temporary wrapper for an assembly.
/// </summary>
private bool isAssemblyWrapper = false;
#endregion
#region Constructor
public NUnitProject( string projectPath )
{
this.projectPath = Path.GetFullPath( projectPath );
configs = new ProjectConfigCollection( this );
}
#endregion
#region Static Methods
// True if it's one of our project types
public static bool IsProjectFile( string path )
{
return Path.GetExtension( path ) == nunitExtension;
}
// True if it's ours or one we can load
public static bool CanLoadAsProject( string path )
{
return IsProjectFile( path ) ||
VSProject.IsProjectFile( path ) ||
VSProject.IsSolutionFile( path );
}
public static string GenerateProjectName()
{
return string.Format( "Project{0}", ++projectSeed );
}
public static NUnitProject EmptyProject()
{
return new NUnitProject( GenerateProjectName() );
}
public static NUnitProject NewProject()
{
NUnitProject project = EmptyProject();
project.Configs.Add( "Debug" );
project.Configs.Add( "Release" );
project.IsDirty = false;
return project;
}
/// <summary>
/// Return a test project by either loading it from
/// the supplied path, creating one from a VS file
/// or wrapping an assembly.
/// </summary>
public static NUnitProject LoadProject( string path )
{
if ( NUnitProject.IsProjectFile( path ) )
{
NUnitProject project = new NUnitProject( path );
project.Load();
return project;
}
else if ( VSProject.IsProjectFile( path ) )
return NUnitProject.FromVSProject( path );
else if ( VSProject.IsSolutionFile( path ) )
return NUnitProject.FromVSSolution( path );
else
return NUnitProject.FromAssembly( path );
}
/// <summary>
/// Creates a project to wrap a list of assemblies
/// </summary>
public static NUnitProject FromAssemblies( string[] assemblies )
{
// if only one assembly is passed in then the configuration file
// should follow the name of the assembly. This will only happen
// if the LoadAssembly method is called. Currently the console ui
// does not differentiate between having one or multiple assemblies
// passed in.
if ( assemblies.Length == 1)
return NUnitProject.FromAssembly(assemblies[0]);
NUnitProject project = NUnitProject.EmptyProject();
ProjectConfig config = new ProjectConfig( "Default" );
foreach( string assembly in assemblies )
{
string fullPath = Path.GetFullPath( assembly );
if ( !File.Exists( fullPath ) )
throw new FileNotFoundException( string.Format( "Assembly not found: {0}", fullPath ) );
config.Assemblies.Add( fullPath );
}
project.Configs.Add( config );
// TODO: Deduce application base, and provide a
// better value for loadpath and project path
// analagous to how new projects are handled
string basePath = Path.GetDirectoryName( Path.GetFullPath( assemblies[0] ) );
project.projectPath = Path.Combine( basePath, project.Name + ".nunit" );
project.IsDirty = true;
return project;
}
/// <summary>
/// Creates a project to wrap an assembly
/// </summary>
public static NUnitProject FromAssembly( string assemblyPath )
{
if ( !File.Exists( assemblyPath ) )
throw new FileNotFoundException( string.Format( "Assembly not found: {0}", assemblyPath ) );
string fullPath = Path.GetFullPath( assemblyPath );
NUnitProject project = new NUnitProject( fullPath );
ProjectConfig config = new ProjectConfig( "Default" );
config.Assemblies.Add( fullPath );
project.Configs.Add( config );
project.isAssemblyWrapper = true;
project.IsDirty = false;
return project;
}
public static NUnitProject FromVSProject( string vsProjectPath )
{
NUnitProject project = new NUnitProject( Path.GetFullPath( vsProjectPath ) );
VSProject vsProject = new VSProject( vsProjectPath );
project.Add( vsProject );
project.isDirty = false;
return project;
}
public static NUnitProject FromVSSolution( string solutionPath )
{
NUnitProject project = new NUnitProject( Path.GetFullPath( solutionPath ) );
string solutionDirectory = Path.GetDirectoryName( solutionPath );
StreamReader reader = new StreamReader( solutionPath );
char[] delims = { '=', ',' };
char[] trimchars = { ' ', '"' };
string line = reader.ReadLine();
while ( line != null )
{
if ( line.StartsWith( "Project" ) )
{
string[] parts = line.Split( delims );
string vsProjectPath = Path.Combine( solutionDirectory, parts[2].Trim(trimchars) );
if ( VSProject.IsProjectFile( vsProjectPath ) )
project.Add( new VSProject( vsProjectPath ) );
}
line = reader.ReadLine();
}
project.isDirty = false;
return project;
}
/// <summary>
/// Figure out the proper name to be used when saving a file.
/// </summary>
public static string ProjectPathFromFile( string path )
{
string fileName = Path.GetFileNameWithoutExtension( path ) + nunitExtension;
return Path.Combine( Path.GetDirectoryName( path ), fileName );
}
#endregion
#region Properties and Events
public static int ProjectSeed
{
get { return projectSeed; }
set { projectSeed = value; }
}
/// <summary>
/// The path to which a project will be saved.
/// </summary>
public string ProjectPath
{
get { return projectPath; }
set
{
projectPath = Path.GetFullPath( value );
isDirty = true;
}
}
/// <summary>
/// The base path for the project is the
/// directory part of the project path.
/// </summary>
public string BasePath
{
get { return Path.GetDirectoryName( projectPath ); }
}
/// <summary>
/// The name of the project.
/// </summary>
public string Name
{
get { return Path.GetFileNameWithoutExtension( projectPath ); }
}
public ProjectConfig ActiveConfig
{
get
{
// In case the previous active config was removed
if ( activeConfig != null && !configs.Contains( activeConfig ) )
activeConfig = null;
// In case no active config is set or it was removed
if ( activeConfig == null && configs.Count > 0 )
activeConfig = configs[0];
return activeConfig;
}
}
// Safe access to name of the active config
public string ActiveConfigName
{
get
{
ProjectConfig config = ActiveConfig;
return config == null ? null : config.Name;
}
}
public bool IsLoadable
{
get
{
return ActiveConfig != null &&
ActiveConfig.Assemblies.Count > 0;
}
}
// A project made from a single assembly is treated
// as a transparent wrapper for some purposes until
// a change is made to it.
public bool IsAssemblyWrapper
{
get { return isAssemblyWrapper; }
}
public string ConfigurationFile
{
get
{
// TODO: Check this
return isAssemblyWrapper
? Path.GetFileName( projectPath ) + ".config"
: Path.GetFileNameWithoutExtension( projectPath ) + ".config";
}
}
public bool IsDirty
{
get { return isDirty; }
set { isDirty = value; }
}
public ProjectConfigCollection Configs
{
get { return configs; }
}
public event ProjectEventHandler Changed;
#endregion
#region Instance Methods
public void SetActiveConfig( int index )
{
activeConfig = configs[index];
OnProjectChange( ProjectChangeType.ActiveConfig, activeConfig.Name );
}
public void SetActiveConfig( string name )
{
foreach( ProjectConfig config in configs )
{
if ( config.Name == name )
{
activeConfig = config;
OnProjectChange( ProjectChangeType.ActiveConfig, activeConfig.Name );
break;
}
}
}
public void OnProjectChange( ProjectChangeType type, string configName )
{
isDirty = true;
if ( isAssemblyWrapper )
{
projectPath = Path.ChangeExtension( projectPath, ".nunit" );
isAssemblyWrapper = false;
}
if ( Changed != null )
Changed( this, new ProjectEventArgs( type, configName ) );
if ( type == ProjectChangeType.RemoveConfig && activeConfig.Name == configName )
{
if ( configs.Count > 0 )
SetActiveConfig( 0 );
}
}
public void Add( VSProject vsProject )
{
foreach( VSProjectConfig vsConfig in vsProject.Configs )
{
string name = vsConfig.Name;
if ( !this.Configs.Contains( name ) )
this.Configs.Add( name );
ProjectConfig config = this.Configs[name];
foreach ( string assembly in vsConfig.Assemblies )
config.Assemblies.Add( assembly );
}
}
public void Load()
{
XmlTextReader reader = new XmlTextReader( projectPath );
string activeConfigName = null;
ProjectConfig currentConfig = null;
try
{
reader.MoveToContent();
if ( reader.NodeType != XmlNodeType.Element || reader.Name != "NUnitProject" )
throw new ProjectFormatException(
"Invalid project format: <NUnitProject> expected.",
reader.LineNumber, reader.LinePosition );
while( reader.Read() )
if ( reader.NodeType == XmlNodeType.Element )
switch( reader.Name )
{
case "Settings":
if ( reader.NodeType == XmlNodeType.Element )
activeConfigName = reader.GetAttribute( "activeconfig" );
break;
case "Config":
if ( reader.NodeType == XmlNodeType.Element )
{
string configName = reader.GetAttribute( "name" );
currentConfig = new ProjectConfig( configName );
currentConfig.BasePath = reader.GetAttribute( "appbase" );
currentConfig.ConfigurationFile = reader.GetAttribute( "configfile" );
string binpath = reader.GetAttribute( "binpath" );
string type = reader.GetAttribute( "binpathtype" );
if ( type == null )
if ( binpath == null )
currentConfig.BinPathType = BinPathType.Auto;
else
currentConfig.BinPathType = BinPathType.Manual;
else
currentConfig.BinPathType = (BinPathType)Enum.Parse( typeof( BinPathType ), type, true );
Configs.Add( currentConfig );
if ( configName == activeConfigName )
activeConfig = currentConfig;
}
else if ( reader.NodeType == XmlNodeType.EndElement )
currentConfig = null;
break;
case "assembly":
if ( reader.NodeType == XmlNodeType.Element && currentConfig != null )
{
string path = reader.GetAttribute( "path" );
string test = reader.GetAttribute( "test" );
bool hasTests = test == null ? true : bool.Parse( test );
currentConfig.Assemblies.Add(
Path.Combine( currentConfig.BasePath, path ),
hasTests );
}
break;
default:
break;
}
this.IsDirty = false;
}
catch( XmlException e )
{
throw new ProjectFormatException(
string.Format( "Invalid project format: {0}", e.Message ),
e.LineNumber, e.LinePosition );
}
catch( Exception e )
{
throw new ProjectFormatException(
string.Format( "Invalid project format: {0} Line {1}, Position {2}",
e.Message, reader.LineNumber, reader.LinePosition ),
reader.LineNumber, reader.LinePosition );
}
finally
{
reader.Close();
}
}
public void Save()
{
projectPath = ProjectPathFromFile( projectPath );
XmlTextWriter writer = new XmlTextWriter( projectPath, System.Text.Encoding.UTF8 );
writer.Formatting = Formatting.Indented;
writer.WriteStartElement( "NUnitProject" );
if ( configs.Count > 0 )
{
writer.WriteStartElement( "Settings" );
writer.WriteAttributeString( "activeconfig", ActiveConfigName );
writer.WriteEndElement();
}
foreach( ProjectConfig config in Configs )
{
writer.WriteStartElement( "Config" );
writer.WriteAttributeString( "name", config.Name );
if ( config.RelativeBasePath != null )
writer.WriteAttributeString( "appbase", config.RelativeBasePath );
string configFile = config.ConfigurationFile;
if ( configFile != null && configFile != this.ConfigurationFile )
writer.WriteAttributeString( "configfile", config.ConfigurationFile );
if ( config.BinPathType == BinPathType.Manual )
writer.WriteAttributeString( "binpath", config.PrivateBinPath );
else
writer.WriteAttributeString( "binpathtype", config.BinPathType.ToString() );
foreach( AssemblyListItem assembly in config.Assemblies )
{
writer.WriteStartElement( "assembly" );
writer.WriteAttributeString( "path", config.RelativePathTo( assembly.FullPath ) );
if ( !assembly.HasTests )
writer.WriteAttributeString( "test", "false" );
writer.WriteEndElement();
}
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.Close();
this.IsDirty = false;
// Once we save a project, it's no longer
// loaded as an assembly wrapper on reload.
this.isAssemblyWrapper = false;
}
public void Save( string projectPath )
{
this.ProjectPath = projectPath;
Save();
}
#endregion
}
}

129
src/Libraries/NUnitFramework/src/util/NUnitRegistry.cs

@ -1,129 +0,0 @@ @@ -1,129 +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
namespace NUnit.Util
{
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
/// <summary>
/// NUnitRegistry provides static properties for NUnit's
/// CurrentUser and LocalMachine subkeys.
/// </summary>
public class NUnitRegistry
{
private static readonly string KEY =
@"Software\Nascent Software\Nunit\";
private static bool testMode = false;
private static string testKey =
@"Software\Nascent Software\Nunit-Test";
/// <summary>
/// Prevent construction of object
/// </summary>
private NUnitRegistry() { }
public static bool TestMode
{
get { return testMode; }
set { testMode = value; }
}
public static string TestKey
{
get { return testKey; }
set { testKey = value; }
}
/// <summary>
/// Registry subkey for the current user
/// </summary>
public static RegistryKey CurrentUser
{
get
{
// Todo: Code can go here to migrate the registry
// if we change our location.
// Try to open new key
// if ( key doesn't exist )
// create it
// open old key
// if ( it was opened )
// copy entries to new key
// return new key
return Registry.CurrentUser.CreateSubKey( testMode ? testKey : KEY );
}
}
/// <summary>
/// Registry subkey for the local machine
/// </summary>
public static RegistryKey LocalMachine
{
get { return Registry.LocalMachine.CreateSubKey( testMode ? testKey : KEY ); }
}
public static void ClearTestKeys()
{
ClearSubKey( Registry.CurrentUser, testKey );
ClearSubKey( Registry.LocalMachine, testKey );
}
/// <summary>
/// Static function that clears out the contents of a subkey
/// </summary>
/// <param name="baseKey">Base key for the subkey</param>
/// <param name="subKey">Name of the subkey</param>
public static void ClearSubKey( RegistryKey baseKey, string subKey )
{
using( RegistryKey key = baseKey.OpenSubKey( subKey, true ) )
{
if ( key != null ) ClearKey( key );
}
}
/// <summary>
/// Static function that clears out the contents of a key
/// </summary>
/// <param name="key">Key to be cleared</param>
public static void ClearKey( RegistryKey key )
{
foreach( string name in key.GetValueNames() )
key.DeleteValue( name );
foreach( string name in key.GetSubKeyNames() )
key.DeleteSubKeyTree( name );
}
}
}

108
src/Libraries/NUnitFramework/src/util/OptionSettings.cs

@ -1,108 +0,0 @@ @@ -1,108 +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;
namespace NUnit.Util
{
/// <summary>
/// Summary description for OptionSettings.
/// </summary>
public class OptionSettings : SettingsGroup
{
private static readonly string NAME = "Options";
public OptionSettings( ) : base( NAME, UserSettings.GetStorageImpl( NAME ) ) { }
public OptionSettings( SettingsStorage storage ) : base( NAME, storage ) { }
public OptionSettings( SettingsGroup parent ) : base( NAME, parent ) { }
public bool LoadLastProject
{
get { return LoadIntSetting( "LoadLastProject", 1 ) != 0; }
set { SaveIntSetting( "LoadLastProject", value ? 1 : 0 ); }
}
public int InitialTreeDisplay
{
get { return LoadIntSetting( "InitialTreeDisplay", 0 ); }
set { SaveIntSetting( "InitialTreeDisplay", value ); }
}
public bool ReloadOnRun
{
get { return LoadIntSetting( "ReloadOnRun", 1 ) != 0; }
set { SaveIntSetting( "ReloadOnRun", value ? 1 : 0 ); }
}
public bool ShowCheckBoxes
{
get { return LoadIntSetting( "ShowCheckBoxes", 0 ) != 0; }
set { SaveIntSetting( "ShowCheckBoxes", value ? 1 : 0 ); }
}
public bool ReloadOnChange
{
get
{
if ( Environment.OSVersion.Platform != System.PlatformID.Win32NT )
return false;
return LoadIntSetting( "ReloadOnChange", 1 ) != 0;
}
set
{
if ( Environment.OSVersion.Platform != System.PlatformID.Win32NT )
return;
SaveIntSetting( "ReloadOnChange", value ? 1 : 0 );
}
}
public bool ClearResults
{
get { return LoadIntSetting( "ClearResults", 1 ) != 0; }
set { SaveIntSetting( "ClearResults", value ? 1 : 0 ); }
}
public bool TestLabels
{
get { return LoadIntSetting( "TestLabels", 0 ) != 0; }
set { SaveIntSetting( "TestLabels", value ? 1 : 0 ); }
}
public bool VisualStudioSupport
{
get { return LoadIntSetting( "VisualStudioSupport", 0 ) != 0; }
set { SaveIntSetting( "VisualStudioSupport", value ? 1 : 0 ); }
}
}
}

339
src/Libraries/NUnitFramework/src/util/ProjectConfig.cs

@ -1,339 +0,0 @@ @@ -1,339 +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;
using System.Text;
using System.Collections;
using System.IO;
using NUnit.Core;
namespace NUnit.Util
{
public enum BinPathType
{
Auto,
Manual,
None
}
public class ProjectConfig
{
#region Instance Variables
/// <summary>
/// The name of this config
/// </summary>
private string name;
/// <summary>
/// IProject interface of containing project
/// </summary>
protected NUnitProject project = null;
/// <summary>
/// Mark this config as changed
/// </summary>
private bool isDirty = false;
/// <summary>
/// List of the names of the assemblies
/// </summary>
private AssemblyList assemblies;
/// <summary>
/// Base path specific to this configuration
/// </summary>
private string basePath;
/// <summary>
/// Our configuration file, if specified
/// </summary>
private string configFile;
/// <summary>
/// Private bin path, if specified
/// </summary>
private string binPath;
/// <summary>
/// True if assembly paths should be added to bin path
/// </summary>
private BinPathType binPathType = BinPathType.Auto;
#endregion
#region Construction
public ProjectConfig()
{
this.assemblies = new AssemblyList( this );
}
public ProjectConfig( string name )
{
this.name = name;
this.assemblies = new AssemblyList( this );
}
#endregion
#region Properties and Events
public NUnitProject Project
{
get { return project; }
set { project = value; }
}
public bool IsDirty
{
get { return isDirty; }
set
{
isDirty = value;
if ( isDirty )
{
if ( Changed != null )
Changed( this, EventArgs.Empty );
}
}
}
public string Name
{
get { return name; }
set
{
if ( name != value )
{
name = value;
IsDirty = true;
}
}
}
public event EventHandler Changed;
/// <summary>
/// The base directory for this config - used
/// as the application base for loading tests.
/// </summary>
public string BasePath
{
get
{
if ( project == null || project.BasePath == null )
return basePath;
if ( basePath == null )
return project.BasePath;
return Path.Combine( project.BasePath, basePath );
}
set
{
if ( BasePath != value )
{
basePath = value;
IsDirty = true;
}
}
}
/// <summary>
/// The base path relative to the project base
/// </summary>
public string RelativeBasePath
{
get
{
if ( project == null || basePath == null || !Path.IsPathRooted( basePath ) )
return basePath;
return ProjectPath.RelativePath( project.BasePath, basePath );
}
}
public string ConfigurationFile
{
get
{
return configFile == null && project != null
? project.ConfigurationFile
: configFile;
}
set
{
if ( ConfigurationFile != value )
{
configFile = value;
IsDirty = true;
}
}
}
public string ConfigurationFilePath
{
get
{
return BasePath != null && ConfigurationFile != null
? Path.Combine( BasePath, ConfigurationFile )
: ConfigurationFile;
}
}
/// <summary>
/// The semicolon-separated path containing all the
/// assemblies in the list.
/// </summary>
public string PrivateBinPath
{
get
{
switch( binPathType )
{
case BinPathType.Manual:
return binPath;
case BinPathType.Auto:
StringBuilder sb = new StringBuilder(200);
ArrayList dirList = new ArrayList();
foreach( AssemblyListItem assembly in Assemblies )
{
string dir = ProjectPath.RelativePath( BasePath, Path.GetDirectoryName( assembly.FullPath ) );
if ( dir != null && dir != "." && !dirList.Contains( dir ) )
{
dirList.Add( dir );
if ( sb.Length > 0 )
sb.Append( ';' );
sb.Append( dir );
}
}
return sb.Length == 0 ? null : sb.ToString();
default:
return null;
}
}
set
{
if ( binPath != value )
{
binPath = value;
binPathType = binPath == null ? BinPathType.Auto : BinPathType.Manual;
IsDirty = true;
}
}
}
/// <summary>
/// How our PrivateBinPath is generated
/// </summary>
public BinPathType BinPathType
{
get { return binPathType; }
set
{
if ( binPathType != value )
{
binPathType = value;
IsDirty = true;
}
}
}
/// <summary>
/// Return our AssemblyList
/// </summary>
public AssemblyList Assemblies
{
get { return assemblies; }
}
/// <summary>
/// Return a string array with the absolute paths of all assemblies
/// </summary>
public string[] AbsolutePaths
{
get
{
ArrayList paths = new ArrayList();
foreach( AssemblyListItem assembly in assemblies )
paths.Add( assembly.FullPath );
return (string[])paths.ToArray( typeof(string) );
}
}
/// <summary>
/// Return a string array with the relative paths of all
/// assemblies from the configuration BasePath.
/// </summary>
public string[] RelativePaths
{
get
{
ArrayList paths = new ArrayList();
foreach( AssemblyListItem assembly in Assemblies )
paths.Add( ProjectPath.RelativePath( BasePath, assembly.FullPath ) );
return (string[])paths.ToArray( typeof(string) );
}
}
/// <summary>
/// Return a string array with the absolute paths of all
/// assemblies that have tests
/// </summary>
public string[] TestAssemblies
{
get
{
ArrayList paths = new ArrayList();
foreach( AssemblyListItem assembly in Assemblies )
if ( assembly.HasTests )
paths.Add( assembly.FullPath );
return (string[])paths.ToArray( typeof(string) );
}
}
#endregion
#region Methods
public string RelativePathTo( string path )
{
return ProjectPath.RelativePath( BasePath, path );
}
#endregion
}
}

169
src/Libraries/NUnitFramework/src/util/ProjectConfigCollection.cs

@ -1,169 +0,0 @@ @@ -1,169 +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;
using System.Collections;
namespace NUnit.Util
{
/// <summary>
/// Summary description for ProjectConfigCollection.
/// </summary>
public class ProjectConfigCollection : CollectionBase
{
protected NUnitProject project;
public ProjectConfigCollection( NUnitProject project )
{
this.project = project;
}
#region Properties
public NUnitProject Project
{
get { return project; }
}
public ArrayList Names
{
get
{
ArrayList names = new ArrayList();
foreach( ProjectConfig config in InnerList )
names.Add( config.Name );
return names;
}
}
public ProjectConfig this[int index]
{
get { return (ProjectConfig)InnerList[index]; }
}
public ProjectConfig this[string name]
{
get
{
int index = IndexOf( name );
return index >= 0 ? (ProjectConfig)InnerList[index]: null;
}
}
#endregion
#region Methods
public void Add( ProjectConfig config )
{
List.Add( config );
config.Project = this.Project;
}
public void Add( string name )
{
Add( new ProjectConfig( name ) );
}
public void Remove( ProjectConfig config )
{
string name = config.Name;
bool wasActive = name == this.Project.ActiveConfigName;
List.Remove( config );
}
public void Remove( string name )
{
int index = IndexOf( name );
if ( index >= 0 )
{
bool wasActive = name == this.Project.ActiveConfigName;
RemoveAt( index );
}
}
public int IndexOf( ProjectConfig config )
{
return InnerList.IndexOf( config );
}
public int IndexOf( string name )
{
for( int index = 0; index < InnerList.Count; index++ )
{
ProjectConfig config = (ProjectConfig)InnerList[index];
if( config.Name == name )
return index;
}
return -1;
}
public bool Contains( ProjectConfig config )
{
return InnerList.Contains( config );
}
public bool Contains( string name )
{
return IndexOf( name ) >= 0;
}
protected override void OnRemoveComplete( int index, object obj )
{
ProjectConfig config = obj as ProjectConfig;
this.Project.OnProjectChange( ProjectChangeType.RemoveConfig, config.Name );
}
protected override void OnInsertComplete( int index, object obj )
{
ProjectConfig config = obj as ProjectConfig;
project.OnProjectChange( ProjectChangeType.AddConfig, config.Name );
config.Changed += new EventHandler( OnConfigChanged );
}
protected override void OnSetComplete( int index, object oldValue, object newValue )
{
ProjectConfig oldConfig = oldValue as ProjectConfig;
ProjectConfig newConfig = newValue as ProjectConfig;
bool active = oldConfig.Name == project.ActiveConfigName;
project.OnProjectChange( ProjectChangeType.UpdateConfig, newConfig.Name );
}
private void OnConfigChanged( object sender, EventArgs e )
{
ProjectConfig config = sender as ProjectConfig;
project.OnProjectChange( ProjectChangeType.UpdateConfig, config.Name );
}
#endregion
}
}

81
src/Libraries/NUnitFramework/src/util/ProjectFormatException.cs

@ -1,81 +0,0 @@ @@ -1,81 +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;
namespace NUnit.Util
{
/// <summary>
/// Exception raised when loading a project file with
/// an invalid format.
/// </summary>
public class ProjectFormatException : ApplicationException
{
#region Instance Variables
private int lineNumber;
private int linePosition;
#endregion
#region Constructors
public ProjectFormatException() : base() {}
public ProjectFormatException( string message )
: base( message ) {}
public ProjectFormatException( string message, Exception inner )
: base( message, inner ) {}
public ProjectFormatException( string message, int lineNumber, int linePosition )
: base( message )
{
this.lineNumber = lineNumber;
this.linePosition = linePosition;
}
#endregion
#region Properties
public int LineNumber
{
get { return lineNumber; }
}
public int LinePosition
{
get { return linePosition; }
}
#endregion
}
}

162
src/Libraries/NUnitFramework/src/util/ProjectPath.cs

@ -1,162 +0,0 @@ @@ -1,162 +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;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
namespace NUnit.Util
{
/// <summary>
/// Static methods for manipulating project paths, including both directories
/// and files. Some synonyms for System.Path methods are included as well.
/// </summary>
public class ProjectPath
{
public const uint FILE_ATTRIBUTE_DIRECTORY = 0x00000010;
public const uint FILE_ATTRIBUTE_NORMAL = 0x00000080;
public const int MAX_PATH = 256;
#region Public methods
public static bool IsAssemblyFileType( string path )
{
string extension = Path.GetExtension( path );
return extension == ".dll" || extension == ".exe";
}
/// <summary>
/// Returns the relative path from a base directory to another
/// directory or file.
/// </summary>
public static string RelativePath( string from, string to )
{
from = Canonicalize( from );
to = Canonicalize( to );
// Second argument to PathRelativeTo must be absolute
if ( !Path.IsPathRooted( to ) )
return to;
StringBuilder sb = new StringBuilder( MAX_PATH );
// Return null if call fails
if ( !PathRelativePathTo( sb, from, FILE_ATTRIBUTE_DIRECTORY, to, FILE_ATTRIBUTE_DIRECTORY ) )
return null;
// Remove initial .\ from path if present
if ( sb.Length >=2 && sb[0] == '.' && sb[1] == '\\' )
sb.Remove( 0, 2 );
if ( sb.Length == 0 )
return null;
return sb.ToString();
}
/// <summary>
/// Return the canonical form of a path.
public static string Canonicalize( string path )
{
StringBuilder sb = new StringBuilder( MAX_PATH );
if ( !PathCanonicalize( sb, path ) )
throw new ArgumentException( string.Format( "Invalid path passed to PathCanonicalize: {0}", path ) );
return sb.ToString();
}
/// <summary>
/// True if the two paths are the same. However, two paths
/// to the same file or directory using different network
/// shares or drive letters are not treated as equal.
/// </summary>
public static bool SamePath( string path1, string path2 )
{
return Canonicalize(path1).ToLower() == Canonicalize(path2).ToLower();
}
/// <summary>
/// True if the two paths are the same or if the second is
/// directly or indirectly under the first. Note that paths
/// using different network shares or drive letters are
/// considered unrelated, even if they end up referencing
/// the same subtrees in the file system.
/// </summary>
public static bool SamePathOrUnder( string path1, string path2 )
{
path1 = Canonicalize( path1 );
path2 = Canonicalize( path2 );
int length1 = path1.Length;
int length2 = path2.Length;
// if path1 is longer, then path2 can't be under it
if ( length1 > length2 )
return false;
// if lengths are the same, check for equality
if ( length1 == length2 )
return path1.ToLower() == path2.ToLower();
// path 2 is longer than path 1: see if initial parts match
if ( path1.ToLower() != path2.Substring( 0, length1 ).ToLower() )
return false;
// must match through or up to a directory separator boundary
return path2[length1-1] == Path.DirectorySeparatorChar ||
path2[length1] == Path.DirectorySeparatorChar;
}
#endregion
#region Shlwapi functions used internally
[DllImport("shlwapi.dll")]
private static extern bool PathRelativePathTo(
StringBuilder result,
string from,
uint attrFrom,
string to,
uint attrTo );
[DllImport("shlwapi.dll")]
private static extern bool PathCanonicalize(
StringBuilder result,
string path );
[DllImport("shlwapi.dll")]
private static extern int PathCommonPrefix(
string file1,
string file2,
StringBuilder result );
#endregion
}
}

173
src/Libraries/NUnitFramework/src/util/RecentFileSettings.cs

@ -1,173 +0,0 @@ @@ -1,173 +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;
using System.Collections;
namespace NUnit.Util
{
/// <summary>
/// Base class for settings that hold lists of recent files
/// </summary>
public abstract class RecentFileSettings : SettingsGroup
{
// TODO: This class does more loading and
// storing than it should but this is the
// current simplest solution to having
// multiple recentfiles objects around.
// We can fix this by using a singleton.
private IList fileEntries;
public static readonly int MinSize = 1;
public static readonly int MaxSize = 24;
public static readonly int DefaultSize = 5;
public RecentFileSettings( string name ) : base ( name, UserSettings.GetStorageImpl( name ) )
{
LoadFiles();
}
public RecentFileSettings( string name, SettingsStorage storage ) : base( name, storage )
{
LoadFiles();
}
public RecentFileSettings( string name, SettingsGroup parent ) : base( name, parent )
{
LoadFiles();
}
public int MaxFiles
{
get
{
int size = LoadIntSetting( "MaxFiles", DefaultSize );
if ( size < MinSize ) size = MinSize;
if ( size > MaxSize ) size = MaxSize;
return size;
}
set
{
int oldSize = MaxFiles;
int newSize = value;
if ( newSize < MinSize ) newSize = MinSize;
if ( newSize > MaxSize ) newSize = MaxSize;
SaveIntSetting( "MaxFiles", newSize );
if ( newSize < oldSize ) SaveSettings();
}
}
protected void LoadFiles()
{
fileEntries = new ArrayList();
for ( int index = 1; index <= MaxFiles; index++ )
{
string fileName = LoadStringSetting( ValueName( index ) );
if ( fileName != null )
fileEntries.Add( fileName );
}
}
public override void Clear()
{
base.Clear();
fileEntries = new ArrayList();
}
public IList GetFiles()
{
LoadFiles();
return fileEntries;
}
public string RecentFile
{
get
{
LoadFiles();
if( fileEntries.Count > 0 )
return (string)fileEntries[0];
return null;
}
set
{
LoadFiles();
int index = fileEntries.IndexOf(value);
if(index == 0) return;
if(index != -1)
{
fileEntries.RemoveAt(index);
}
fileEntries.Insert( 0, value );
if( fileEntries.Count > MaxFiles )
fileEntries.RemoveAt( MaxFiles );
SaveSettings();
}
}
public void Remove( string fileName )
{
LoadFiles();
fileEntries.Remove( fileName );
SaveSettings();
}
private void SaveSettings()
{
while( fileEntries.Count > MaxFiles )
fileEntries.RemoveAt( fileEntries.Count - 1 );
for( int index = 0; index < MaxSize; index++ )
{
string valueName = ValueName( index + 1 );
if ( index < fileEntries.Count )
SaveSetting( valueName, fileEntries[index] );
else
RemoveSetting( valueName );
}
}
private string ValueName( int index )
{
return string.Format( "File{0}", index );
}
}
}

60
src/Libraries/NUnitFramework/src/util/RecentProjectSettings.cs

@ -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-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;
namespace NUnit.Util
{
/// <summary>
/// Holds list of most recent projects
///
/// NOTE: An earlier version had separate settings for
/// RecentProjects and RecentAssemblies. Currently we
/// currently only have RecentProjects, displayed in
/// the user interface as "Recent Files" and containing
/// all types of projects and assemblies that have
/// been opened. We retained the separation into two
/// classes in case we should need another recent list
/// at some time in the future. The UI component
/// RecentFilesMenuHandler can deal with any class
/// derived from RecentFileSettings.
/// </summary>
public class RecentProjectSettings : RecentFileSettings
{
private static readonly string NAME = "Recent-Projects";
public RecentProjectSettings( ) : base ( NAME ) { }
public RecentProjectSettings( SettingsStorage storage )
: base( NAME, storage ) { }
public RecentProjectSettings( SettingsGroup parent )
: base( NAME, parent ) { }
}
}

263
src/Libraries/NUnitFramework/src/util/RegistrySettingsStorage.cs

@ -1,263 +0,0 @@ @@ -1,263 +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;
using System.Diagnostics;
using Microsoft.Win32;
namespace NUnit.Util
{
/// <summary>
/// Implementation of SettingsStorage for NUnit user settings,
/// based on storage of settings in the registry.
/// </summary>
public class RegistrySettingsStorage : SettingsStorage, IDisposable
{
#region Instance Variables
/// <summary>
/// If not null, the registry key for this storage
/// </summary>
private RegistryKey storageKey;
#endregion
#region Construction and Disposal
/// <summary>
/// Construct a storage as a child of another storage
/// </summary>
/// <param name="storageName">The name to give the storage</param>
/// <param name="parentStorage">The parent in which the storage is to be created</param>
public RegistrySettingsStorage( string storageName, RegistrySettingsStorage parentStorage )
: base( storageName, parentStorage )
{
this.storageKey = parentStorage.StorageKey.CreateSubKey( storageName );
}
/// <summary>
/// Construct a storage using a registry key. This constructor is
/// intended for use at the top level of the hierarchy.
/// </summary>
/// <param name="storageName">The name to give the storage</param>
/// <param name="parentKey">The registry Key under which the storage will be created</param>
public RegistrySettingsStorage( string storageName, RegistryKey parentKey )
: base ( storageName, null )
{
this.storageKey = parentKey.CreateSubKey( storageName );
}
/// <summary>
/// Construct a storage on top of a given key, using the key's name
/// </summary>
/// <param name="storageKey"></param>
public RegistrySettingsStorage( RegistryKey storageKey )
: base( storageKey.Name, null )
{
this.storageKey = storageKey;
}
/// <summary>
/// Dispose of this object by closing the storage key, if any
/// </summary>
public override void Dispose()
{
if ( storageKey != null )
storageKey.Close();
}
#endregion
#region Properties
/// <summary>
/// The registry key used to hold this storage
/// </summary>
public RegistryKey StorageKey
{
get { return storageKey; }
}
/// <summary>
/// The count of settings in this storage
/// </summary>
public override int SettingsCount
{
get { return storageKey.ValueCount; }
}
#endregion
#region Methods
/// <summary>
/// Find out if a child storage exists
/// </summary>
/// <param name="storageName">Name of the child storage</param>
/// <returns>True if the child storage exists</returns>
public override bool ChildStorageExists( string storageName )
{
using (RegistryKey key = storageKey.OpenSubKey( storageName ) )
{
return key != null;
}
}
/// <summary>
/// Make a new child storage under this one
/// </summary>
/// <param name="storageName">Name of the child storage to make</param>
/// <returns>New storage</returns>
public override SettingsStorage MakeChildStorage( string storageName )
{
return new RegistrySettingsStorage( storageName, this );
}
/// <summary>
/// Load a setting from this storage
/// </summary>
/// <param name="settingName">Name of the setting to load</param>
/// <returns>Value of the setting</returns>
public override object LoadSetting( string settingName )
{
return storageKey.GetValue( settingName );
}
/// <summary>
/// Load an int setting from this storage. Since int is a
/// value type, we can't return null so zero is used to
/// indicate that nothing was found - or the found value
/// was zero. If you need to distinguish, use your own
/// default value or call LoadSetting and check for null.
/// </summary>
/// <param name="settingName">Name of the setting to load</param>
/// <returns>Value of the setting or zero if missing</returns>
public override int LoadIntSetting( string settingName )
{
return LoadIntSetting( settingName, 0 );
}
/// <summary>
/// Load a string setting from this storage
/// </summary>
/// <param name="settingName">Name of the setting to load</param>
/// <returns>Value of the setting</returns>
public override string LoadStringSetting( string settingName )
{
object resultValue = storageKey.GetValue( settingName );
if ( resultValue == null || resultValue is string )
return (string) resultValue;
return resultValue.ToString();
}
/// <summary>
/// Load a setting from this storage or return a default value
/// </summary>
/// <param name="settingName">Name of setting to load</param>
/// <param name="defaultValue">Value to return if the seeting is not present</param>
/// <returns>Value of the setting or the default</returns>
public override object LoadSetting( string settingName, object defaultValue )
{
return storageKey.GetValue( settingName, defaultValue );
}
/// <summary>
/// Load an integer setting from this storage or return a default value
/// </summary>
/// <param name="settingName">Name of setting to load</param>
/// <param name="defaultValue">Value to return if the seeting is not present</param>
/// <returns>Value of the setting or the default</returns>
public override int LoadIntSetting( string settingName, int defaultValue )
{
object resultValue = storageKey.GetValue( settingName, defaultValue );
if ( resultValue is int )
return (int)resultValue;
return int.Parse( (string)resultValue );
}
/// <summary>
/// Load a string setting from this storage or return a default value
/// </summary>
/// <param name="settingName">Name of setting to load</param>
/// <param name="defaultValue">Value to return if the seeting is not present</param>
/// <returns>Value of the setting or the default</returns>
public override string LoadStringSetting( string settingName, string defaultValue )
{
object resultValue = storageKey.GetValue( settingName, defaultValue );
if ( resultValue is string )
return (string) resultValue;
return resultValue.ToString();
}
/// <summary>
/// Remove a setting from the storage
/// </summary>
/// <param name="settingName">Name of the setting to remove</param>
public override void RemoveSetting( string settingName )
{
storageKey.DeleteValue( settingName, false );
}
/// <summary>
/// Save a setting in this storage
/// </summary>
/// <param name="settingName">Name of the setting to save</param>
/// <param name="settingValue">Value to be saved</param>
public override void SaveSetting( string settingName, object settingValue )
{
storageKey.SetValue( settingName, settingValue );
}
/// <summary>
/// Static function that clears out the contents of a key
/// </summary>
/// <param name="key">Key to be cleared</param>
public static void ClearKey( RegistryKey key )
{
foreach( string name in key.GetValueNames() )
key.DeleteValue( name );
foreach( string name in key.GetSubKeyNames() )
key.DeleteSubKeyTree( name );
}
/// <summary>
/// Clear all settings from the storage - empty storage remains
/// </summary>
public override void Clear()
{
ClearKey( storageKey );
}
#endregion
}
}

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

Loading…
Cancel
Save