Browse Source

Switch from MbUnit to NUnit:

Fixes SD2-621 (ExpectedException test failure not added to error list), SD2-408 (Add "Run Test" to member bookmark), SD2-618 (Run test fixture in console with debugger shows no output).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1069 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
94d5e5bc08
  1. 13
      bin/setup/PostInstallTasks.bat
  2. 8
      bin/setup/PreUninstallTasks.bat
  3. BIN
      data/resources/StringResources.cz.resources
  4. BIN
      data/resources/StringResources.de.resources
  5. BIN
      data/resources/StringResources.fr.resources
  6. BIN
      data/resources/StringResources.hu.resources
  7. 4
      src/AddIns/BackendBindings/Boo/BooBinding.sln
  8. 10
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ConvertVisitor.cs
  9. 8
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Templates/FormsProject.xpt
  10. 9
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Test/NRefactoryToBooConverter.Tests.csproj
  11. 9
      src/AddIns/BackendBindings/CSharpBinding/Test/CSharpBinding.Tests.csproj
  12. 8
      src/AddIns/BackendBindings/VBNetBinding/Test/VBNetBinding.Tests.csproj
  13. 9
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj
  14. 1
      src/AddIns/Misc/AddinScout/Project/Src/Gui/CodonListPanel.cs
  15. 78
      src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin
  16. 15
      src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.csproj
  17. 4
      src/AddIns/Misc/CodeCoverage/Project/Configuration/AssemblyInfo.cs
  18. 6
      src/AddIns/Misc/CodeCoverage/Project/PostBuildEvent.proj
  19. 297
      src/AddIns/Misc/CodeCoverage/Project/Src/AbstractRunTestsWithCodeCoverageCommand.cs
  20. 113
      src/AddIns/Misc/CodeCoverage/Project/Src/MbUnitResults.cs
  21. 113
      src/AddIns/Misc/CodeCoverage/Project/Src/NUnitResults.cs
  22. 37
      src/AddIns/Misc/CodeCoverage/Project/Src/RunMbUnitPadTestsWithCodeCoverageCommand.cs
  23. 47
      src/AddIns/Misc/CodeCoverage/Project/Src/RunTestFixtureWithCodeCoverageCommand.cs
  24. 213
      src/AddIns/Misc/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs
  25. 4
      src/AddIns/Misc/CodeCoverage/Test/AssemblyInfo.cs
  26. 9
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj
  27. 12
      src/AddIns/Misc/FiletypeRegisterer/Project/Src/FiletypeAssociationDoozer.cs
  28. 16
      src/AddIns/Misc/MbUnitPad/MbUnitPad.sln
  29. 176
      src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.addin
  30. 69
      src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.csproj
  31. 5
      src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.csproj.user
  32. 198
      src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitCommands.cs
  33. 27
      src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitRunningTestsCondition.cs
  34. 336
      src/AddIns/Misc/MbUnitPad/Project/Src/TestTreeView.cs
  35. 9
      src/AddIns/Misc/NAntAddIn/Test/NAntAddIn.Tests.csproj
  36. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlFormReader.cs
  37. 14
      src/AddIns/Misc/UnitTesting/Configuration/AssemblyInfo.cs
  38. 102
      src/AddIns/Misc/UnitTesting/Src/NUnitResults.cs
  39. 149
      src/AddIns/Misc/UnitTesting/Src/PadContent.cs
  40. 100
      src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs
  41. 45
      src/AddIns/Misc/UnitTesting/Src/RunningTestsCondition.cs
  42. 448
      src/AddIns/Misc/UnitTesting/Src/TestTreeView.cs
  43. 22
      src/AddIns/Misc/UnitTesting/Src/TestableCondition.cs
  44. 151
      src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs
  45. 96
      src/AddIns/Misc/UnitTesting/Src/UnitTestCommands.cs
  46. 187
      src/AddIns/Misc/UnitTesting/UnitTesting.addin
  47. 93
      src/AddIns/Misc/UnitTesting/UnitTesting.csproj
  48. 9
      src/Libraries/ICSharpCode.Build.Tasks/Test/ICSharpCode.Build.Tasks.Tests.csproj
  49. 1
      src/Libraries/ICSharpCode.TextEditor/Project/Configuration/AssemblyInfo.cs
  50. 11
      src/Libraries/ICSharpCode.TextEditor/Test/ICSharpCode.TextEditor.Tests.csproj
  51. 1
      src/Libraries/NRefactory/Project/Configuration/AssemblyInfo.cs
  52. 9
      src/Libraries/NRefactory/Test/NRefactoryTests.csproj
  53. 80
      src/Libraries/NUnit.Framework/AbstractAsserter.cs
  54. 5
      src/Libraries/NUnit.Framework/AssemblyInfo.cs
  55. 1697
      src/Libraries/NUnit.Framework/Assert.cs
  56. 190
      src/Libraries/NUnit.Framework/Assertion.cs
  57. 68
      src/Libraries/NUnit.Framework/AssertionException.cs
  58. 481
      src/Libraries/NUnit.Framework/AssertionFailureMessage.cs
  59. 60
      src/Libraries/NUnit.Framework/CategoryAttribute.cs
  60. 57
      src/Libraries/NUnit.Framework/CommonAssemblyInfo.cs
  61. 35
      src/Libraries/NUnit.Framework/ComparisonAsserter.cs
  62. 186
      src/Libraries/NUnit.Framework/ConditionAsserters.cs
  63. 99
      src/Libraries/NUnit.Framework/EqualAsserter.cs
  64. 152
      src/Libraries/NUnit.Framework/EqualityAsserter.cs
  65. 113
      src/Libraries/NUnit.Framework/ExpectedExceptionAttribute.cs
  66. 21
      src/Libraries/NUnit.Framework/ExplicitAttribute.cs
  67. 30
      src/Libraries/NUnit.Framework/IAsserter.cs
  68. 67
      src/Libraries/NUnit.Framework/IgnoreAttribute.cs
  69. 68
      src/Libraries/NUnit.Framework/IgnoreException.cs
  70. 52
      src/Libraries/NUnit.Framework/ListContentsAsserter.cs
  71. 35
      src/Libraries/NUnit.Framework/NotEqualAsserter.cs
  72. 40
      src/Libraries/NUnit.Framework/NotSameAsserter.cs
  73. 58
      src/Libraries/NUnit.Framework/OldTestCase.cs
  74. 51
      src/Libraries/NUnit.Framework/PlatformAttribute.cs
  75. 40
      src/Libraries/NUnit.Framework/SameAsserter.cs
  76. 40
      src/Libraries/NUnit.Framework/SetUpAttribute.cs
  77. 12
      src/Libraries/NUnit.Framework/SetUpFixtureAttribute.cs
  78. 155
      src/Libraries/NUnit.Framework/StringAssert.cs
  79. 204
      src/Libraries/NUnit.Framework/StringAsserters.cs
  80. 40
      src/Libraries/NUnit.Framework/SuiteAttribute.cs
  81. 40
      src/Libraries/NUnit.Framework/TearDownAttribute.cs
  82. 69
      src/Libraries/NUnit.Framework/TestAttribute.cs
  83. 56
      src/Libraries/NUnit.Framework/TestFixtureAttribute.cs
  84. 41
      src/Libraries/NUnit.Framework/TestFixtureSetUpAttribute.cs
  85. 42
      src/Libraries/NUnit.Framework/TestFixtureTearDownAttribute.cs
  86. 208
      src/Libraries/NUnit.Framework/TypeAsserters.cs
  87. 42
      src/Libraries/NUnit.Framework/greaterasserter.cs
  88. 41
      src/Libraries/NUnit.Framework/lessasserter.cs
  89. 31
      src/Libraries/NUnit.Framework/nunit.framework.build
  90. 145
      src/Libraries/NUnit.Framework/nunit.framework.dll.csproj
  91. BIN
      src/Libraries/NUnit.Framework/nunit.key
  92. 1
      src/Main/Base/Project/Configuration/AssemblyInfo.cs
  93. 20
      src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs
  94. 9
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs
  95. 6
      src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs
  96. 4
      src/Main/Base/Project/Src/Internal/Doozers/PadDescriptor.cs
  97. 3
      src/Main/Base/Project/Src/Project/Converter/PrjxToSolutionProject.cs
  98. 14
      src/Main/Base/Project/Src/Project/Solution/Solution.cs
  99. 29
      src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingService.cs
  100. 7
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs
  101. Some files were not shown because too many files have changed in this diff Show More

13
bin/setup/PostInstallTasks.bat

@ -5,16 +5,9 @@ pushd .. @@ -5,16 +5,9 @@ pushd ..
echo Installing assemblies into the GAC
echo.
echo NUnit.Framework.dll
tools\gacutil2.exe /i nunit.framework.dll
echo.
echo MbUnit requirements
tools\gacutil2.exe /i tools\MbUnit\Refly.dll
tools\gacutil2.exe /i tools\MbUnit\TestFu.dll
tools\gacutil2.exe /i tools\MbUnit\QuickGraph.dll
tools\gacutil2.exe /i tools\MbUnit\QuickGraph.Algorithms.dll
echo.
echo MbUnit.Framework.dll
tools\gacutil2.exe /i tools\MbUnit\MbUnit.Framework.dll
tools\gacutil2.exe /i tools\NUnit\nunit.framework.dll
echo NUnit.Core.dll
tools\gacutil2.exe /i tools\NUnit\nunit.core.dll
echo.
echo.
echo.

8
bin/setup/PreUninstallTasks.bat

@ -3,12 +3,8 @@ @@ -3,12 +3,8 @@
pushd ..
echo Removing assemblies from the GAC...
tools\gacutil2.exe /u nunit.framework.dll
tools\gacutil2.exe /u tools\MbUnit\Refly.dll
tools\gacutil2.exe /u tools\MbUnit\TestFu.dll
tools\gacutil2.exe /u tools\MbUnit\QuickGraph.dll
tools\gacutil2.exe /u tools\MbUnit\QuickGraph.Algorithms.dll
tools\gacutil2.exe /u tools\MbUnit\MbUnit.Framework.dll
tools\gacutil2.exe /u tools\NUnit\nunit.framework.dll
tools\gacutil2.exe /u tools\NUnit\nunit.core.dll
echo.
echo.
echo Uninstalling native images...

BIN
data/resources/StringResources.cz.resources

Binary file not shown.

BIN
data/resources/StringResources.de.resources

Binary file not shown.

BIN
data/resources/StringResources.fr.resources

Binary file not shown.

BIN
data/resources/StringResources.hu.resources

Binary file not shown.

4
src/AddIns/BackendBindings/Boo/BooBinding.sln

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.940
# SharpDevelop 2.0.0.1057
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryToBooConverter", "NRefactoryToBooConverter\Project\NRefactoryToBooConverter.csproj", "{DBCF20A1-BA13-4582-BFA9-74DE4D987B73}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryToBooConverter.Tests", "NRefactoryToBooConverter\Test\NRefactoryToBooConverter.Tests.csproj", "{C9DE556D-325C-4544-B29F-16A9EB7C9830}"
@ -22,8 +22,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", @@ -22,8 +22,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj", "{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.framework.dll", "..\..\..\Libraries\NUnit.Framework\nunit.framework.dll.csproj", "{83DD7E12-A705-4DBA-9D71-09C8973D9382}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsDesigner", "..\..\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj", "{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}"
EndProject
Global

10
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ConvertVisitor.cs

@ -160,9 +160,15 @@ namespace Grunwald.BooBinding.CodeCompletion @@ -160,9 +160,15 @@ namespace Grunwald.BooBinding.CodeCompletion
m.TypeParameters = DefaultTypeParameter.EmptyTypeParameterList;
}
void ConvertAttributes(AST.Node node, AbstractDecoration c)
void ConvertAttributes(AST.TypeMember node, AbstractDecoration c)
{
c.Attributes = DefaultAttribute.EmptyAttributeList;
if (node.Attributes.Count == 0) {
c.Attributes = DefaultAttribute.EmptyAttributeList;
} else {
foreach (AST.Attribute a in node.Attributes) {
c.Attributes.Add(new DefaultAttribute(a.Name));
}
}
c.Documentation = node.Documentation;
}

8
src/AddIns/BackendBindings/Boo/BooBinding/Project/Templates/FormsProject.xpt

@ -42,9 +42,11 @@ partial class MainForm: @@ -42,9 +42,11 @@ partial class MainForm:
InitializeComponent()
// TODO: Add constructor code after the InitializeComponent() call.
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(false)
Application.Run(MainForm())
[STAThread]
def Main(argv as (string)):
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(false)
Application.Run(MainForm())
]]></File>
<File name="MainForm.Designer.boo" dependentUpon="MainForm.boo"><![CDATA[namespace ${StandardNamespace}

9
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Test/NRefactoryToBooConverter.Tests.csproj

@ -39,6 +39,10 @@ @@ -39,6 +39,10 @@
<HintPath>..\..\..\..\..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="GlobalTests.cs" />
@ -55,11 +59,6 @@ @@ -55,11 +59,6 @@
<Project>{DBCF20A1-BA13-4582-BFA9-74DE4D987B73}</Project>
<Name>NRefactoryToBooConverter</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Libraries\NUnit.Framework\nunit.framework.dll.csproj">
<Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>
<Name>nunit.framework.dll</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

9
src/AddIns/BackendBindings/CSharpBinding/Test/CSharpBinding.Tests.csproj

@ -32,6 +32,10 @@ @@ -32,6 +32,10 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ExpressionFinder.cs" />
@ -47,11 +51,6 @@ @@ -47,11 +51,6 @@
<Name>ICSharpCode.SharpDevelop</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NUnit.Framework\nunit.framework.dll.csproj">
<Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>
<Name>nunit.framework.dll</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

8
src/AddIns/BackendBindings/VBNetBinding/Test/VBNetBinding.Tests.csproj

@ -35,15 +35,15 @@ @@ -35,15 +35,15 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ExpressionFinderTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Libraries\NUnit.Framework\nunit.framework.dll.csproj">
<Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>
<Name>nunit.framework.dll</Name>
</ProjectReference>
<ProjectReference Include="..\Project\VBNetBinding.csproj">
<Project>{BF38FB72-B380-4196-AF8C-95749D726C61}</Project>
<Name>VBNetBinding</Name>

9
src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

@ -37,6 +37,10 @@ @@ -37,6 +37,10 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
@ -101,11 +105,6 @@ @@ -101,11 +105,6 @@
<Name>XmlEditor</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NUnit.Framework\nunit.framework.dll.csproj">
<Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>
<Name>nunit.framework.dll</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

1
src/AddIns/Misc/AddinScout/Project/Src/Gui/CodonListPanel.cs

@ -86,6 +86,7 @@ namespace AddInScout @@ -86,6 +86,7 @@ namespace AddInScout
ExtLabel.Text = "Extension : " + path;
AddInTreeNode node = AddInTree.GetTreeNode(path, false);
if (node == null) return;
foreach (Codon c in node.Codons) {
ListViewItem lvi = new ListViewItem(c.Name);
lvi.Tag = c;

78
src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin

@ -5,18 +5,21 @@ @@ -5,18 +5,21 @@
<Manifest>
<Identity name = "ICSharpCode.CodeCoverage"/>
<Dependency addin = "ICSharpCode.MbUnitPad"/>
<Dependency addin = "ICSharpCode.UnitTesting"/>
</Manifest>
<Runtime>
<!-- NUnit is not in the path, so we need to load it manually -->
<Import assembly = "../../../../bin/Tools/NUnit/NUnit.Util.dll"/>
<Import assembly = "../../../../bin/Tools/NUnit/NUnit.UIKit.dll"/>
<Import assembly = "$ICSharpCode.UnitTesting/UnitTesting.dll"/>
<Import assembly = "CodeCoverage.dll"/>
<Import assembly = "MbUnitPad.dll"/>
</Runtime>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "CodeCoveragePad"
category = "Tools"
title = "Code Coverage"
title = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
insertafter = "Bookmarks"
insertbefore = "DefinitionView"
icon = "CodeCoverage.Icons.16x16.Pad"
@ -24,74 +27,25 @@ @@ -24,74 +27,25 @@
</Path>
<Path name = "/SharpDevelop/Pads/CodeCoveragePad/Toolbar">
<Condition name = "SolutionOpen" action = "Disable">
<ToolbarItem id = "ToggleCodeCoverage"
icon = "CodeCoverage.Icons.16x16.File"
tooltip = "Toggle Code Coverage"
type = "CheckBox"
class = "ICSharpCode.CodeCoverage.ToggleCodeCoverageCommand"/>
</Condition>
<ToolbarItem id = "ToggleCodeCoverage"
icon = "CodeCoverage.Icons.16x16.File"
tooltip = "Toggle Code Coverage"
type = "CheckBox"
class = "ICSharpCode.CodeCoverage.ToggleCodeCoverageCommand"/>
</Path>
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<DialogPanel id = "CodeCoverageOptionsPanel"
label = "Code Coverage"
label = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
insertafter = "NAnt"
class = "ICSharpCode.CodeCoverage.CodeCoverageOptionsPanel"/>
</Path>
<Path name = "/SharpDevelop/Pads/MbUnitPad/ContextMenu">
<ComplexCondition action="Disable">
<And>
<Condition name = "Ownerstate" ownerstate = "TestItemSelected"/>
<Not>
<Condition name = "MbUnitRunningTests"/>
</Not>
</And>
<MenuItem id = "RunWithCodeCoverage"
icon = "CodeCoverage.Icons.16x16.Run"
insertafter = "Run"
insertbefore = "Stop"
label = "Run tests with code coverage"
class = "ICSharpCode.CodeCoverage.RunMbUnitPadTestsWithCodeCoverageCommand"/>
</ComplexCondition>
</Path>
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassMemberContextMenu/MbUnitTestMenu">
<Condition name = "MbUnitTestable">
<MenuItem id = "RunWithCodeCoverage"
insertafter = "RunWithDebugger"
label = "Run with code coverage"
icon = "CodeCoverage.Icons.16x16.Run"
class = "ICSharpCode.CodeCoverage.RunTestWithCodeCoverageCommand"/>
</Condition>
</Path>
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassBookmarkContextMenu/MbUnitTestMenu">
<Condition name = "MbUnitTestable">
<MenuItem id = "RunWithCodeCoverage"
insertafter = "RunWithDebugger"
label = "Run with code coverage"
icon = "CodeCoverage.Icons.16x16.Run"
class = "ICSharpCode.CodeCoverage.RunTestFixtureWithCodeCoverageCommand"/>
</Condition>
</Path>
<Path name = "/SharpDevelop/Pads/ClassBrowser/ClassContextMenu/MbUnitTestMenu">
<Condition name = "MbUnitTestable">
<MenuItem id = "RunWithCodeCoverage"
insertafter = "RunWithDebugger"
label = "Run with code coverage"
icon = "CodeCoverage.Icons.16x16.Run"
class = "ICSharpCode.CodeCoverage.RunTestFixtureWithCodeCoverageCommand"/>
</Condition>
</Path>
<Path name = "/SharpDevelop/Pads/ClassBrowser/MemberContextMenu/MbUnitTestMenu">
<Condition name = "MbUnitTestable">
<Path name = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands">
<Condition name="UnitCommonTestCommandsEnabled" action="Disable">
<MenuItem id = "RunWithCodeCoverage"
insertafter = "RunWithDebugger"
label = "Run with code coverage"
label = "${res:ICSharpCode.UnitTesting.RunWithCoverage}"
icon = "CodeCoverage.Icons.16x16.Run"
class = "ICSharpCode.CodeCoverage.RunTestWithCodeCoverageCommand"/>
</Condition>
@ -99,7 +53,7 @@ @@ -99,7 +53,7 @@
<Path path = "/SharpDevelop/BackendBindings/ProjectOptions/C#">
<DialogPanel id = "CodeCoverage"
label = "Code Coverage"
label = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
insertafter = "Publish"
class = "ICSharpCode.CodeCoverage.CodeCoverageProjectOptionsPanel"/>
</Path>

15
src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.csproj

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
<AssemblyName>CodeCoverage</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B7F1A068-01F5-49E7-83EF-05DE281B09FD}</ProjectGuid>
<ProjectGuid>{08ce9972-283b-44f4-82fa-966f7dfa6b7a}</ProjectGuid>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<RegisterForComInterop>False</RegisterForComInterop>
@ -60,7 +60,6 @@ @@ -60,7 +60,6 @@
<EmbeddedResource Include="Resources\CodeCoverageOptionsPanel.xfrm" />
<Compile Include="Src\CodeCoverageDisplayItem.cs" />
<Compile Include="Src\ColorPickerComboBox.cs" />
<Compile Include="Src\RunMbUnitPadTestsWithCodeCoverageCommand.cs" />
<Compile Include="Src\OutputReader.cs" />
<Compile Include="Src\ProcessRunner.cs" />
<Compile Include="Src\ProcessRunnerException.cs" />
@ -72,11 +71,8 @@ @@ -72,11 +71,8 @@
<Compile Include="Src\CodeCoverageProjectOptionsPanel.cs" />
<EmbeddedResource Include="Resources\CodeCoverageProjectOptionsPanel.xfrm" />
<Compile Include="Src\NCoverSettings.cs" />
<Compile Include="Src\MbUnitResults.cs" />
<Compile Include="Src\CodeCoverageService.cs" />
<Compile Include="Src\AbstractRunTestsWithCodeCoverageCommand.cs" />
<Compile Include="Src\RunTestWithCodeCoverageCommand.cs" />
<Compile Include="Src\RunTestFixtureWithCodeCoverageCommand.cs" />
<EmbeddedResource Include="Resources\CodeCoverageRunnerNotFoundForm.xfrm" />
<Compile Include="Src\CodeCoverageRunnerNotFoundForm.cs" />
<None Include="CodeCoverage.addin">
@ -84,7 +80,6 @@ @@ -84,7 +80,6 @@
</None>
<Compile Include="Src\CodeCoverageImageList.cs" />
<Compile Include="Src\GrayScaleBitmap.cs" />
<Compile Include="Src\NUnitResults.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
@ -102,12 +97,12 @@ @@ -102,12 +97,12 @@
<Name>ICSharpCode.TextEditor</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\MbUnitPad\Project\MbUnitPad.csproj">
<Project>{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}</Project>
<Name>MbUnitPad</Name>
<Content Include="PostBuildEvent.proj" />
<ProjectReference Include="..\..\UnitTesting\UnitTesting.csproj">
<Project>{1F261725-6318-4434-A1B1-6C70CE4CD324}</Project>
<Name>UnitTesting</Name>
<Private>False</Private>
</ProjectReference>
<Content Include="PostBuildEvent.proj" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<Import Project="PostBuildEvent.proj" />

4
src/AddIns/Misc/CodeCoverage/Project/Configuration/AssemblyInfo.cs

@ -1,11 +1,10 @@ @@ -1,11 +1,10 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System.Reflection;
using System.Runtime.CompilerServices;
@ -32,4 +31,3 @@ using System.Runtime.CompilerServices; @@ -32,4 +31,3 @@ using System.Runtime.CompilerServices;
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("2.0.0.1")]

6
src/AddIns/Misc/CodeCoverage/Project/PostBuildEvent.proj

@ -3,9 +3,9 @@ @@ -3,9 +3,9 @@
<PrepareForRunDependsOn>$(PrepareForRunDependsOn);MyPostBuildTarget</PrepareForRunDependsOn>
</PropertyGroup>
<Target Name="MyPostBuildTarget">
<!-- Delete the MbUnitPad.addin file that gets copied to the CodeCoverage AddIn output
folder due to an MSBuild bug. Otherwise the MbUnitPad.addin file will be
<!-- Delete the UnitTesting.addin file that gets copied to the CodeCoverage AddIn output
folder due to an MSBuild bug. Otherwise the UnitTesting.addin file will be
loaded twice by SharpDevelop -->
<Delete Files="$(OutputPath)\MbUnitPad.addin" ContinueOnError="True"/>
<Delete Files="$(OutputPath)\UnitTesting.addin" ContinueOnError="True"/>
</Target>
</Project>

297
src/AddIns/Misc/CodeCoverage/Project/Src/AbstractRunTestsWithCodeCoverageCommand.cs

@ -1,297 +0,0 @@ @@ -1,297 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using System;
using System.IO;
using System.Reflection;
using System.Text;
namespace ICSharpCode.CodeCoverage
{
/// <summary>
/// Base class that provides an NCover runner to run tests
/// with code coverage
/// </summary>
public abstract class AbstractRunTestsWithCodeCoverageCommand : AbstractMenuCommand
{
static MessageViewCategory category;
static NCoverRunner runner;
public AbstractRunTestsWithCodeCoverageCommand()
{
if (runner == null) {
runner = NCoverRunnerSingleton.Runner;
runner.NCoverExited += new NCoverExitEventHandler(NCoverExited);
runner.OutputLineReceived += new LineReceivedEventHandler(OutputLineReceived);
}
}
public override void Run()
{
if (IsBuildRunning) {
throw new CodeCoverageException();
}
string ncoverFileName = GetNCoverFileName();
if (ncoverFileName != null) {
SetNCoverRunnerProperties(ncoverFileName);
RunNCover();
} else {
using (CodeCoverageRunnerNotFoundForm form = new CodeCoverageRunnerNotFoundForm()) {
form.ShowDialog();
}
}
}
/// <summary>
/// Returns the full filename of the assembly being tested.
/// </summary>
/// <returns></returns>
protected virtual string GetTestAssemblyFileName()
{
return String.Empty;
}
/// <summary>
/// Returns the project containing the tests.
/// </summary>
protected virtual IProject GetProject()
{
return null;
}
bool IsBuildRunning {
get {
return runner.IsRunning;
}
}
/// <summary>
/// Gets the message view output window.
/// </summary>
MessageViewCategory Category {
get {
if (category == null) {
category = new MessageViewCategory("Code Coverage");
CompilerMessageView cmv = (CompilerMessageView)WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).PadContent;
cmv.AddCategory(category);
}
return category;
}
}
/// <summary>
/// Writes a line of text to the output window.
/// </summary>
void CategoryWriteLine(string message)
{
Category.AppendText(String.Concat(message, Environment.NewLine));
}
/// <summary>
/// Brings output pad to the front.
/// </summary>
void ShowOutputPad()
{
WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront();
}
bool FileNameExists(string fileName)
{
return fileName.Length > 0 && File.Exists(fileName);
}
void SetNCoverRunnerProperties(string ncoverFileName)
{
IProject project = GetProject();
string ncoverOutputDirectory = GetNCoverOutputDirectory(project);
runner.NCoverFileName = ncoverFileName;
runner.ProfiledApplicationCommand = GetMbUnitConsoleFileName();
runner.ProfiledApplicationCommandLineArguments = GetMbUnitConsoleCommandLineArguments(ncoverOutputDirectory);
runner.WorkingDirectory = Path.GetDirectoryName(GetTestAssemblyFileName());
runner.CoverageResultsFileName = Path.Combine(ncoverOutputDirectory, "Coverage.Xml");
runner.LogFileName = Path.Combine(ncoverOutputDirectory, "Coverage.log");
runner.AssemblyList = GetAssemblyList(project);
}
void RunNCover()
{
CodeCoverageService.ClearResults();
Category.ClearText();
TaskService.ClearExceptCommentTasks();
ShowOutputPad();
// Remove existing coverage results file.
if (File.Exists(runner.CoverageResultsFileName)) {
File.Delete(runner.CoverageResultsFileName);
}
// Remove existing MbUnit results file.
string mbUnitResultsFileName = GetMbUnitResultsFileName();
if (File.Exists(mbUnitResultsFileName)) {
File.Delete(mbUnitResultsFileName);
}
// Create NCover output directory.
if (!Directory.Exists(Path.GetDirectoryName(runner.CoverageResultsFileName))) {
Directory.CreateDirectory(Path.GetDirectoryName(runner.CoverageResultsFileName));
}
CategoryWriteLine(StringParser.Parse("Running NCover..."));
CategoryWriteLine(runner.CommandLine);
runner.Start();
}
/// <summary>
/// Displays the output from NCover after it has exited.
/// </summary>
/// <param name="sender">The event source.</param>
/// <param name="e">The NCover exit event arguments.</param>
void NCoverExited(object sender, NCoverExitEventArgs e)
{
System.Diagnostics.Debug.Assert(e.Error.Length == 0);
DisplayMbUnitResults(GetMbUnitResultsFileName());
DisplayCoverageResults(runner.CoverageResultsFileName);
if (TaskService.SomethingWentWrong) {
ShowErrorList();
}
}
void OutputLineReceived(object sender, LineReceivedEventArgs e)
{
CategoryWriteLine(e.Line);
}
void DisplayCoverageResults(string fileName)
{
if (!File.Exists(fileName)) {
Task task = new Task(String.Empty, String.Concat("No code coverage results file generated: ", fileName), 0, 0, TaskType.Error);
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", new object[] {task});
return;
}
CodeCoverageResults results = new CodeCoverageResults(fileName);
WorkbenchSingleton.SafeThreadAsyncCall(typeof(CodeCoverageService), "ShowResults", new object[] {results});
}
void DisplayMbUnitResults(string fileName)
{
if (!File.Exists(fileName)) {
Task task = new Task(String.Empty, String.Concat("No MbUnit results file generated: ", fileName), 0, 0, TaskType.Error);
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", new object[] {task});
return;
}
MbUnitResults results = new MbUnitResults(fileName);
foreach (Task task in results.Tasks) {
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", new object[] {task});
}
}
/// <summary>
/// Returns the full path to the NCover console application if it
/// exists.
/// </summary>
string GetNCoverFileName()
{
string ncoverFileName = CodeCoverageOptions.NCoverFileName;
if (FileNameExists(ncoverFileName)) {
return ncoverFileName;
} else {
ncoverFileName = GetDefaultNCoverFileName();
if (FileNameExists(ncoverFileName)) {
return ncoverFileName;
}
}
return null;
}
/// <summary>
/// Returns the default full path to the NCover console application.
/// </summary>
/// <returns></returns>
string GetDefaultNCoverFileName()
{
string programFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
return Path.Combine(programFilesPath, @"NCover\NCover.Console.exe");
}
void ShowErrorList()
{
PadDescriptor padDescriptor = WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad));
if (padDescriptor != null) {
WorkbenchSingleton.SafeThreadAsyncCall(padDescriptor, "BringPadToFront");
}
}
/// <summary>
/// Reads the list of assemblies to be profiled from the project's
/// NCover settings.
/// </summary>
string GetAssemblyList(IProject project)
{
if (project == null) {
return String.Empty;
}
string ncoverSettingsFileName = NCoverSettings.GetFileName(project);
if (File.Exists(ncoverSettingsFileName)) {
NCoverSettings settings = new NCoverSettings(ncoverSettingsFileName);
return settings.AssemblyList;
}
return String.Empty;
}
string GetNCoverOutputDirectory(IProject project)
{
return Path.Combine(project.Directory, "NCover");
}
/// <summary>
/// Gets the assembly folder where this add-in was loaded from.
/// </summary>
/// <returns>The assembly folder where this add-in was loaded.</returns>
string GetAssemblyFolder()
{
Assembly assembly = GetType().Assembly;
string assemblyFilename = assembly.CodeBase.Replace("file:///", String.Empty);
return Path.GetDirectoryName(assemblyFilename);
}
string GetMbUnitConsoleFileName()
{
return Path.GetFullPath(Path.Combine(GetAssemblyFolder(),
@"..\..\..\..\bin\Tools\MbUnit\MbUnit.Cons.exe"));
}
string GetMbUnitConsoleCommandLineArguments(string reportFolder)
{
StringBuilder commandLine = new StringBuilder();
commandLine.Append("/report-name-format:mbunit ");
commandLine.Append("/report-type:Xml ");
commandLine.AppendFormat("/report-folder:\"{0}\" ", reportFolder);
commandLine.AppendFormat("\"{0}\"", GetTestAssemblyFileName());
return commandLine.ToString();
}
string GetMbUnitResultsFileName()
{
string ncoverOutputDirectory = Path.GetDirectoryName(runner.CoverageResultsFileName);
return Path.Combine(ncoverOutputDirectory, "mbunit.xml");
}
}
}

113
src/AddIns/Misc/CodeCoverage/Project/Src/MbUnitResults.cs

@ -1,113 +0,0 @@ @@ -1,113 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
namespace ICSharpCode.CodeCoverage
{
/// <summary>
/// Reads the MbUnit results file.
/// </summary>
public class MbUnitResults
{
static readonly string RunElementName = "run";
static readonly string MessageElementName = "message";
static readonly string StackTraceElementName= "stack-trace";
List<Task> tasks = new List<Task>();
public MbUnitResults(string fileName) : this(new StreamReader(fileName, true))
{
}
public MbUnitResults(XmlTextReader reader)
{
ReadResults(reader);
}
public MbUnitResults(TextReader reader) : this(new XmlTextReader(reader))
{
}
public List<Task> Tasks {
get {
return tasks;
}
}
void ReadResults(XmlTextReader reader)
{
using (reader) {
while (reader.Read()) {
if (reader.NodeType == XmlNodeType.Element) {
if (IsRunFailureElement(reader)) {
ReadErrorTask(reader);
}
}
}
}
}
bool IsRunFailureElement(XmlReader reader)
{
if (reader.Name == RunElementName) {
string result = reader.GetAttribute("result");
if (result == "failure") {
return true;
}
}
return false;
}
void ReadErrorTask(XmlReader reader)
{
string testCase = reader.GetAttribute("name");
string message = String.Empty;
while (reader.Read()) {
if (reader.NodeType == XmlNodeType.Element) {
if (reader.Name == MessageElementName) {
message = reader.ReadElementString();
} else if (reader.Name == StackTraceElementName) {
string stackTrace = reader.ReadElementString();
AddTask(GetDescription(testCase, message), stackTrace);
return;
}
}
}
}
/// <summary>
/// Gets task error description.
/// </summary>
string GetDescription(string testCase, string message)
{
return StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] {
{"TestCase", testCase},
{"Message", message}
});
}
void AddTask(string description, string stackTrace)
{
FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(stackTrace, true);
if (lineRef != null) {
Task task = new Task(Path.GetFullPath(lineRef.FileName),
description,
lineRef.Column,
lineRef.Line,
TaskType.Error);
tasks.Add(task);
}
}
}
}

113
src/AddIns/Misc/CodeCoverage/Project/Src/NUnitResults.cs

@ -1,113 +0,0 @@ @@ -1,113 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
namespace ICSharpCode.CodeCoverage
{
/// <summary>
/// Reads the NUnit results file.
/// </summary>
public class NUnitResults
{
static readonly string TestCaseElementName = "test-case";
static readonly string MessageElementName = "message";
static readonly string StackTraceElementName= "stack-trace";
List<Task> tasks = new List<Task>();
public NUnitResults(string fileName) : this(new StreamReader(fileName, true))
{
}
public NUnitResults(XmlTextReader reader)
{
ReadResults(reader);
}
public NUnitResults(TextReader reader) : this(new XmlTextReader(reader))
{
}
public List<Task> Tasks {
get {
return tasks;
}
}
void ReadResults(XmlTextReader reader)
{
using (reader) {
while (reader.Read()) {
if (reader.NodeType == XmlNodeType.Element) {
if (IsTestCaseFailureElement(reader)) {
ReadErrorTask(reader);
}
}
}
}
}
bool IsTestCaseFailureElement(XmlReader reader)
{
if (reader.Name == TestCaseElementName) {
string success = reader.GetAttribute("success");
if (success == "False") {
return true;
}
}
return false;
}
void ReadErrorTask(XmlReader reader)
{
string testCase = reader.GetAttribute("name");
string message = String.Empty;
while (reader.Read()) {
if (reader.NodeType == XmlNodeType.Element) {
if (reader.Name == MessageElementName) {
message = reader.ReadElementString();
} else if (reader.Name == StackTraceElementName) {
string stackTrace = reader.ReadElementString();
AddTask(GetDescription(testCase, message), stackTrace);
return;
}
}
}
}
/// <summary>
/// Gets task error description.
/// </summary>
string GetDescription(string testCase, string message)
{
return StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] {
{"TestCase", testCase},
{"Message", message}
});
}
void AddTask(string description, string stackTrace)
{
FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(stackTrace, true);
if (lineRef != null) {
Task task = new Task(Path.GetFullPath(lineRef.FileName),
description,
lineRef.Column,
lineRef.Line,
TaskType.Error);
tasks.Add(task);
}
}
}
}

37
src/AddIns/Misc/CodeCoverage/Project/Src/RunMbUnitPadTestsWithCodeCoverageCommand.cs

@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.MbUnitPad;
using System;
namespace ICSharpCode.CodeCoverage
{
public class RunMbUnitPadTestsWithCodeCoverageCommand : AbstractRunTestsWithCodeCoverageCommand
{
protected override string GetTestAssemblyFileName()
{
return MbUnitPadContent.Instance.SelectedAssemblyFileName;
}
protected override IProject GetProject()
{
return GetSelectedProject(GetTestAssemblyFileName());
}
IProject GetSelectedProject(string outputAssemblyFileName)
{
foreach (IProject project in ProjectService.OpenSolution.Projects) {
if (FileUtility.IsEqualFileName(outputAssemblyFileName, project.OutputAssemblyFullPath)) {
return project;
}
}
return null;
}
}
}

47
src/AddIns/Misc/CodeCoverage/Project/Src/RunTestFixtureWithCodeCoverageCommand.cs

@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.MbUnitPad;
using System;
namespace ICSharpCode.CodeCoverage
{
/// <summary>
/// Menu command selected after right clicking a test fixture in the text editor
/// to run tests with code coverage.
/// </summary>
public class RunTestFixtureWithCodeCoverageCommand : AbstractRunTestsWithCodeCoverageCommand
{
IProject project;
public override void Run()
{
IMember m = MbUnitTestableCondition.GetMember(Owner);
IClass c = (m != null) ? m.DeclaringType : MbUnitTestableCondition.GetClass(Owner);
project = c.ProjectContent.Project;
if (project != null) {
base.Run();
} else {
MessageService.ShowMessage("Unable to determine project.");
}
}
protected override IProject GetProject()
{
return project;
}
protected override string GetTestAssemblyFileName()
{
return project.OutputAssemblyFullPath;
}
}
}

213
src/AddIns/Misc/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs

@ -7,9 +7,11 @@ @@ -7,9 +7,11 @@
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.MbUnitPad;
using ICSharpCode.UnitTesting;
using System;
using System.IO;
namespace ICSharpCode.CodeCoverage
{
@ -17,30 +19,213 @@ namespace ICSharpCode.CodeCoverage @@ -17,30 +19,213 @@ namespace ICSharpCode.CodeCoverage
/// Menu command selected after right clicking a test method in the text editor
/// to run tests with code coverage.
/// </summary>
public class RunTestWithCodeCoverageCommand : AbstractRunTestsWithCodeCoverageCommand
public class RunTestWithCodeCoverageCommand : AbstractRunTestCommand
{
IProject project;
static MessageViewCategory category;
static NCoverRunner runner;
public override void Run()
public RunTestWithCodeCoverageCommand()
{
IMember m = MbUnitTestableCondition.GetMember(Owner);
IClass c = (m != null) ? m.DeclaringType : MbUnitTestableCondition.GetClass(Owner);
project = c.ProjectContent.Project;
if (project != null) {
base.Run();
if (runner == null) {
runner = NCoverRunnerSingleton.Runner;
runner.NCoverExited += new NCoverExitEventHandler(NCoverExited);
runner.OutputLineReceived += new LineReceivedEventHandler(OutputLineReceived);
}
}
protected override void RunTests(IProject project, IClass fixture, IMember test)
{
if (IsBuildRunning) {
throw new CodeCoverageException();
}
string ncoverFileName = GetNCoverFileName();
if (ncoverFileName != null) {
SetNCoverRunnerProperties(ncoverFileName, project, fixture, test);
RunNCover();
} else {
MessageService.ShowMessage("Unable to determine project.");
using (CodeCoverageRunnerNotFoundForm form = new CodeCoverageRunnerNotFoundForm()) {
form.ShowDialog();
}
}
}
bool IsBuildRunning {
get {
return runner.IsRunning;
}
}
protected override IProject GetProject()
/// <summary>
/// Gets the message view output window.
/// </summary>
MessageViewCategory Category {
get {
if (category == null) {
category = new MessageViewCategory("Code Coverage");
CompilerMessageView cmv = (CompilerMessageView)WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).PadContent;
cmv.AddCategory(category);
}
return category;
}
}
/// <summary>
/// Writes a line of text to the output window.
/// </summary>
void CategoryWriteLine(string message)
{
Category.AppendText(String.Concat(message, Environment.NewLine));
}
/// <summary>
/// Brings output pad to the front.
/// </summary>
void ShowOutputPad()
{
return project;
WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront();
}
bool FileNameExists(string fileName)
{
return fileName.Length > 0 && File.Exists(fileName);
}
void SetNCoverRunnerProperties(string ncoverFileName, IProject project, IClass fixture, IMember test)
{
string ncoverOutputDirectory = GetNCoverOutputDirectory(project);
UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
helper.Initialize(project, fixture, test);
helper.XmlOutputFile = Path.Combine(ncoverOutputDirectory, "NUnit.Xml");
runner.NCoverFileName = ncoverFileName;
runner.ProfiledApplicationCommand = UnitTestApplicationStartHelper.UnitTestConsoleApplication;
runner.ProfiledApplicationCommandLineArguments = helper.GetArguments();
runner.WorkingDirectory = Path.GetDirectoryName(helper.Assemblies[0]);
runner.CoverageResultsFileName = Path.Combine(ncoverOutputDirectory, "Coverage.Xml");
runner.LogFileName = Path.Combine(ncoverOutputDirectory, "Coverage.log");
runner.AssemblyList = GetAssemblyList(project);
}
void RunNCover()
{
CodeCoverageService.ClearResults();
CodeCoverageService.CodeCoverageHighlighted = true;
Category.ClearText();
TaskService.ClearExceptCommentTasks();
ShowOutputPad();
// Remove existing coverage results file.
if (File.Exists(runner.CoverageResultsFileName)) {
File.Delete(runner.CoverageResultsFileName);
}
// Create NCover output directory.
if (!Directory.Exists(Path.GetDirectoryName(runner.CoverageResultsFileName))) {
Directory.CreateDirectory(Path.GetDirectoryName(runner.CoverageResultsFileName));
}
CategoryWriteLine(StringParser.Parse("Running NCover..."));
CategoryWriteLine(runner.CommandLine);
runner.Start();
}
/// <summary>
/// Displays the output from NCover after it has exited.
/// </summary>
/// <param name="sender">The event source.</param>
/// <param name="e">The NCover exit event arguments.</param>
void NCoverExited(object sender, NCoverExitEventArgs e)
{
System.Diagnostics.Debug.Assert(e.Error.Length == 0);
string ncoverOutputDirectory = Path.GetDirectoryName(runner.CoverageResultsFileName);
string unitTestResultsFileName = Path.Combine(ncoverOutputDirectory, "NUnit.Xml");
UnitTestApplicationStartHelper.DisplayResults(unitTestResultsFileName);
DisplayCoverageResults(runner.CoverageResultsFileName);
if (TaskService.SomethingWentWrong) {
ShowErrorList();
}
}
void OutputLineReceived(object sender, LineReceivedEventArgs e)
{
CategoryWriteLine(e.Line);
}
void DisplayCoverageResults(string fileName)
{
if (!File.Exists(fileName)) {
Task task = new Task(String.Empty, String.Concat("No code coverage results file generated: ", fileName), 0, 0, TaskType.Error);
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", new object[] {task});
return;
}
CodeCoverageResults results = new CodeCoverageResults(fileName);
WorkbenchSingleton.SafeThreadAsyncCall(typeof(CodeCoverageService), "ShowResults", new object[] {results});
}
/// <summary>
/// Returns the full path to the NCover console application if it
/// exists.
/// </summary>
string GetNCoverFileName()
{
string ncoverFileName = CodeCoverageOptions.NCoverFileName;
if (FileNameExists(ncoverFileName)) {
return ncoverFileName;
} else {
ncoverFileName = GetDefaultNCoverFileName();
if (FileNameExists(ncoverFileName)) {
return ncoverFileName;
}
}
return null;
}
/// <summary>
/// Returns the default full path to the NCover console application.
/// </summary>
/// <returns></returns>
string GetDefaultNCoverFileName()
{
string programFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
return Path.Combine(programFilesPath, @"NCover\NCover.Console.exe");
}
void ShowErrorList()
{
PadDescriptor padDescriptor = WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad));
if (padDescriptor != null) {
WorkbenchSingleton.SafeThreadAsyncCall(padDescriptor, "BringPadToFront");
}
}
/// <summary>
/// Reads the list of assemblies to be profiled from the project's
/// NCover settings.
/// </summary>
string GetAssemblyList(IProject project)
{
if (project == null) {
return String.Empty;
}
string ncoverSettingsFileName = NCoverSettings.GetFileName(project);
if (File.Exists(ncoverSettingsFileName)) {
NCoverSettings settings = new NCoverSettings(ncoverSettingsFileName);
return settings.AssemblyList;
}
return String.Empty;
}
protected override string GetTestAssemblyFileName()
string GetNCoverOutputDirectory(IProject project)
{
return project.OutputAssemblyFullPath;
return Path.Combine(project.Directory, "NCover");
}
}
}

4
src/AddIns/Misc/CodeCoverage/Test/AssemblyInfo.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
@ -23,5 +23,5 @@ using System.Runtime.CompilerServices; @@ -23,5 +23,5 @@ using System.Runtime.CompilerServices;
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.1")]

9
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj

@ -32,6 +32,10 @@ @@ -32,6 +32,10 @@
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" />
@ -68,11 +72,6 @@ @@ -68,11 +72,6 @@
<Name>Debugger.Core</Name>
</ProjectReference>
<Folder Include="Src\TestPrograms" />
<ProjectReference Include="..\..\..\..\..\Libraries\NUnit.Framework\nunit.framework.dll.csproj">
<Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>
<Name>nunit.framework.dll</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

12
src/AddIns/Misc/FiletypeRegisterer/Project/Src/FiletypeAssociationDoozer.cs

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 29.01.2006
* Time: 15:33
*/
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections;

16
src/AddIns/Misc/MbUnitPad/MbUnitPad.sln

@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.960
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MbUnitPad", "Project\MbUnitPad.csproj", "{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Release|Any CPU.Build.0 = Release|Any CPU
{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

176
src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.addin

@ -1,176 +0,0 @@ @@ -1,176 +0,0 @@
<AddIn name = "MbUnit-Addin"
author = "Daniel Grunwald"
copyright = "prj:///doc/copyright.txt"
description = "Runs MbUnit and NUnit tests inside #Develop">
<Manifest>
<Identity name = "ICSharpCode.MbUnitPad"/>
</Manifest>
<Runtime>
<!-- MbUnit is not in the path, so we need to load it manually -->
<Import assembly = "../../../../bin/Tools/MbUnit/MbUnit.GUI.exe"/>
<Import assembly = "MbUnitPad.dll">
<ConditionEvaluator name = "MbUnitTestable" class = "ICSharpCode.MbUnitPad.MbUnitTestableCondition"/>
<ConditionEvaluator name = "MbUnitRunningTests" class = "ICSharpCode.MbUnitPad.MbUnitRunningTestsCondition"/>
</Import>
</Runtime>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "MbUnitPad"
category = "Tools"
title = "${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}"
icon = "PadIcons.MbUnitTest"
shortcut = "Control|Alt|T"
class = "ICSharpCode.MbUnitPad.MbUnitPadContent"/>
</Path>
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassMemberContextMenu">
<Include id = "MbUnitTests" insertbefore = "MenuBuilder" item="/SharpDevelop/Pads/ClassBrowser/MemberContextMenu/MbUnitTestMenu"/>
</Path>
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassBookmarkContextMenu">
<Include id = "MbUnitTests" insertbefore = "MenuBuilder" item="/SharpDevelop/Pads/ClassBrowser/ClassContextMenu/MbUnitTestMenu"/>
</Path>
<Path name = "/SharpDevelop/Pads/ClassBrowser/MemberContextMenu">
<Condition name = "MbUnitTestable">
<MenuItem id="MbUnitTestMenu" type="Menu" label="Unit Testing" icon="PadIcons.MbUnitTest" insertbefore="MenuBuilder">
<MenuItem id = "RunInPad"
label = "Run in unit test pad"
icon = "PadIcons.MbUnitTest"
class = "ICSharpCode.MbUnitPad.RunTestInPadCommand"/>
<MenuItem id = "RunWithDebugger"
label = "Run in console with debugger"
icon = "Icons.16x16.RunProgramIcon"
class = "ICSharpCode.MbUnitPad.RunTestWithDebuggerCommand"/>
</MenuItem>
</Condition>
</Path>
<Path name = "/SharpDevelop/Pads/ClassBrowser/ClassContextMenu">
<Condition name = "MbUnitTestable">
<MenuItem id="MbUnitTestMenu" type="Menu" label="Unit Testing" icon="PadIcons.MbUnitTest" insertbefore="MenuBuilder">
<MenuItem id = "RunInPad"
label = "Run in unit test pad"
icon = "PadIcons.MbUnitTest"
class = "ICSharpCode.MbUnitPad.RunTestInPadCommand"/>
<MenuItem id = "RunWithDebugger"
label = "Run in console with debugger"
icon = "Icons.16x16.RunProgramIcon"
class = "ICSharpCode.MbUnitPad.RunTestWithDebuggerCommand"/>
</MenuItem>
</Condition>
</Path>
<Path name = "/SharpDevelop/Pads/MbUnitPad/Toolbar">
<Condition name = "SolutionOpen" action="Disable">
<ToolbarItem id = "Reload"
icon = "Icons.16x16.BrowserRefresh"
tooltip = "${res:NUnitPad.NUnitPadContent.RefreshItem}"
class = "ICSharpCode.MbUnitPad.ReloadCommand"/>
<ToolbarItem id = "Unload"
icon = "Icons.16x16.BrowserCancel"
tooltip = "${res:NUnitPad.NUnitPadContent.CancelItem}"
class = "ICSharpCode.MbUnitPad.UnloadCommand"/>
<ToolbarItem id = "Separator1" type = "Separator"/>
<ToolbarItem id = "AddMbUnitReference"
icon = "Icons.16x16.Reference"
tooltip = "${res:MbUnitPad.ReferenceItem}"
class = "ICSharpCode.MbUnitPad.AddMbUnitReferenceCommand"/>
<ToolbarItem id = "AddNUnitReference"
icon = "PadIcons.NUnitTest"
tooltip = "${res:NUnitPad.NUnitPadContent.ReferenceItem}"
class = "ICSharpCode.MbUnitPad.AddNUnitReferenceCommand"/>
<ToolbarItem id = "Separator2" type = "Separator"/>
</Condition>
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Not>
<Condition name="MbUnitRunningTests"/>
</Not>
</And>
<ToolbarItem id = "Run"
icon = "Icons.16x16.RunProgramIcon"
tooltip = "${res:NUnitPad.NUnitPadContent.RunItem}"
class = "ICSharpCode.MbUnitPad.RunTestsCommand"/>
</ComplexCondition>
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Condition name="MbUnitRunningTests"/>
</And>
<ToolbarItem id = "Stop"
icon = "Icons.16x16.Debug.StopProcess"
tooltip = "${res:NUnitPad.NUnitPadContent.StopTests}"
class = "ICSharpCode.MbUnitPad.StopTestsCommand"/>
</ComplexCondition>
</Path>
<Path name = "/SharpDevelop/Pads/MbUnitPad/ContextMenu">
<ComplexCondition action="Disable">
<And>
<Condition name="Ownerstate" ownerstate="TestItemSelected"/>
<Not>
<Condition name="MbUnitRunningTests"/>
</Not>
</And>
<MenuItem id = "Run"
icon = "Icons.16x16.RunProgramIcon"
label = "${res:NUnitPad.NUnitPadContent.RunTestsContextMenuLabel}"
class = "ICSharpCode.MbUnitPad.RunTestsCommand"/>
</ComplexCondition>
<ComplexCondition action="Disable">
<And>
<Condition name="Ownerstate" ownerstate="TestItemSelected"/>
<Condition name="MbUnitRunningTests"/>
</And>
<MenuItem id = "Stop"
icon = "Icons.16x16.Debug.StopProcess"
label = "${res:NUnitPad.NUnitPadContent.StopTests}"
class = "ICSharpCode.MbUnitPad.StopTestsCommand"/>
</ComplexCondition>
<Condition name="Ownerstate" ownerstate="SourceCodeItemSelected" action="Disable">
<MenuItem id = "GotoDefinition"
label = "${res:NUnitPad.NUnitPadContent.GotoDefinitionContextMenuLabel}"
class = "ICSharpCode.MbUnitPad.GotoDefinitionCommand"/>
</Condition>
<MenuItem id="Tree"
label="${res:MainWindow.Windows.UnitTestsTreeView.TreeMenu}"
type="Menu">
<MenuItem id = "ExpandAll"
label = "${res:MainWindow.Windows.SearchResultPanel.ExpandAll.ToolTip}"
class = "ICSharpCode.MbUnitPad.ExpandAllCommand"/>
<MenuItem id = "CollapseAll"
label = "${res:MainWindow.Windows.SearchResultPanel.CollapseAll.ToolTip}"
class = "ICSharpCode.MbUnitPad.CollapseAllCommand"/>
<MenuItem id="Separator1" type = "Separator"/>
<MenuItem id = "ExpandCurrent"
label = "${res:MainWindow.Windows.TreeView.ExpandCurrent}"
class = "ICSharpCode.MbUnitPad.ExpandCurrentCommand"/>
<MenuItem id = "CollapseCurrent"
label = "${res:MainWindow.Windows.TreeView.CollapseCurrent}"
class = "ICSharpCode.MbUnitPad.CollapseCurrentCommand"/>
<MenuItem id="Separator2" type = "Separator"/>
<MenuItem id = "ExpandAllFailures"
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandAllFailures}"
class = "ICSharpCode.MbUnitPad.ExpandAllFailuresCommand"/>
<MenuItem id = "ExpandCurrentFailures"
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandCurrentFailures}"
class = "ICSharpCode.MbUnitPad.ExpandCurrentFailuresCommand"/>
<MenuItem id="Separator3" type = "Separator"/>
<MenuItem id = "ExpandAllIgnored"
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandAllIgnoredTests}"
class = "ICSharpCode.MbUnitPad.ExpandAllIgnoredCommand"/>
<MenuItem id = "ExpandCurrentIgnored"
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandCurrentIgnoredTests}"
class = "ICSharpCode.MbUnitPad.ExpandCurrentIgnoredCommand"/>
<MenuItem id="Separator4" type = "Separator"/>
<MenuItem id = "ClearResults"
label = "${res:MainWindow.Windows.UnitTestsTreeView.ClearResults}"
class = "ICSharpCode.MbUnitPad.ClearResultsCommand"/>
</MenuItem>
</Path>
</AddIn>

69
src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.csproj

@ -1,69 +0,0 @@ @@ -1,69 +0,0 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.MbUnitPad</RootNamespace>
<AssemblyName>MbUnitPad</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}</ProjectGuid>
<ProductVersion>8.0.50215</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\MbUnitPad\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\MbUnitPad\</OutputPath>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="MbUnit.Framework">
<HintPath>..\..\..\..\Tools\MbUnit\MbUnit.Framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="MbUnit.GUI">
<HintPath>..\..\..\..\Tools\MbUnit\MbUnit.GUI.exe</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="MbUnitPad.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="Src\MbUnitPad.cs" />
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\MbUnitCommands.cs" />
<Compile Include="Src\TestTreeView.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Src\MbUnitTestableCondition.cs" />
<Compile Include="Src\MbUnitRunningTestsCondition.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
<Name>ICSharpCode.TextEditor</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

5
src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.csproj.user

@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastOpenVersion>8.0.50215</LastOpenVersion>
</PropertyGroup>
</Project>

198
src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitCommands.cs

@ -1,198 +0,0 @@ @@ -1,198 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using MbUnit.Forms;
namespace ICSharpCode.MbUnitPad
{
public class ReloadCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.ReloadAssemblyList();
}
}
public class UnloadCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.RemoveAssemblies();
}
}
public class RunTestsCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.RunTests();
}
}
public class StopTestsCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.StopTests();
}
}
public class AddNUnitReferenceCommand : AbstractMenuCommand
{
public override void Run()
{
if (ProjectService.CurrentProject != null) {
ProjectService.AddProjectItem(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "nunit.framework"));
ProjectService.CurrentProject.Save();
}
}
}
public class AddMbUnitReferenceCommand : AbstractMenuCommand
{
public override void Run()
{
if (ProjectService.CurrentProject != null) {
ProjectService.AddProjectItem(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "MbUnit.Framework"));
ProjectService.CurrentProject.Save();
}
}
}
public class RunTestInPadCommand : AbstractMenuCommand
{
public override void Run()
{
IMember m = MbUnitTestableCondition.GetMember(Owner);
IClass c = (m != null) ? m.DeclaringType : MbUnitTestableCondition.GetClass(Owner);
MessageService.ShowMessage("Not implemented");
}
}
public class RunTestWithDebuggerCommand : AbstractMenuCommand
{
public override void Run()
{
if (DebuggerService.IsDebuggerLoaded && DebuggerService.CurrentDebugger.IsDebugging) {
MessageService.ShowMessage("The debugger is currently busy.");
return;
}
IMember m = MbUnitTestableCondition.GetMember(Owner);
IClass c = (m != null) ? m.DeclaringType : MbUnitTestableCondition.GetClass(Owner);
if (m != null) {
MessageService.ShowMessage("Running single tests is not implemented, run the test fixture instead.");
return;
}
IProject project = c.ProjectContent.Project;
MSBuildEngineCallback callback = delegate(System.CodeDom.Compiler.CompilerResults results) {
if (results.Errors.Count > 0) {
return;
}
string mbUnitDir = Path.GetDirectoryName(typeof(ReflectorTreeView).Assembly.Location);
ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(mbUnitDir, "MbUnit.Cons.exe"));
string assemblyPath = project.OutputAssemblyFullPath;
StringBuilder sb = new StringBuilder();
sb.Append("\"/filter-type:" + c.FullyQualifiedName + "\"");
sb.Append(" \"/assembly-path:" + Path.GetDirectoryName(assemblyPath) + "\"");
sb.Append(" \"" + assemblyPath + "\"");
startInfo.Arguments = sb.ToString();
startInfo.WorkingDirectory = mbUnitDir;
LoggingService.Info("Run " + startInfo.FileName + " " + startInfo.Arguments);
DebuggerService.CurrentDebugger.Start(startInfo);
};
project.Build(callback);
}
}
public class GotoDefinitionCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.GotoDefinition();
}
}
public class ExpandAllCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.ExpandAll();
}
}
public class CollapseAllCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.CollapseAll();
}
}
public class ExpandCurrentCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.ExpandChildNode(MbUnitPadContent.Instance.TreeView.SelectedNode);
}
}
public class CollapseCurrentCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.CollapseChildNode(MbUnitPadContent.Instance.TreeView.SelectedNode);
}
}
public class ExpandAllFailuresCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.ExpandAllFailures();
}
}
public class ExpandCurrentFailuresCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.ExpandCurrentFailures();
}
}
public class ExpandAllIgnoredCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.ExpandAllIgnored();
}
}
public class ExpandCurrentIgnoredCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.ExpandCurrentIgnored();
}
}
public class ClearResultsCommand : AbstractMenuCommand
{
public override void Run()
{
MbUnitPadContent.Instance.TreeView.ClearAllResults();
}
}
}

27
src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitRunningTestsCondition.cs

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using System;
namespace ICSharpCode.MbUnitPad
{
/// <summary>
/// Determines whether #develop is currently running MbUnit tests.
/// </summary>
public class MbUnitRunningTestsCondition : IConditionEvaluator
{
public bool IsValid(object caller, Condition condition)
{
MbUnitPadContent pad = caller as MbUnitPadContent;
if (pad != null) {
return pad.IsRunningTests;
}
return false;
}
}
}

336
src/AddIns/Misc/MbUnitPad/Project/Src/TestTreeView.cs

@ -1,336 +0,0 @@ @@ -1,336 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using MbUnit.Forms;
using MbUnit.Core;
using MbUnit.Core.Graph;
using MbUnit.Core.Remoting;
using MbUnit.Core.Reports.Serialization;
namespace ICSharpCode.MbUnitPad
{
public class TestTreeView : ReflectorTreeView, IOwnerState
{
Hashtable pipeNodes;
[Flags]
public enum TestTreeViewState {
Nothing = 0,
SourceCodeItemSelected = 1,
TestItemSelected = 2
}
protected TestTreeViewState internalState = TestTreeViewState.Nothing;
public System.Enum InternalState {
get {
return internalState;
}
}
public TestTreeView()
{
TypeTree.HideSelection = false;
TypeTree.ContextMenu = null;
TypeTree.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/MbUnitPad/ContextMenu");
TypeTree.MouseDown += TreeViewMouseDown;
this.StartTests += OnTestsStarted;
this.FinishTests += delegate { BeginInvoke(new MethodInvoker(ExpandAllFailures)); };
this.Facade.Updated += OnFacadeUpdated;
// I don't see another good way to get a pipe node by GUID but stealing the facade's hashtable
pipeNodes = (Hashtable)typeof(TestTreeNodeFacade).InvokeMember("pipeNodes", BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic, null, Facade, null);
}
public TreeNode SelectedNode {
get {
return TypeTree.SelectedNode;
}
}
public string SelectedAssemblyFileName {
get {
UnitTreeNode node = SelectedNode as UnitTreeNode;
if (node != null) {
foreach (TreeTestDomain d in this.TestDomains) {
if (d.Identifier == node.DomainIdentifier) {
return d.TestFilePath;
}
}
}
return String.Empty;
}
}
public bool IsPopulated {
get {
return TypeTree.Nodes.Count > 0;
}
}
public void ExpandChildNode(TreeNode node)
{
TypeTree.BeginUpdate();
if (node != null) {
node.Expand();
foreach(TreeNode child in node.Nodes) {
ExpandChildNode(child);
}
}
TypeTree.EndUpdate();
}
public void CollapseChildNode(TreeNode node)
{
TypeTree.BeginUpdate();
if (node != null) {
node.Collapse();
foreach(TreeNode child in node.Nodes) {
CollapseChildNode(child);
}
}
TypeTree.EndUpdate();
}
public void ExpandAll()
{
TypeTree.ExpandAll();
}
public void CollapseAll()
{
TypeTree.CollapseAll();
}
public void GotoDefinition()
{
UnitTreeNode node = SelectedNode as UnitTreeNode;
if (node != null) {
string methodName = null;
string fixtureName = null;
switch (node.TestNodeType) {
case TestNodeType.Test:
methodName = GetTestMethodName(node.Text);
fixtureName = node.Parent.Text;
break;
case TestNodeType.Fixture:
fixtureName = node.Text;
break;
}
if (fixtureName != null) {
List<IClass> fixtures = FindTestFixtures(fixtureName);
if (fixtures.Count > 0) {
if (methodName == null) {
// Go to fixture definition.
IClass c = fixtures[0];
if (c.CompilationUnit != null) {
FileService.JumpToFilePosition(c.CompilationUnit.FileName, c.Region.BeginLine - 1, c.Region.BeginColumn - 1);
}
} else {
foreach (IClass c in fixtures) {
IMethod method = FindTestMethod(c, methodName);
if (method != null) {
FileService.JumpToFilePosition(c.CompilationUnit.FileName, method.Region.BeginLine - 1, method.Region.BeginColumn - 1);
break;
}
}
}
}
}
}
}
static MessageViewCategory testRunnerCategory;
string GetTestMethodName(string methodName)
{
int index = methodName.IndexOf(".");
if (index >= 0) {
return methodName.Substring(index + 1);
}
return methodName;
}
void OnTestsStarted(object sender, EventArgs e)
{
BeginInvoke(new EventHandler(OnTestsStartedInvoked));
}
void OnTestsStartedInvoked(object sender, EventArgs e)
{
PadDescriptor outputPad = WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView));
if (testRunnerCategory == null) {
testRunnerCategory = new MessageViewCategory("MbUnit");
((CompilerMessageView)outputPad.PadContent).AddCategory(testRunnerCategory);
} else {
testRunnerCategory.ClearText();
}
outputPad.BringPadToFront();
}
void OnFacadeUpdated(ResultEventArgs e)
{
try {
if (e.State == TestState.Failure) {
IList list = (IList)pipeNodes[e.PipeIdentifier];
for (int i = 0; i < list.Count; i++) {
UnitTreeNode node = list[i] as UnitTreeNode;
if (node != null) {
AppendResult(this.TestDomains.GetResult(node));
break;
}
}
}
} catch (Exception ex) {
MessageService.ShowError(ex);
}
}
void AppendResult(ReportRun result)
{
ReportException ex = result.Exception;
string message = (ex != null) ? ex.Message : "-";
string outputMessage = StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] {
{"TestCase", result.Name},
{"Message", message}
});
testRunnerCategory.AppendText(outputMessage + Environment.NewLine);
testRunnerCategory.AppendText(result.Description + Environment.NewLine);
if (ex != null) {
testRunnerCategory.AppendText(ex.StackTrace + Environment.NewLine);
FileLineReference LineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(ex.StackTrace, true);
if (LineRef != null) {
Task task = new Task(Path.GetFullPath(LineRef.FileName),
outputMessage,
LineRef.Column,
LineRef.Line,
TaskType.Error);
BeginInvoke(new AddTaskInvoker(TaskService.Add), new object[] { task });
}
}
}
delegate void AddTaskInvoker(Task task);
/// <summary>
/// Default MbUnit-GUI doesn't use shadow copy, we have to override that behaviour.
/// </summary>
public new void AddAssembly(string file)
{
if (this.TestDomains.ContainsTestAssembly(file)) {
throw new ApplicationException(string.Format("The file {0} is already loaded.", file));
} else {
TreeTestDomain domain = this.TestDomains.Add(file);
domain.ShadowCopyFiles = true;
this.TestDomains.Watcher.Start();
}
}
protected override void MessageOnStatusBar(string message, object[] args)
{
if (message.Length == 0) {
StatusBarService.SetMessage(null);
} else {
string msg = string.Format(message, args);
LoggingService.Debug(msg);
StatusBarService.SetMessage("MbUnit: " + msg);
}
}
void TreeViewMouseDown(object sender, MouseEventArgs e)
{
TreeNode node = TypeTree.GetNodeAt(e.X, e.Y);
TypeTree.SelectedNode = node;
internalState = TestTreeViewState.Nothing;
if (IsSourceCodeItemSelected) {
internalState |= TestTreeViewState.SourceCodeItemSelected;
}
if (IsTestItemSelected) {
internalState |= TestTreeViewState.TestItemSelected;
}
}
bool IsSourceCodeItemSelected {
get {
UnitTreeNode node = TypeTree.SelectedNode as UnitTreeNode;
if (node != null) {
return (node.TestNodeType == TestNodeType.Test) || (node.TestNodeType == TestNodeType.Fixture);
}
return false;
}
}
bool IsTestItemSelected {
get {
UnitTreeNode node = TypeTree.SelectedNode as UnitTreeNode;
return node != null;
}
}
List<IClass> FindTestFixtures(string name)
{
List<IClass> fixtures = new List<IClass>();
if (ProjectService.OpenSolution != null) {
foreach (IProject project in ProjectService.OpenSolution.Projects) {
IProjectContent projectContent = ParserService.GetProjectContent(project);
if (projectContent != null) {
foreach (IClass c in projectContent.Classes) {
if (c.Name == name) {
if (HasAttribute(c.Attributes, "TestFixture")) {
fixtures.Add(c);
}
}
}
}
}
}
return fixtures;
}
IMethod FindTestMethod(IClass c, string name)
{
foreach (IMethod method in c.Methods) {
if (method.Name == name) {
if (HasAttribute(method.Attributes, "Test")) {
return method;
}
}
}
return null;
}
bool HasAttribute(IList<IAttribute> attributes, string name)
{
foreach (IAttribute attr in attributes) {
if (attr.Name == name) {
return true;
}
}
return false;
}
}
}

9
src/AddIns/Misc/NAntAddIn/Test/NAntAddIn.Tests.csproj

@ -42,6 +42,10 @@ @@ -42,6 +42,10 @@
<HintPath>..\ConsoleApp\bin\ConsoleApp.exe</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
@ -82,11 +86,6 @@ @@ -82,11 +86,6 @@
<Project>{1DB3CAD2-38E8-4C5E-8E1B-0E37B1A5C006}</Project>
<Name>NAntAddIn</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\NUnit.Framework\nunit.framework.dll.csproj">
<Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>
<Name>nunit.framework.dll</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

2
src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlFormReader.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// <version>$Revision$</version>
// </file>
using System;

14
src/AddIns/Misc/MbUnitPad/Project/Configuration/AssemblyInfo.cs → src/AddIns/Misc/UnitTesting/Configuration/AssemblyInfo.cs

@ -1,11 +1,4 @@ @@ -1,11 +1,4 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
@ -14,8 +7,8 @@ using System.Runtime.CompilerServices; @@ -14,8 +7,8 @@ using System.Runtime.CompilerServices;
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("MbUnitPad")]
[assembly: AssemblyDescription("Addin for SharpDevelop 2.0")]
[assembly: AssemblyTitle("UnitTesting")]
[assembly: AssemblyDescription("AddIn for SharpDevelop 2.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ic#code")]
[assembly: AssemblyProduct("SharpDevelop")]
@ -31,3 +24,4 @@ using System.Runtime.CompilerServices; @@ -31,3 +24,4 @@ using System.Runtime.CompilerServices;
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("2.0.0.1")]

102
src/AddIns/Misc/UnitTesting/Src/NUnitResults.cs

@ -0,0 +1,102 @@ @@ -0,0 +1,102 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.UnitTesting
{
/// <summary>
/// Reads the NUnit results file.
/// </summary>
public class NUnitResults
{
static readonly string TestCaseElementName = "test-case";
static readonly string MessageElementName = "message";
static readonly string StackTraceElementName= "stack-trace";
readonly List<Task> tasks = new List<Task>();
public List<Task> Tasks {
get {
return tasks;
}
}
public NUnitResults(string fileName) : this(new StreamReader(fileName, true))
{
}
public NUnitResults(TextReader reader) : this(new XmlTextReader(reader))
{
}
public NUnitResults(XmlReader reader)
{
using (reader) {
ReadResults(reader);
}
}
void ReadResults(XmlReader reader)
{
while (reader.Read()) {
if (reader.NodeType == XmlNodeType.Element) {
if (reader.Name == TestCaseElementName) {
if (bool.Parse(reader.GetAttribute("executed")) == false) {
// test was ignored.
AddTest(reader, TaskType.Warning, "${res:NUnitPad.NUnitPadContent.TestTreeView.TestNotExecutedMessage}");
} else if (bool.Parse(reader.GetAttribute("success")) == false) {
// test failed.
AddTest(reader, TaskType.Error, "${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}");
}
}
}
}
}
void AddTest(XmlReader reader, TaskType type, string message)
{
string testName = reader.GetAttribute("name");
string msg, stackTrace;
GetDescription(reader, out msg, out stackTrace);
message = StringParser.Parse(message, new string[,] {
{"TestCase", testName},
{"Message", msg}
});
Task task = TestTreeView.CreateTask(type, message, testName, stackTrace);
if (task != null) {
tasks.Add(task);
}
}
void GetDescription(XmlReader reader, out string message, out string stackTrace)
{
message = "";
stackTrace = "";
while (reader.Read()) {
if (reader.NodeType == XmlNodeType.Element) {
if (reader.Name == MessageElementName) {
message = reader.ReadElementString();
} else if (reader.Name == StackTraceElementName) {
stackTrace = reader.ReadElementString();
}
} else if (reader.NodeType == XmlNodeType.EndElement) {
if (reader.Name == TestCaseElementName) {
return;
}
}
}
}
}
}

149
src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitPad.cs → src/AddIns/Misc/UnitTesting/Src/PadContent.cs

@ -11,30 +11,29 @@ using System.Reflection; @@ -11,30 +11,29 @@ using System.Reflection;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using MbUnit.Forms;
namespace ICSharpCode.MbUnitPad
namespace ICSharpCode.UnitTesting
{
public class MbUnitPadContent : AbstractPadContent
public class PadContent : AbstractPadContent
{
public static MbUnitPadContent Instance {
public static PadContent Instance {
get {
PadDescriptor descriptor = WorkbenchSingleton.Workbench.GetPad(typeof(MbUnitPadContent));
return (MbUnitPadContent)descriptor.PadContent;
PadDescriptor descriptor = WorkbenchSingleton.Workbench.GetPad(typeof(PadContent));
return (PadContent)descriptor.PadContent;
}
}
public static void BringToFront()
{
WorkbenchSingleton.Workbench.GetPad(typeof(MbUnitPadContent)).BringPadToFront();
WorkbenchSingleton.Workbench.GetPad(typeof(PadContent)).BringPadToFront();
}
TestTreeView treeView;
ToolStrip toolStrip;
Control ctl;
bool runningTests;
public TestTreeView TreeView {
get {
@ -45,21 +44,25 @@ namespace ICSharpCode.MbUnitPad @@ -45,21 +44,25 @@ namespace ICSharpCode.MbUnitPad
/// <summary>
/// Creates a new TestPad object
/// </summary>
public MbUnitPadContent()
public PadContent()
{
ctl = new Panel();
treeView = new TestTreeView();
treeView.Dock = DockStyle.Fill;
treeView.TypeTree.KeyPress += TreeViewKeyPress;
treeView.TypeTree.DoubleClick += TreeViewDoubleClick;
treeView.RunStarted += ThreadedUpdateToolbar;
treeView.RunFinished += ThreadedUpdateToolbar;
treeView.RunFinished += delegate {
WorkbenchSingleton.SafeThreadAsyncCall((MethodInvoker)ShowErrorList);
};
ctl.Controls.Add(treeView);
toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/MbUnitPad/Toolbar");
toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/UnitTestingPad/Toolbar");
toolStrip.GripStyle = ToolStripGripStyle.Hidden;
ctl.Controls.Add(toolStrip);
ProjectService.SolutionLoaded += OnSolutionLoaded;
ProjectService.SolutionClosed += OnSolutionClosed;
ProjectService.EndBuild += OnEndBuild;
}
/// <summary>
@ -69,21 +72,10 @@ namespace ICSharpCode.MbUnitPad @@ -69,21 +72,10 @@ namespace ICSharpCode.MbUnitPad
{
ProjectService.SolutionLoaded -= OnSolutionLoaded;
ProjectService.SolutionClosed -= OnSolutionClosed;
ProjectService.EndBuild -= OnEndBuild;
ctl.Dispose();
}
public bool IsRunningTests {
get {
return runningTests;
}
}
public string SelectedAssemblyFileName {
get {
return treeView.SelectedAssemblyFileName;
}
}
void OnSolutionLoaded(object sender, EventArgs e)
{
UpdateToolbar();
@ -91,54 +83,62 @@ namespace ICSharpCode.MbUnitPad @@ -91,54 +83,62 @@ namespace ICSharpCode.MbUnitPad
void OnSolutionClosed(object sender, EventArgs e)
{
treeView.UnloadTestAssemblies();
UpdateToolbar();
treeView.NewConfig();
}
public void RunTests()
void OnEndBuild(object sender, EventArgs e)
{
TaskService.ClearExceptCommentTasks();
if (treeView.TypeTree.Nodes.Count == 0) {
treeView.TreePopulated += StartTestsAfterTreePopulation;
treeView.FinishTests += FinishTests;
ReloadAssemblyList();
} else {
treeView.FinishTests += FinishTests;
treeView.ThreadedRunTests();
runningTests = true;
UpdateToolbar();
if (autoLoadItems) {
ReloadAssemblyList(null);
}
}
public void StopTests()
bool autoLoadItems;
public void RunTests()
{
LoadAssemblyList(treeView.RunTests);
}
public void UnloadTests()
{
treeView.AbortWorkerThread();
runningTests = false;
autoLoadItems = false;
treeView.UnloadTestAssemblies();
UpdateToolbar();
ShowErrorList();
}
void FinishTests(object sender, EventArgs e)
public bool IsRunningTests {
get {
return treeView.IsTestRunning;
}
}
public void StopTests()
{
treeView.FinishTests -= FinishTests;
runningTests = false;
WorkbenchSingleton.SafeThreadAsyncCall(this, "UpdateToolbar");
WorkbenchSingleton.SafeThreadAsyncCall(this, "ShowErrorList");
treeView.StopTests();
UpdateToolbar();
}
void StartTestsAfterTreePopulation(object sender, EventArgs e)
/// <summary>
/// Loads the assemblies if they are not already loaded.
/// </summary>
public void LoadAssemblyList(MethodInvoker callback)
{
treeView.TreePopulated -= StartTestsAfterTreePopulation;
// we cannot run the tests on this thread because we have to wait for the worker thread to exit
WorkbenchSingleton.SafeThreadAsyncCall(treeView, "ThreadedRunTests");
runningTests = true;
WorkbenchSingleton.SafeThreadAsyncCall(this, "UpdateToolbar");
if (autoLoadItems) {
if (callback != null)
callback();
} else {
ReloadAssemblyList(callback);
}
}
public void ReloadAssemblyList()
public void ReloadAssemblyList(MethodInvoker callback)
{
LoggingService.Debug("ReloadAssemblyList");
treeView.TestDomains.Clear();
autoLoadItems = true;
treeView.UnloadTestAssemblies();
treeView.StartAddingAssemblies();
foreach (IProject project in ProjectService.OpenSolution.Projects) {
bool referenceFound = false;
foreach (ProjectItem item in project.Items) {
@ -155,8 +155,8 @@ namespace ICSharpCode.MbUnitPad @@ -155,8 +155,8 @@ namespace ICSharpCode.MbUnitPad
if (include.Substring(include.Length - 4).Equals(".dll", StringComparison.OrdinalIgnoreCase))
include = include.Substring(0, include.Length - 4);
}
if (string.Equals(include, "nunit.framework", StringComparison.OrdinalIgnoreCase)
|| string.Equals(include, "mbunit.framework", StringComparison.OrdinalIgnoreCase))
if (string.Equals(include, "nunit.framework", StringComparison.OrdinalIgnoreCase))
//|| string.Equals(include, "mbunit.framework", StringComparison.OrdinalIgnoreCase))
{
referenceFound = true;
break;
@ -165,15 +165,13 @@ namespace ICSharpCode.MbUnitPad @@ -165,15 +165,13 @@ namespace ICSharpCode.MbUnitPad
}
if (referenceFound) {
string outputAssembly = project.OutputAssemblyFullPath;
LoggingService.Debug("MbUnitPad: Load " + outputAssembly);
try {
treeView.AddAssembly(outputAssembly);
} catch (Exception e) {
LoggingService.Warn("MbUnitPad load error", e);
}
LoggingService.Debug("UnitTestingPad: Load " + outputAssembly);
treeView.AddAssembly(project, outputAssembly);
}
}
treeView.ThreadedPopulateTree(true);
treeView.FinishAddingAssemblies();
if (callback != null)
WorkbenchSingleton.SafeThreadAsyncCall(callback);
}
/// <summary>
@ -192,23 +190,14 @@ namespace ICSharpCode.MbUnitPad @@ -192,23 +190,14 @@ namespace ICSharpCode.MbUnitPad
{
}
void UpdateToolbar()
{
ToolbarService.UpdateToolbar(toolStrip);
}
void TreeViewKeyPress(object sender, KeyPressEventArgs e)
void ThreadedUpdateToolbar(object sender, EventArgs e)
{
if (e.KeyChar == '\r') {
treeView.GotoDefinition();
} else if (e.KeyChar == ' ') {
RunTests();
}
WorkbenchSingleton.SafeThreadAsyncCall((MethodInvoker)UpdateToolbar);
}
void TreeViewDoubleClick(object sender, EventArgs e)
void UpdateToolbar()
{
treeView.GotoDefinition();
ToolbarService.UpdateToolbar(toolStrip);
}
void ShowErrorList()
@ -217,5 +206,13 @@ namespace ICSharpCode.MbUnitPad @@ -217,5 +206,13 @@ namespace ICSharpCode.MbUnitPad
WorkbenchSingleton.Workbench.GetPad(typeof(ErrorListPad)).BringPadToFront();
}
}
public void RunTest(IProject project, IClass fixture, IMember test)
{
LoadAssemblyList(delegate {
treeView.SelectTest(project, fixture, test);
treeView.RunTests();
});
}
}
}

100
src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs

@ -0,0 +1,100 @@ @@ -0,0 +1,100 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.UnitTesting
{
public abstract class AbstractRunTestCommand : AbstractMenuCommand
{
public override void Run()
{
IMember m = TestableCondition.GetMember(Owner);
IClass c = (m != null) ? m.DeclaringType : TestableCondition.GetClass(Owner);
Run(TestableCondition.GetProject(Owner), c, m);
}
public void Run(IProject project, IClass fixture, IMember test)
{
if (project == null) {
throw new ArgumentNullException("project");
}
MSBuildEngineCallback callback = delegate(System.CodeDom.Compiler.CompilerResults results) {
if (results.Errors.Count > 0) {
return;
}
RunTests(project, fixture, test);
};
project.Build(callback);
}
protected abstract void RunTests(IProject project, IClass fixture, IMember test);
}
public class RunTestInPadCommand : AbstractRunTestCommand
{
protected override void RunTests(IProject project, IClass fixture, IMember test)
{
PadContent.BringToFront();
PadContent.Instance.RunTest(project, fixture, test);
}
}
public class RunTestWithDebuggerCommand : AbstractRunTestCommand
{
public override void Run()
{
if (DebuggerService.IsDebuggerLoaded && DebuggerService.CurrentDebugger.IsDebugging) {
MessageService.ShowMessage("The debugger is currently busy.");
} else {
base.Run();
}
}
static string lastOutputFile;
protected override void RunTests(IProject project, IClass fixture, IMember test)
{
ProcessStartInfo startInfo = new ProcessStartInfo(UnitTestApplicationStartHelper.UnitTestConsoleApplication);
UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
helper.Initialize(project, fixture, test);
helper.XmlOutputFile = Path.GetTempFileName();
try {
File.Delete(helper.XmlOutputFile);
} catch {}
lastOutputFile = helper.XmlOutputFile;
startInfo.Arguments = helper.GetArguments();
startInfo.WorkingDirectory = UnitTestApplicationStartHelper.UnitTestApplicationDirectory;
LoggingService.Info("Run " + startInfo.FileName + " " + startInfo.Arguments);
// register event if it is not already registered
DebuggerService.DebugStopped -= DebuggerFinished;
DebuggerService.DebugStopped += DebuggerFinished;
DebuggerService.CurrentDebugger.Start(startInfo);
}
static void DebuggerFinished(object sender, EventArgs e)
{
DebuggerService.DebugStopped -= DebuggerFinished;
if (lastOutputFile != null) {
UnitTestApplicationStartHelper.DisplayResults(lastOutputFile);
try {
File.Delete(lastOutputFile);
} catch {}
lastOutputFile = null;
}
}
}
}

45
src/AddIns/Misc/UnitTesting/Src/RunningTestsCondition.cs

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using System;
namespace ICSharpCode.UnitTesting
{
/// <summary>
/// Determines whether #develop is currently running unit tests.
/// </summary>
public class RunningTestsCondition : IConditionEvaluator
{
public bool IsValid(object caller, Condition condition)
{
// initializing PadContent might call IsValid
if (caller is PadContent)
return ((PadContent)caller).IsRunningTests;
return PadContent.Instance.IsRunningTests;
}
}
/// <summary>
/// Determines whether starting unit tests by calling a command derived from
/// AbstractRunTestCommand is possible.
/// </summary>
public class UnitCommonTestCommandsEnabledCondition : IConditionEvaluator
{
public bool IsValid(object caller, Condition condition)
{
if (PadContent.Instance.IsRunningTests)
return false;
TestTreeView view = caller as TestTreeView;
if (view != null) {
return view.SelectedProject != null;
} else {
return true;
}
}
}
}

448
src/AddIns/Misc/UnitTesting/Src/TestTreeView.cs

@ -0,0 +1,448 @@ @@ -0,0 +1,448 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using NUnit.Core;
using NUnit.Framework;
using NUnit.UiKit;
using NUnit.Util;
namespace ICSharpCode.UnitTesting
{
public class TestTreeView : TestSuiteTreeView, IOwnerState
{
TestLoader loader = new TestLoader();
static MessageViewCategory testRunnerCategory;
[Flags]
public enum TestTreeViewState {
Nothing = 0,
SourceCodeItemSelected = 1,
TestItemSelected = 2
}
System.Enum IOwnerState.InternalState {
get {
TestTreeViewState state = TestTreeViewState.Nothing;
UITestNode test = SelectedTest;
if (test != null) {
state |= TestTreeViewState.TestItemSelected;
if (test.IsTestCase || test.IsFixture) {
state |= TestTreeViewState.SourceCodeItemSelected;
}
}
return state;
}
}
public static MessageViewCategory TestRunnerCategory {
get {
if (testRunnerCategory == null) {
testRunnerCategory = new MessageViewCategory("${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}");
CompilerMessageView.Instance.AddCategory(testRunnerCategory);
}
return testRunnerCategory;
}
}
void OnRunStarting()
{
TaskService.ClearExceptCommentTasks();
TestRunnerCategory.ClearText();
PadDescriptor outputPad = WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView));
outputPad.BringPadToFront();
}
public TestTreeView()
{
loader.ReloadOnChange = false;
loader.ReloadOnRun = false;
loader.Events.TestLoadFailed += delegate(object sender, TestEventArgs e) {
TestRunnerCategory.AppendText("Loading " + e.Name + " failed: " + e.Exception.ToString());
if (e.Exception is InvalidCastException && e.Exception.Message.Contains(typeof(AssemblyResolver).FullName)) {
MessageService.ShowMessage("Loading tests failed, make sure NUnit.Core is in the Global Assembly Cache.");
} else {
MessageService.ShowMessage("Loading " + e.Name + " failed: " + e.Exception.ToString());
}
};
loader.Events.TestLoaded += delegate(object sender, TestEventArgs e) {
WorkbenchSingleton.SafeThreadAsyncCall((MethodInvoker)UpdateProjectTitles);
};
loader.Events.RunStarting += delegate(object sender, TestEventArgs e) {
WorkbenchSingleton.SafeThreadAsyncCall((MethodInvoker)OnRunStarting);
};
loader.Events.TestOutput += delegate(object sender, TestEventArgs e) {
// This method interceps StdOut/StdErr from the tests
TestRunnerCategory.AppendText(e.TestOutput.Text);
};
loader.Events.TestFinished += delegate(object sender, TestEventArgs e) {
TestResult result = e.Result;
if (!result.IsSuccess) {
string outputMessage = StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] {
{"TestCase", result.Test.FullName},
{"Message", result.Message.Replace("\t", " ").Trim()}
});
TestRunnerCategory.AppendText(Environment.NewLine + outputMessage + Environment.NewLine);
if (!string.IsNullOrEmpty(result.Description)) {
TestRunnerCategory.AppendText(result.Description + Environment.NewLine);
}
TestRunnerCategory.AppendText(result.StackTrace + Environment.NewLine);
AddTask(TaskType.Error, outputMessage, result.Test.FullName, result.StackTrace);
} else if (!result.Executed) {
string outputMessage = StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestNotExecutedMessage}", new string[,] {
{"TestCase", result.Test.FullName}
});
testRunnerCategory.AppendText(Environment.NewLine + outputMessage + Environment.NewLine);
testRunnerCategory.AppendText(result.Message + Environment.NewLine);
if (!string.IsNullOrEmpty(result.Description)) {
TestRunnerCategory.AppendText(result.Description + Environment.NewLine);
}
testRunnerCategory.AppendText(result.StackTrace + Environment.NewLine);
AddTask(TaskType.Warning, outputMessage, result.Test.FullName, result.StackTrace);
}
};
Initialize(loader, loader.Events);
this.ContextMenu = null;
this.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/UnitTestingPad/ContextMenu");
}
void UpdateProjectTitles()
{
if (Nodes.Count == 0)
return;
TreeNode root = Nodes[0];
root.Text = ProjectService.OpenSolution.Name;
foreach (TreeNode project in root.Nodes) {
if (Path.IsPathRooted(project.Text)) {
project.Text = Path.GetFileNameWithoutExtension(project.Text);
}
}
}
static void AddTask(TaskType type, string message, string fullTestName, string stackTrace)
{
Task task = CreateTask(type, message, fullTestName, stackTrace);
if (task != null) {
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", task);
}
}
internal static Task CreateTask(TaskType type, string message, string fullTestName, string stackTrace)
{
FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(stackTrace, true);
if (lineRef == null) {
lineRef = FindTest(fullTestName);
}
if (lineRef != null) {
return new Task(Path.GetFullPath(lineRef.FileName),
message, lineRef.Column, lineRef.Line, type);
} else {
return null;
}
}
public void StopTests()
{
loader.CancelTestRun();
}
public event TestEventHandler RunStarted {
add { loader.Events.RunStarting += value; }
remove { loader.Events.RunStarting -= value; }
}
public event TestEventHandler RunFinished {
add { loader.Events.RunFinished += value; }
remove { loader.Events.RunFinished -= value; }
}
public bool IsTestRunning {
get {
return loader.IsTestRunning;
}
}
NUnitProject project;
public void StartAddingAssemblies()
{
project = NUnitProject.NewProject();
project.ProjectPath = ProjectService.OpenSolution.Directory;
// assemblies outside the BasePath cannot be loaded by .NET, so use the root of the drive
project.BasePath = Path.GetPathRoot(ProjectService.OpenSolution.Directory);
}
public void FinishAddingAssemblies()
{
loader.TestProject = project;
loader.LoadTest();
project = null;
}
public void AddAssembly(IProject sdProject, string assemblyFile)
{
if (!File.Exists(assemblyFile)) {
TestRunnerCategory.AppendText(assemblyFile + " does not exist.");
return;
}
#if DEBUG
// NUnit uses cross thread calls.......
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
#endif
if (project != null) {
project.ActiveConfig.Assemblies.Add(assemblyFile);
} else {
if (!loader.IsProjectLoaded) {
StartAddingAssemblies();
loader.TestProject = project;
project = null;
}
loader.TestProject.ActiveConfig.Assemblies.Add(assemblyFile);
}
}
public void UnloadTestAssemblies()
{
if (loader.IsProjectLoaded) {
loader.UnloadProject();
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
if (e.Button == MouseButtons.Right) {
// required to run context menu commands on the correct item:
this.SelectedNode = GetNodeAt(e.Location);
}
base.OnMouseDown(e);
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (e.KeyChar == '\r') {
e.Handled = true;
GotoDefinition();
} else if (e.KeyChar == ' ') {
e.Handled = true;
RunTests();
} else {
base.OnKeyPress(e);
}
}
public void SelectTest(IProject project, IClass fixture, IMember test)
{
if (Nodes.Count == 0) {
return;
}
TreeNode root = Nodes[0];
TreeNode nodeToSelect = null;
foreach (TreeNode projectNode in root.Nodes) {
if (projectNode.Text == project.Name) {
nodeToSelect = projectNode;
break;
}
}
if (nodeToSelect != null && fixture != null) {
// find fixture node
TestSuiteTreeNode node = FindTest(nodeToSelect, fixture);
if (node != null) {
nodeToSelect = node;
if (test != null) {
node = FindTest(node, test);
if (node != null) {
nodeToSelect = node;
}
}
}
}
this.SelectedNode = nodeToSelect;
}
TestSuiteTreeNode FindTest(TestSuiteTreeNode fixtureNode, IMember test)
{
foreach (TestSuiteTreeNode node in fixtureNode.Nodes) {
if (node.Text == test.Name)
return node;
}
return null;
}
TestSuiteTreeNode FindTest(TreeNode projectNode, IClass fixture)
{
foreach (TreeNode node in projectNode.Nodes) {
TestSuiteTreeNode testNode = node as TestSuiteTreeNode;
if (testNode != null) {
if (testNode.Test.IsFixture) {
if (testNode.Test.FullName == fixture.FullyQualifiedName)
return testNode;
} else {
testNode = FindTest(testNode, fixture);
if (testNode != null)
return testNode;
}
}
}
return null;
}
public new void RunTests()
{
if (Nodes.Count > 0) {
base.RunTests();
}
}
protected override void OnDoubleClick(EventArgs e)
{
GotoDefinition();
}
public void GotoDefinition()
{
UITestNode node = SelectedTest;
if (node != null) {
FileLineReference lr = null;
if (node.IsFixture) {
lr = FindTest(node.FullName, null);
} else if (node.IsTestCase) {
lr = FindTest(node.FullName);
}
if (lr != null) {
FileService.JumpToFilePosition(lr.FileName, lr.Line, lr.Column);
}
}
}
public IProject SelectedProject {
get {
IClass fixture = SelectedFixtureClass;
if (fixture != null)
return fixture.ProjectContent.Project;
TreeNode node = SelectedNode;
if (node == null)
return null;
if (node.Level == 0 && node.Nodes.Count == 1) {
// solution node clicked, but has only 1 project
node = node.Nodes[0];
}
if (node.Level == 2 && node.Parent.Nodes.Count == 1) {
// namespace node clicked, but project has only 1 namespace
node = node.Parent;
}
if (node.Level == 1) {
foreach (IProject p in ProjectService.OpenSolution.Projects) {
if (p.Name == node.Text) {
return p;
}
}
}
return null;
}
}
public IClass SelectedFixtureClass {
get {
IMember member = SelectedTestMethod;
if (member != null)
return member.DeclaringType;
UITestNode node = SelectedTest;
if (node != null && node.IsFixture) {
foreach (IClass fixture in FindTestFixtures(node.FullName)) {
return fixture;
}
}
return null;
}
}
public IMember SelectedTestMethod {
get {
UITestNode node = SelectedTest;
if (node != null && node.IsTestCase) {
string fullMethodName = node.FullName;
int pos = fullMethodName.LastIndexOf('.');
string shortName = fullMethodName.Substring(pos + 1);
foreach (IClass fixture in FindTestFixtures(fullMethodName.Substring(0, pos))) {
IMember m = FindTestMethod(fixture, shortName);
if (m != null)
return m;
}
}
return null;
}
}
static FileLineReference FindTest(string fullMethodName)
{
int pos = fullMethodName.LastIndexOf('.');
return FindTest(fullMethodName.Substring(0, pos), fullMethodName.Substring(pos + 1));
}
static FileLineReference FindTest(string fixtureName, string methodName)
{
if (fixtureName != null) {
List<IClass> fixtures = FindTestFixtures(fixtureName);
if (fixtures.Count > 0) {
if (methodName == null) {
// Go to fixture definition.
IClass c = fixtures[0];
if (c.CompilationUnit != null) {
return new FileLineReference(c.CompilationUnit.FileName, c.Region.BeginLine - 1, c.Region.BeginColumn - 1);
}
} else {
foreach (IClass c in fixtures) {
IMethod method = FindTestMethod(c, methodName);
if (method != null) {
return new FileLineReference(c.CompilationUnit.FileName, method.Region.BeginLine - 1, method.Region.BeginColumn - 1);
}
}
}
}
}
return null;
}
static List<IClass> FindTestFixtures(string fullName)
{
List<IClass> fixtures = new List<IClass>();
if (ProjectService.OpenSolution != null) {
foreach (IProject project in ProjectService.OpenSolution.Projects) {
IProjectContent projectContent = ParserService.GetProjectContent(project);
if (projectContent != null) {
IClass c = projectContent.GetClass(fullName, 0, projectContent.Language, false);
if (c != null) {
fixtures.Add(c);
}
}
}
}
return fixtures;
}
static IMethod FindTestMethod(IClass c, string name)
{
return c.Methods.Find(delegate(IMethod m) { return m.Name == name; });
}
}
}

22
src/AddIns/Misc/MbUnitPad/Project/Src/MbUnitTestableCondition.cs → src/AddIns/Misc/UnitTesting/Src/TestableCondition.cs

@ -14,15 +14,18 @@ using ICSharpCode.SharpDevelop.Dom; @@ -14,15 +14,18 @@ using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.MbUnitPad
namespace ICSharpCode.UnitTesting
{
/// <summary>
/// Supplies a "Unit test" menu item if the class is a test fixture.
/// </summary>
public class MbUnitTestableCondition : IConditionEvaluator
public class TestableCondition : IConditionEvaluator
{
public static IMember GetMember(object caller)
{
if (caller is TestTreeView) {
return ((TestTreeView)caller).SelectedTestMethod;
}
MemberNode memberNode = caller as MemberNode;
if (memberNode != null) {
return memberNode.Member;
@ -37,6 +40,9 @@ namespace ICSharpCode.MbUnitPad @@ -37,6 +40,9 @@ namespace ICSharpCode.MbUnitPad
public static IClass GetClass(object caller)
{
if (caller is TestTreeView) {
return ((TestTreeView)caller).SelectedFixtureClass;
}
ClassNode classNode = caller as ClassNode;
if (classNode != null) {
return classNode.Class;
@ -49,10 +55,22 @@ namespace ICSharpCode.MbUnitPad @@ -49,10 +55,22 @@ namespace ICSharpCode.MbUnitPad
return null;
}
public static ICSharpCode.SharpDevelop.Project.IProject GetProject(object caller)
{
if (caller is TestTreeView) {
return ((TestTreeView)caller).SelectedProject;
}
IMember m = GetMember(caller);
IClass c = (m != null) ? m.DeclaringType : GetClass(caller);
return c.ProjectContent.Project;
}
public bool IsValid(object caller, Condition condition)
{
IMember m = GetMember(caller);
IClass c = (m != null) ? m.DeclaringType : GetClass(caller);
if (c.ProjectContent.Project == null)
return false;
StringComparer nameComparer = c.ProjectContent.Language.NameComparer;
string attributeName = (m != null) ? "Test" : "TestFixture";
foreach (IAttribute attribute in (m ?? (IDecoration)c).Attributes) {

151
src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs

@ -0,0 +1,151 @@ @@ -0,0 +1,151 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.UnitTesting
{
/// <summary>
/// Helper to run the unit testing console application.
/// </summary>
public class UnitTestApplicationStartHelper
{
/// <summary>
/// returns full/path/to/Tools/NUnit
/// </summary>
public static string UnitTestApplicationDirectory {
get {
return Path.Combine(FileUtility.ApplicationRootPath, "bin/Tools/NUnit");
}
}
/// <summary>
/// returns full/path/to/Tools/NUnit/nunit-console.exe
/// </summary>
public static string UnitTestConsoleApplication {
get {
return Path.Combine(UnitTestApplicationDirectory, "nunit-console.exe");
}
}
public readonly List<string> Assemblies = new List<string>();
/// <summary>
/// Use shadow copy assemblies. Default = true.
/// </summary>
public bool ShadowCopy = true;
/// <summary>
/// Run tests on separate thread. Default = false.
/// </summary>
public bool Threaded = false;
/// <summary>
/// Use /nologo directive.
/// </summary>
public bool NoLogo = false;
/// <summary>
/// File to write xml output to. Default = null.
/// </summary>
public string XmlOutputFile;
/// <summary>
/// Fixture to test. Null = test all fixtures.
/// </summary>
public string Fixture;
/// <summary>
/// Test to run. Null = run all tests. Only valid together with the Fixture property.
/// </summary>
public string Test;
public void Initialize(IProject project, IClass fixture, IMember test)
{
Assemblies.Add(project.OutputAssemblyFullPath);
if (fixture != null) {
Fixture = fixture.FullyQualifiedName;
if (test != null) {
Test = test.Name;
}
}
}
/// <summary>
/// Gets the arguments to use on the command line to run NUnit.
/// </summary>
public string GetArguments()
{
StringBuilder b = new StringBuilder();
foreach (string assembly in Assemblies) {
if (b.Length > 0)
b.Append(' ');
b.Append('"');
b.Append(assembly);
b.Append('"');
}
if (!ShadowCopy)
b.Append(" /noshadow");
if (Threaded)
b.Append(" /thread");
if (NoLogo)
b.Append(" /nologo");
if (XmlOutputFile != null) {
b.Append(" /xml=\"");
b.Append(XmlOutputFile);
b.Append('"');
}
if (Fixture != null) {
b.Append(" /fixture=\"");
b.Append(Fixture);
b.Append('"');
if (Test != null) {
b.Append(" /testMethodName=\"");
b.Append(Fixture);
b.Append('.');
b.Append(Test);
b.Append('"');
}
}
return b.ToString();
}
public void DisplayResults()
{
DisplayResults(XmlOutputFile);
}
public static void DisplayResults(string resultFile)
{
if (resultFile == null)
throw new ArgumentNullException("resultFile");
if (!File.Exists(resultFile)) {
Task task = new Task("", "No NUnit results file generated: " + resultFile, 0, 0, TaskType.Error);
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", task);
return;
}
try {
NUnitResults results = new NUnitResults(resultFile);
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "AddRange", results.Tasks);
} catch (System.Xml.XmlException ex) {
Task task = new Task(resultFile, "Invalid NUnit results file: " + ex.Message, ex.LineNumber, ex.LinePosition, TaskType.Error);
WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", task);
}
}
}
}

96
src/AddIns/Misc/UnitTesting/Src/UnitTestCommands.cs

@ -0,0 +1,96 @@ @@ -0,0 +1,96 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.UnitTesting
{
public class ReloadCommand : AbstractMenuCommand
{
public override void Run()
{
PadContent.Instance.ReloadAssemblyList(null);
}
}
public class UnloadCommand : AbstractMenuCommand
{
public override void Run()
{
PadContent.Instance.UnloadTests();
}
}
public class RunTestsCommand : AbstractMenuCommand
{
public override void Run()
{
PadContent.Instance.RunTests();
}
}
public class StopTestsCommand : AbstractMenuCommand
{
public override void Run()
{
PadContent.Instance.StopTests();
}
}
public class AddNUnitReferenceCommand : AbstractMenuCommand
{
public override void Run()
{
if (ProjectService.CurrentProject != null) {
ProjectService.AddProjectItem(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "nunit.framework"));
ProjectService.CurrentProject.Save();
}
}
}
public class AddMbUnitReferenceCommand : AbstractMenuCommand
{
public override void Run()
{
if (ProjectService.CurrentProject != null) {
ProjectService.AddProjectItem(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "MbUnit.Framework"));
ProjectService.CurrentProject.Save();
}
}
}
public class GotoDefinitionCommand : AbstractMenuCommand
{
public override void Run()
{
PadContent.Instance.TreeView.GotoDefinition();
}
}
public class ExpandAllCommand : AbstractMenuCommand
{
public override void Run()
{
PadContent.Instance.TreeView.ExpandAll();
}
}
public class CollapseAllCommand : AbstractMenuCommand
{
public override void Run()
{
PadContent.Instance.TreeView.CollapseAll();
}
}
}

187
src/AddIns/Misc/UnitTesting/UnitTesting.addin

@ -0,0 +1,187 @@ @@ -0,0 +1,187 @@
<AddIn name = "UnitTesting-Addin"
author = "Daniel Grunwald"
copyright = "prj:///doc/copyright.txt"
description = "Runs NUnit tests inside #Develop">
<Manifest>
<Identity name = "ICSharpCode.UnitTesting"/>
</Manifest>
<Runtime>
<!-- NUnit is not in the path, so we need to load it manually -->
<Import assembly = "../../../../bin/Tools/NUnit/NUnit.Util.dll"/>
<Import assembly = "../../../../bin/Tools/NUnit/NUnit.UIKit.dll"/>
<Import assembly = "UnitTesting.dll">
<ConditionEvaluator name = "UnitTestable" class = "ICSharpCode.UnitTesting.TestableCondition"/>
<ConditionEvaluator name = "UnitRunningTests" class = "ICSharpCode.UnitTesting.RunningTestsCondition"/>
<ConditionEvaluator name = "UnitCommonTestCommandsEnabled" class = "ICSharpCode.UnitTesting.UnitCommonTestCommandsEnabledCondition"/>
</Import>
</Runtime>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "UnitTestingPad"
category = "Tools"
title = "${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}"
icon = "PadIcons.NUnitTest"
shortcut = "Control|Alt|T"
class = "ICSharpCode.UnitTesting.PadContent"/>
</Path>
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassMemberContextMenu">
<Include id = "UnitTests" insertbefore = "MenuBuilder" item="/SharpDevelop/Pads/ClassBrowser/MemberContextMenu/UnitTestMenu"/>
</Path>
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassBookmarkContextMenu">
<Include id = "UnitTests" insertbefore = "MenuBuilder" item="/SharpDevelop/Pads/ClassBrowser/ClassContextMenu/UnitTestMenu"/>
</Path>
<Path name = "/SharpDevelop/Pads/ClassBrowser/MemberContextMenu">
<Condition name = "UnitTestable">
<MenuItem id="UnitTestMenu" type="Menu" label="Unit Testing" icon="PadIcons.NUnitTest" insertbefore="MenuBuilder">
<Condition name="UnitCommonTestCommandsEnabled" action="Disable">
<MenuItem id = "RunInPad"
label = "${res:ICSharpCode.UnitTesting.RunInTestPad}"
icon = "PadIcons.NUnitTest"
class = "ICSharpCode.UnitTesting.RunTestInPadCommand"/>
</Condition>
<Include id = "CommonTestCommands" path = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands"/>
</MenuItem>
</Condition>
</Path>
<Path name = "/SharpDevelop/Pads/ClassBrowser/ClassContextMenu">
<Condition name = "UnitTestable">
<MenuItem id="UnitTestMenu" type="Menu" label="Unit Testing" icon="PadIcons.NUnitTest" insertbefore="MenuBuilder">
<Condition name="UnitCommonTestCommandsEnabled" action="Disable">
<MenuItem id = "RunInPad"
label = "${res:ICSharpCode.UnitTesting.RunInTestPad}"
icon = "PadIcons.NUnitTest"
class = "ICSharpCode.UnitTesting.RunTestInPadCommand"/>
</Condition>
<Include id = "CommonTestCommands" path = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands"/>
</MenuItem>
</Condition>
</Path>
<Path name = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands">
<Condition name="UnitCommonTestCommandsEnabled" action="Disable">
<MenuItem id = "RunWithDebugger"
label = "${res:ICSharpCode.UnitTesting.RunWithDebugger}"
icon = "Icons.16x16.RunProgramIcon"
class = "ICSharpCode.UnitTesting.RunTestWithDebuggerCommand"/>
</Condition>
</Path>
<Path name = "/SharpDevelop/Pads/UnitTestingPad/Toolbar">
<Condition name = "SolutionOpen" action="Disable">
<ToolbarItem id = "Reload"
icon = "Icons.16x16.BrowserRefresh"
tooltip = "${res:NUnitPad.NUnitPadContent.RefreshItem}"
class = "ICSharpCode.UnitTesting.ReloadCommand"/>
<ToolbarItem id = "Unload"
icon = "Icons.16x16.BrowserCancel"
tooltip = "${res:NUnitPad.NUnitPadContent.CancelItem}"
class = "ICSharpCode.UnitTesting.UnloadCommand"/>
<ToolbarItem id = "Separator1" type = "Separator"/>
<!--<ToolbarItem id = "AddMbUnitReference"
icon = "Icons.16x16.Reference"
tooltip = "${res:MbUnitPad.ReferenceItem}"
class = "ICSharpCode.MbUnitPad.AddMbUnitReferenceCommand"/>-->
<ToolbarItem id = "AddNUnitReference"
icon = "Icons.16x16.Reference"
tooltip = "${res:NUnitPad.NUnitPadContent.ReferenceItem}"
class = "ICSharpCode.UnitTesting.AddNUnitReferenceCommand"/>
<ToolbarItem id = "Separator2" type = "Separator"/>
</Condition>
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Not>
<Condition name="UnitRunningTests"/>
</Not>
</And>
<ToolbarItem id = "Run"
icon = "Icons.16x16.RunProgramIcon"
tooltip = "${res:NUnitPad.NUnitPadContent.RunItem}"
class = "ICSharpCode.UnitTesting.RunTestsCommand"/>
</ComplexCondition>
<ComplexCondition action="Disable">
<And>
<Condition name="SolutionOpen"/>
<Condition name="UnitRunningTests"/>
</And>
<ToolbarItem id = "Stop"
icon = "Icons.16x16.Debug.StopProcess"
tooltip = "${res:NUnitPad.NUnitPadContent.StopTests}"
class = "ICSharpCode.UnitTesting.StopTestsCommand"/>
</ComplexCondition>
</Path>
<Path name = "/SharpDevelop/Pads/UnitTestingPad/ContextMenu">
<ComplexCondition action="Disable">
<And>
<Condition name="Ownerstate" ownerstate="TestItemSelected"/>
<Not>
<Condition name="UnitRunningTests"/>
</Not>
</And>
<MenuItem id = "Run"
icon = "Icons.16x16.RunProgramIcon"
label = "${res:NUnitPad.NUnitPadContent.RunTestsContextMenuLabel}"
class = "ICSharpCode.UnitTesting.RunTestsCommand"/>
</ComplexCondition>
<Include id = "CommonTestCommands" path = "/SharpDevelop/Pads/UnitTestingPad/CommonTestCommands"/>
<ComplexCondition action="Disable">
<And>
<Condition name="Ownerstate" ownerstate="TestItemSelected"/>
<Condition name="UnitRunningTests"/>
</And>
<MenuItem id = "Stop"
icon = "Icons.16x16.Debug.StopProcess"
label = "${res:NUnitPad.NUnitPadContent.StopTests}"
class = "ICSharpCode.UnitTesting.StopTestsCommand"/>
</ComplexCondition>
<Condition name="Ownerstate" ownerstate="SourceCodeItemSelected" action="Disable">
<MenuItem id = "GotoDefinition"
label = "${res:NUnitPad.NUnitPadContent.GotoDefinitionContextMenuLabel}"
class = "ICSharpCode.UnitTesting.GotoDefinitionCommand"/>
</Condition>
<!--<MenuItem id="Tree"
label="${res:MainWindow.Windows.UnitTestsTreeView.TreeMenu}"
type="Menu">-->
<MenuItem id="Separator0" type = "Separator"/>
<MenuItem id = "ExpandAll"
label = "${res:MainWindow.Windows.SearchResultPanel.ExpandAll.ToolTip}"
class = "ICSharpCode.UnitTesting.ExpandAllCommand"/>
<MenuItem id = "CollapseAll"
label = "${res:MainWindow.Windows.SearchResultPanel.CollapseAll.ToolTip}"
class = "ICSharpCode.UnitTesting.CollapseAllCommand"/>
<!--
<MenuItem id="Separator1" type = "Separator"/>
<MenuItem id = "ExpandCurrent"
label = "${res:MainWindow.Windows.TreeView.ExpandCurrent}"
class = "ICSharpCode.MbUnitPad.ExpandCurrentCommand"/>
<MenuItem id = "CollapseCurrent"
label = "${res:MainWindow.Windows.TreeView.CollapseCurrent}"
class = "ICSharpCode.MbUnitPad.CollapseCurrentCommand"/>
<MenuItem id="Separator2" type = "Separator"/>
<MenuItem id = "ExpandAllFailures"
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandAllFailures}"
class = "ICSharpCode.MbUnitPad.ExpandAllFailuresCommand"/>
<MenuItem id = "ExpandCurrentFailures"
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandCurrentFailures}"
class = "ICSharpCode.MbUnitPad.ExpandCurrentFailuresCommand"/>
<MenuItem id="Separator3" type = "Separator"/>
<MenuItem id = "ExpandAllIgnored"
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandAllIgnoredTests}"
class = "ICSharpCode.MbUnitPad.ExpandAllIgnoredCommand"/>
<MenuItem id = "ExpandCurrentIgnored"
label = "${res:MainWindow.Windows.UnitTestsTreeView.ExpandCurrentIgnoredTests}"
class = "ICSharpCode.MbUnitPad.ExpandCurrentIgnoredCommand"/>
<MenuItem id="Separator4" type = "Separator"/>
<MenuItem id = "ClearResults"
label = "${res:MainWindow.Windows.UnitTestsTreeView.ClearResults}"
class = "ICSharpCode.MbUnitPad.ClearResultsCommand"/>
</MenuItem>-->
</Path>
</AddIn>

93
src/AddIns/Misc/UnitTesting/UnitTesting.csproj

@ -0,0 +1,93 @@ @@ -0,0 +1,93 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.UnitTesting</RootNamespace>
<AssemblyName>UnitTesting</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1F261725-6318-4434-A1B1-6C70CE4CD324}</ProjectGuid>
<OutputPath>..\..\..\..\AddIns\AddIns\Misc\UnitTesting\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="nunit.uikit">
<HintPath>..\..\..\Tools\NUnit\nunit.uikit.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="nunit.core">
<HintPath>..\..\..\Tools\NUnit\nunit.core.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="nunit.util">
<HintPath>..\..\..\Tools\NUnit\nunit.util.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="UnitTesting.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\UnitTestCommands.cs" />
<Compile Include="Src\TestableCondition.cs" />
<Compile Include="Src\RunningTestsCondition.cs" />
<Compile Include="Src\PadContent.cs" />
<Compile Include="Src\TestTreeView.cs" />
<Compile Include="Src\UnitTestApplicationStartHelper.cs" />
<Compile Include="Src\NUnitResults.cs" />
<Compile Include="Src\RunTestCommands.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project>
<Name>ICSharpCode.TextEditor</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

9
src/Libraries/ICSharpCode.Build.Tasks/Test/ICSharpCode.Build.Tasks.Tests.csproj

@ -37,6 +37,10 @@ @@ -37,6 +37,10 @@
<Reference Include="Microsoft.Build.Utilities, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.Build.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="nunit.framework">
<HintPath>..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CompilerCommandLineTestFixture.cs" />
@ -49,11 +53,6 @@ @@ -49,11 +53,6 @@
<Project>{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}</Project>
<Name>ICSharpCode.Build.Tasks</Name>
</ProjectReference>
<ProjectReference Include="..\..\NUnit.Framework\nunit.framework.dll.csproj">
<Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>
<Name>nunit.framework.dll</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

1
src/Libraries/ICSharpCode.TextEditor/Project/Configuration/AssemblyInfo.cs

@ -22,4 +22,3 @@ using System.Runtime.CompilerServices; @@ -22,4 +22,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("2.0.0.1")]

11
src/Libraries/ICSharpCode.TextEditor/Test/ICSharpCode.TextEditor.Tests.csproj

@ -34,6 +34,12 @@ @@ -34,6 +34,12 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="DocumentTests.cs" />
@ -45,11 +51,6 @@ @@ -45,11 +51,6 @@
<Package>{00000000-0000-0000-0000-000000000000}</Package>
<Name>ICSharpCode.TextEditor</Name>
</ProjectReference>
<ProjectReference Include="..\..\NUnit.Framework\nunit.framework.dll.csproj">
<Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>
<Name>nunit.framework.dll</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>

1
src/Libraries/NRefactory/Project/Configuration/AssemblyInfo.cs

@ -35,4 +35,3 @@ using System.Runtime.CompilerServices; @@ -35,4 +35,3 @@ using System.Runtime.CompilerServices;
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("2.0.0.1")]

9
src/Libraries/NRefactory/Test/NRefactoryTests.csproj

@ -38,6 +38,10 @@ @@ -38,6 +38,10 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="nunit.framework">
<HintPath>..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
@ -145,11 +149,6 @@ @@ -145,11 +149,6 @@
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
<Folder Include="Output\VBNet" />
<ProjectReference Include="..\..\NUnit.Framework\nunit.framework.dll.csproj">
<Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>
<Name>nunit.framework.dll</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>

80
src/Libraries/NUnit.Framework/AbstractAsserter.cs

@ -1,80 +0,0 @@ @@ -1,80 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// AbstractAsserter is the base class for all asserters.
/// Asserters encapsulate a condition test and generation
/// of an AssertionException with a tailored message. They
/// are used by the Assert class as helper objects.
///
/// User-defined asserters may be passed to the
/// Assert.DoAssert method in order to implement
/// extended asserts.
/// </summary>
public abstract class AbstractAsserter : IAsserter
{
/// <summary>
/// The user-defined message for this asserter.
/// </summary>
protected readonly string userMessage;
/// <summary>
/// Arguments to use in formatting the user-defined message.
/// </summary>
protected readonly object[] args;
/// <summary>
/// Our failure message object, initialized as needed
/// </summary>
private AssertionFailureMessage failureMessage;
/// <summary>
/// Constructs an AbstractAsserter
/// </summary>
/// <param name="message">The message issued upon failure</param>
/// <param name="args">Arguments to be used in formatting the message</param>
public AbstractAsserter( string message, params object[] args )
{
this.userMessage = message;
this.args = args;
}
/// <summary>
/// AssertionFailureMessage object used internally
/// </summary>
protected AssertionFailureMessage FailureMessage
{
get
{
if ( failureMessage == null )
failureMessage = new AssertionFailureMessage( userMessage, args );
return failureMessage;
}
}
#region IAsserter Interface
/// <summary>
/// Test method to be implemented by derived types.
/// Default always succeeds.
/// </summary>
/// <returns>True if the test succeeds</returns>
public virtual bool Test()
{
return true;
}
/// <summary>
/// Message related to a failure. If no failure has
/// occured, the result is unspecified.
/// </summary>
public virtual string Message
{
get
{
return FailureMessage.ToString();
}
}
#endregion
}
}

5
src/Libraries/NUnit.Framework/AssemblyInfo.cs

@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
using System;
using System.Reflection;
[assembly: CLSCompliant(true)]

1697
src/Libraries/NUnit.Framework/Assert.cs

File diff suppressed because it is too large Load Diff

190
src/Libraries/NUnit.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/NUnit.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)
{}
}
}

481
src/Libraries/NUnit.Framework/AssertionFailureMessage.cs

@ -1,481 +0,0 @@ @@ -1,481 +0,0 @@
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig, Douglas de la Torre
/************************************************************************************
'
' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
' Copyright 2000-2002 Philip A. Craig
' Copyright 2001 Douglas de la Torre
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' software.
'
' Permission is granted to anyone to use this software for any purpose, including
' commercial applications, and to alter it and redistribute it freely, subject to the
' following restrictions:
'
' 1. The origin of this software must not be misrepresented; you must not claim that
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
' Portions Copyright 2002 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
' Copyright 2000-2002 Philip A. Craig, or Copyright 2001 Douglas de la Torre
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
'
' 3. This notice may not be removed or altered from any source distribution.
'
'***********************************************************************************/
#endregion
using System;
using System.Text;
using System.IO;
using System.Collections;
namespace NUnit.Framework
{
/// <summary>
/// Summary description for AssertionFailureMessage.
/// </summary>
public class AssertionFailureMessage : StringWriter
{
#region Static Constants
/// <summary>
/// Number of characters before a highlighted position before
/// clipping will occur. Clipped text is replaced with an
/// elipsis "..."
/// </summary>
static public readonly int PreClipLength = 35;
/// <summary>
/// Number of characters after a highlighted position before
/// clipping will occur. Clipped text is replaced with an
/// elipsis "..."
/// </summary>
static public readonly int PostClipLength = 35;
/// <summary>
/// Prefix used to start an expected value line.
/// Must be same length as actualPrefix.
/// </summary>
static protected readonly string expectedPrefix = "expected:";
/// <summary>
/// Prefix used to start an actual value line.
/// Must be same length as expectedPrefix.
/// </summary>
static protected readonly string actualPrefix = " but was:";
static private readonly string expectedAndActualFmt = "\t{0} {1}";
static private readonly string diffStringLengthsFmt
= "\tString lengths differ. Expected length={0}, but was length={1}.";
static private readonly string sameStringLengthsFmt
= "\tString lengths are both {0}.";
static private readonly string diffArrayLengthsFmt
= "Array lengths differ. Expected length={0}, but was length={1}.";
static private readonly string sameArrayLengthsFmt
= "Array lengths are both {0}.";
static private readonly string stringsDifferAtIndexFmt
= "\tStrings differ at index {0}.";
static private readonly string arraysDifferAtIndexFmt
= "Arrays differ at index {0}.";
#endregion
#region Constructors
/// <summary>
/// Construct an AssertionFailureMessage with a message
/// and optional arguments.
/// </summary>
/// <param name="message"></param>
/// <param name="args"></param>
public AssertionFailureMessage( string message, params object[] args )
: base( CreateStringBuilder( message, args ) ) { }
/// <summary>
/// Construct an empty AssertionFailureMessage
/// </summary>
public AssertionFailureMessage() : this( null, null ) { }
#endregion
/// <summary>
/// Add text to the message as a new line.
/// </summary>
/// <param name="text">The text to add</param>
public void AddLine( string text )
{
WriteLine();
Write( text );
}
/// <summary>
/// Add formatted text and arguments to the message as a new line.
/// </summary>
/// <param name="fmt">Format string</param>
/// <param name="args">Arguments to use with the format</param>
public void AddLine( string fmt, params object[] args )
{
WriteLine();
Write( fmt, args );
}
/// <summary>
/// Add an expected value line to the message containing
/// the text provided as an argument.
/// </summary>
/// <param name="text">Text describing what was expected.</param>
public void AddExpectedLine( string text )
{
AddLine( string.Format( expectedAndActualFmt, expectedPrefix, text ) );
}
/// <summary>
/// Add an actual value line to the message containing
/// the text provided as an argument.
/// </summary>
/// <param name="text">Text describing the actual value.</param>
public void AddActualLine( string text )
{
AddLine( string.Format( expectedAndActualFmt, actualPrefix, text ) );
}
/// <summary>
/// Add an expected value line to the message containing
/// a string representation of the object provided.
/// </summary>
/// <param name="expected">An object representing the expected value</param>
public void DisplayExpectedValue( object expected )
{
AddExpectedLine( FormatObjectForDisplay( expected ) );
}
/// <summary>
/// Add an actual value limne to the message containing
/// a string representation of the object provided.
/// </summary>
/// <param name="actual">An object representing what was actually found</param>
public void DisplayActualValue( object actual )
{
AddActualLine( FormatObjectForDisplay( actual ) );
}
/// <summary>
/// Display two lines that communicate the expected value, and the actual value
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value found</param>
public void DisplayExpectedAndActual( Object expected, Object actual )
{
DisplayExpectedValue( expected );
DisplayActualValue( actual );
}
/// <summary>
/// Draws a marker under the expected/actual strings that highlights
/// where in the string a mismatch occurred.
/// </summary>
/// <param name="iPosition">The position of the mismatch</param>
public void DisplayPositionMarker( int iPosition )
{
AddLine( "\t{0}^", new String( '-', expectedPrefix.Length + iPosition + 3 ) );
}
/// <summary>
/// Reports whether the string lengths are the same or different, and
/// what the string lengths are.
/// </summary>
/// <param name="sExpected">The expected string</param>
/// <param name="sActual">The actual string value</param>
protected void BuildStringLengthReport( string sExpected, string sActual )
{
if( sExpected.Length != sActual.Length )
AddLine( diffStringLengthsFmt, sExpected.Length, sActual.Length );
else
AddLine( sameStringLengthsFmt, sExpected.Length );
}
/// <summary>
/// Called to create additional message lines when two objects have been
/// found to be unequal. If the inputs are strings, a special message is
/// rendered that can help track down where the strings are different,
/// based on differences in length, or differences in content.
///
/// If the inputs are not strings, the ToString method of the objects
/// is used to show what is different about them.
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="caseInsensitive">True if a case-insensitive comparison is being performed</param>
public void DisplayDifferences( object expected, object actual, bool caseInsensitive )
{
if( InputsAreStrings( expected, actual ) )
{
DisplayStringDifferences(
(string)expected,
(string)actual,
caseInsensitive );
}
else
{
DisplayExpectedAndActual( expected, actual );
}
}
/// <summary>
/// Constructs a message that can be displayed when the content of two
/// strings are different, but the string lengths are the same. The
/// message will clip the strings to a reasonable length, centered
/// around the first position where they are mismatched, and draw
/// a line marking the position of the difference to make comparison
/// quicker.
/// </summary>
/// <param name="sExpected">The expected string value</param>
/// <param name="sActual">The actual string value</param>
/// <param name="caseInsensitive">True if a case-insensitive comparison is being performed</param>
protected void DisplayStringDifferences( string sExpected, string sActual, bool caseInsensitive )
{
//
// If they mismatch at a specified position, report the
// difference.
//
int iPosition = caseInsensitive
? FindMismatchPosition( sExpected.ToLower(), sActual.ToLower(), 0 )
: FindMismatchPosition( sExpected, sActual, 0 );
//
// If the lengths differ, but they match up to the length,
// show the difference just past the length of the shorter
// string
//
if( iPosition == -1 )
iPosition = Math.Min( sExpected.Length, sActual.Length );
BuildStringLengthReport( sExpected, sActual );
AddLine( stringsDifferAtIndexFmt, iPosition );
//
// Clips the strings, then turns any hidden whitespace into visible
// characters
//
string sClippedExpected = ConvertWhitespace(ClipAroundPosition( sExpected, iPosition ));
string sClippedActual = ConvertWhitespace(ClipAroundPosition( sActual, iPosition ));
DisplayExpectedAndActual(
sClippedExpected,
sClippedActual );
// Add a line showing where they differ. If the string lengths are
// different, they start differing just past the length of the
// shorter string
DisplayPositionMarker( caseInsensitive
? FindMismatchPosition( sClippedExpected.ToLower(), sClippedActual.ToLower(), 0 )
: FindMismatchPosition( sClippedExpected, sClippedActual, 0 ) );
}
/// <summary>
/// Display a standard message showing the differences found between
/// two arrays that were expected to be equal.
/// </summary>
/// <param name="expected">The expected array value</param>
/// <param name="actual">The actual array value</param>
/// <param name="index">The index at which a difference was found</param>
public void DisplayArrayDifferences( Array expected, Array actual, int index )
{
if( expected.Length != actual.Length )
AddLine( diffArrayLengthsFmt, expected.Length, actual.Length );
else
AddLine( sameArrayLengthsFmt, expected.Length );
AddLine( arraysDifferAtIndexFmt, index );
if ( index < expected.Length && index < actual.Length )
DisplayDifferences( expected.GetValue( index ), actual.GetValue( index ), false );
else if( expected.Length < actual.Length )
DisplayListElements( " extra:", actual, index, 3 );
else
DisplayListElements( " missing:", expected, index, 3 );
}
/// <summary>
/// Displays elements from a list on a line
/// </summary>
/// <param name="label">Text to prefix the line with</param>
/// <param name="list">The list of items to display</param>
/// <param name="index">The index in the list of the first element to display</param>
/// <param name="max">The maximum number of elements to display</param>
public void DisplayListElements( string label, IList list, int index, int max )
{
AddLine( "{0}<", label );
if ( list == null )
Write( "null" );
else if ( list.Count == 0 )
Write( "empty" );
else
{
for( int i = 0; i < max && index < list.Count; i++ )
{
Write( FormatObjectForDisplay( list[index++] ) );
if ( index < list.Count )
Write( "," );
}
if ( index < list.Count )
Write( "..." );
}
Write( ">" );
}
#region Static Methods
/// <summary>
/// Formats an object for display in a message line
/// </summary>
/// <param name="obj">The object to be displayed</param>
/// <returns></returns>
static protected string FormatObjectForDisplay( object obj )
{
if ( obj == null )
return "<(null)>";
else if ( obj is string )
return string.Format( "<\"{0}\">", obj );
else
return string.Format( "<{0}>", obj );
}
/// <summary>
/// Tests two objects to determine if they are strings.
/// </summary>
/// <param name="expected"></param>
/// <param name="actual"></param>
/// <returns></returns>
static protected bool InputsAreStrings( Object expected, Object actual )
{
return expected != null && actual != null &&
expected is string && actual is string;
}
/// <summary>
/// Used to create a StringBuilder that is used for constructing
/// the output message when text is different. Handles initialization
/// when a message is provided. If message is null, an empty
/// StringBuilder is returned.
/// </summary>
/// <param name="message"></param>
/// <param name="args"></param>
/// <returns></returns>
static protected StringBuilder CreateStringBuilder( string message, params object[] args )
{
if (message != null)
if ( args != null && args.Length > 0 )
return new StringBuilder( string.Format( message, args ) );
else
return new StringBuilder( message );
else
return new StringBuilder();
}
/// <summary>
/// Renders up to M characters before, and up to N characters after
/// the specified index position. If leading or trailing text is
/// clipped, and elipses "..." is added where the missing text would
/// be.
///
/// Clips strings to limit previous or post newline characters,
/// since these mess up the comparison
/// </summary>
/// <param name="sString"></param>
/// <param name="iPosition"></param>
/// <returns></returns>
static protected string ClipAroundPosition( string sString, int iPosition )
{
if( sString == null || sString.Length == 0 )
return "";
bool preClip = iPosition > PreClipLength;
bool postClip = iPosition + PostClipLength < sString.Length;
int start = preClip
? iPosition - PreClipLength : 0;
int length = postClip
? iPosition + PostClipLength - start : sString.Length - start;
if ( start + length > iPosition + PostClipLength )
length = iPosition + PostClipLength - start;
StringBuilder sb = new StringBuilder();
if ( preClip ) sb.Append("...");
sb.Append( sString.Substring( start, length ) );
if ( postClip ) sb.Append("...");
return sb.ToString();
}
/// <summary>
/// Shows the position two strings start to differ. Comparison
/// starts at the start index.
/// </summary>
/// <param name="sExpected"></param>
/// <param name="sActual"></param>
/// <param name="iStart"></param>
/// <returns>-1 if no mismatch found, or the index where mismatch found</returns>
static private int FindMismatchPosition( string sExpected, string sActual, int iStart )
{
int iLength = Math.Min( sExpected.Length, sActual.Length );
for( int i=iStart; i<iLength; i++ )
{
//
// If they mismatch at a specified position, report the
// difference.
//
if( sExpected[i] != sActual[i] )
{
return i;
}
}
//
// Strings have same content up to the length of the shorter string.
// Mismatch occurs because string lengths are different, so show
// that they start differing where the shortest string ends
//
if( sExpected.Length != sActual.Length )
{
return iLength;
}
//
// Same strings
//
Assert.IsTrue( sExpected.Equals( sActual ) );
return -1;
}
/// <summary>
/// Turns CR, LF, or TAB into visual indicator to preserve visual marker
/// position. This is done by replacing the '\r' into '\\' and 'r'
/// characters, and the '\n' into '\\' and 'n' characters, and '\t' into
/// '\\' and 't' characters.
///
/// Thus the single character becomes two characters for display.
/// </summary>
/// <param name="sInput"></param>
/// <returns></returns>
static protected string ConvertWhitespace( string sInput )
{
if( null != sInput )
{
sInput = sInput.Replace( "\r", "\\r" );
sInput = sInput.Replace( "\n", "\\n" );
sInput = sInput.Replace( "\t", "\\t" );
}
return sInput;
}
#endregion
}
}

60
src/Libraries/NUnit.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; }
}
}
}

57
src/Libraries/NUnit.Framework/CommonAssemblyInfo.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.Reflection;
//
// Common Information about all NUnit assemblies is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("NUnit.org")]
[assembly: AssemblyProduct("NUnit")]
[assembly: AssemblyCopyright("Copyright (C) 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole.\r\nCopyright (C) 2000-2003 Philip Craig.\r\nAll Rights Reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("2.2.5.0")]

35
src/Libraries/NUnit.Framework/ComparisonAsserter.cs

@ -1,35 +0,0 @@ @@ -1,35 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// Abstract class used as a base for asserters that compare
/// expected and an actual values in some way or another.
/// </summary>
public abstract class ComparisonAsserter : AbstractAsserter
{
/// <summary>
/// The expected value, used as the basis for comparison.
/// </summary>
protected object expected;
/// <summary>
/// The actual value to be compared.
/// </summary>
protected object actual;
/// <summary>
/// Constructs a ComparisonAsserter for two objects
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public ComparisonAsserter( object expected, object actual, string message, params object[] args )
: base( message, args )
{
this.expected = expected;
this.actual = actual;
}
}
}

186
src/Libraries/NUnit.Framework/ConditionAsserters.cs

@ -1,186 +0,0 @@ @@ -1,186 +0,0 @@
using System;
using System.Collections;
namespace NUnit.Framework
{
#region ConditionAsserter
/// <summary>
/// ConditionAsserter class represents an asssertion
/// that tests a particular condition, which is passed
/// to it in the constructor. The failure message is
/// not specialized in this class, but derived classes
/// are free to do so.
/// </summary>
public class ConditionAsserter : AbstractAsserter
{
/// <summary>
/// The condition we are testing
/// </summary>
protected bool condition;
/// <summary>
/// Phrase indicating what we expected to find
/// Ignored unless set by derived class
/// </summary>
protected string expectation;
/// <summary>
/// Constructor
/// </summary>
/// <param name="condition">The condition to be tested</param>
/// <param name="message">The message issued upon failure</param>
/// <param name="args">Arguments to be used in formatting the message</param>
public ConditionAsserter( bool condition, string message, params object[] args )
: base( message, args )
{
this.condition = condition;
}
/// <summary>
/// Test the condition being asserted directly
/// </summary>
public override bool Test()
{
return condition;
}
}
#endregion
#region TrueAsserter
/// <summary>
/// Class to assert that a condition is true
/// </summary>
public class TrueAsserter : ConditionAsserter
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="condition">The condition to assert</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public TrueAsserter( bool condition, string message, params object[] args )
: base( condition, message, args ) { }
}
#endregion
#region FalseAsserter
/// <summary>
/// Class to assert that a condition is false
/// </summary>
public class FalseAsserter : ConditionAsserter
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="condition">The condition to assert</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public FalseAsserter( bool condition, string message, params object[] args )
: base( !condition, message, args ) { }
}
#endregion
#region NullAsserter
/// <summary>
/// Class to assert that an object is null
/// </summary>
public class NullAsserter : ConditionAsserter
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="anObject">The object to test</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public NullAsserter( object anObject, string message, params object[] args )
: base( anObject == null, message, args ) { }
}
#endregion
#region NotNullAsserter
/// <summary>
/// Class to assert that an object is not null
/// </summary>
public class NotNullAsserter : ConditionAsserter
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="anObject">The object to test</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public NotNullAsserter( object anObject, string message, params object[] args )
: base( anObject != null, message, args ) { }
}
#endregion
#region NaNAsserter
/// <summary>
/// Class to assert that a double is an NaN
/// </summary>
public class NaNAsserter : ConditionAsserter
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="aDouble">The value to test</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public NaNAsserter( double aDouble, string message, params object[] args )
: base( double.IsNaN( aDouble ), message, args ) { }
}
#endregion
#region EmptyAsserter
/// <summary>
/// Class to Assert that a string or collection is empty
/// </summary>
public class EmptyAsserter : ConditionAsserter
{
/// <summary>
/// Construct an EmptyAsserter for a string
/// </summary>
/// <param name="aString">The string to be tested</param>
/// <param name="message">The message to display if the string is not empty</param>
/// <param name="args">Arguements to use in formatting the message</param>
public EmptyAsserter( string aString, string message, params object[] args )
: base( aString == string.Empty, message, args ) { }
/// <summary>
/// Construct an EmptyAsserter for a collection
/// </summary>
/// <param name="collection">The collection to be tested</param>
/// <param name="message">The message to display if the collection is not empty</param>
/// <param name="args">Arguements to use in formatting the message</param>
public EmptyAsserter( ICollection collection, string message, params object[] args )
: base( collection.Count == 0, message, args ) { }
}
#endregion
#region NotEmptyAsserter
/// <summary>
/// Class to Assert that a string or collection is not empty
/// </summary>
public class NotEmptyAsserter : ConditionAsserter
{
/// <summary>
/// Construct a NotEmptyAsserter for a string
/// </summary>
/// <param name="aString">The string to be tested</param>
/// <param name="message">The message to display if the string is empty</param>
/// <param name="args">Arguements to use in formatting the message</param>
public NotEmptyAsserter( string aString, string message, params object[] args )
: base( aString != string.Empty, message, args ) { }
/// <summary>
/// Construct a NotEmptyAsserter for a collection
/// </summary>
/// <param name="collection">The collection to be tested</param>
/// <param name="message">The message to display if the collection is empty</param>
/// <param name="args">Arguements to use in formatting the message</param>
public NotEmptyAsserter( ICollection collection, string message, params object[] args )
: base( collection.Count != 0, message, args ) { }
}
#endregion
}

99
src/Libraries/NUnit.Framework/EqualAsserter.cs

@ -1,99 +0,0 @@ @@ -1,99 +0,0 @@
using System;
using System.Text;
namespace NUnit.Framework
{
/// <summary>
/// Class to assert that two objects are equal
/// </summary>
public class EqualAsserter : EqualityAsserter
{
/// <summary>
/// Constructs an EqualAsserter for two objects
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public EqualAsserter( object expected, object actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Constructs an EqualAsserter for two doubles and a tolerance
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="tolerance">The tolerance used in making the comparison</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public EqualAsserter( double expected, double actual, double tolerance, string message, params object[] args )
: base( expected, actual, tolerance, message, args ) { }
/// <summary>
/// Test whether the objects are equal, building up
/// the failure message for later use if they are not.
/// </summary>
/// <returns>True if the objects are equal</returns>
public override bool Test()
{
if ( expected == null && actual == null ) return true;
if ( expected == null || actual == null )
{
DisplayDifferences();
return false;
}
// For now, dynamically call array assertion if necessary. Try to move
// this into the ObjectsEqual method later on.
if ( expected.GetType().IsArray && actual.GetType().IsArray )
{
Array expectedArray = expected as Array;
Array actualArray = actual as Array;
if ( expectedArray.Rank != actualArray.Rank )
{
DisplayDifferences();
return false;
}
if ( expectedArray.Rank != 1 )
throw new ArgumentException( "Multi-dimension array comparison is not supported" );
int iLength = Math.Min( expectedArray.Length, actualArray.Length );
for( int i = 0; i < iLength; i++ )
if ( !ObjectsEqual( expectedArray.GetValue( i ), actualArray.GetValue( i ) ) )
{
DisplayArrayDifferences( i );
return false;
}
if ( expectedArray.Length != actualArray.Length )
{
DisplayArrayDifferences( iLength );
return false;
}
}
else
{
if ( !ObjectsEqual( expected, actual ) )
{
DisplayDifferences();
return false;
}
}
return true;
}
private void DisplayDifferences()
{
FailureMessage.DisplayDifferences( expected, actual, false );
}
private void DisplayArrayDifferences( int index )
{
FailureMessage.DisplayArrayDifferences( (Array)expected, (Array)actual, index );
}
}
}

152
src/Libraries/NUnit.Framework/EqualityAsserter.cs

@ -1,152 +0,0 @@ @@ -1,152 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// Abstract base class for EqualsAsserter and NotEqualsAsserter
/// </summary>
public abstract class EqualityAsserter : ComparisonAsserter
{
private double delta;
/// <summary>
/// Constructor taking expected and actual values and a user message with arguments.
/// </summary>
/// <param name="expected"></param>
/// <param name="actual"></param>
/// <param name="message"></param>
/// <param name="args"></param>
public EqualityAsserter( object expected, object actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Constructor taking expected and actual values, a tolerance
/// and a user message and arguments.
/// </summary>
/// <param name="expected"></param>
/// <param name="actual"></param>
/// <param name="delta"></param>
/// <param name="message"></param>
/// <param name="args"></param>
public EqualityAsserter( double expected, double actual, double delta, string message, params object[] args )
: base( expected, actual, message, args )
{
this.delta = delta;
}
/// <summary>
/// Used to compare two objects. Two nulls are equal and null
/// is not equal to non-null. Comparisons between the same
/// numeric types are fine (Int32 to Int32, or Int64 to Int64),
/// but the Equals method fails across different types so we
/// use <c>ToString</c> and compare the results.
/// </summary>
/// <param name="expected"></param>
/// <param name="actual"></param>
/// <returns></returns>
protected virtual bool ObjectsEqual( Object expected, Object actual )
{
if ( expected == null && actual == null ) return true;
if ( expected == null || actual == null ) return false;
//if ( expected.GetType().IsArray && actual.GetType().IsArray )
// return ArraysEqual( (System.Array)expected, (System.Array)actual );
if ( expected is double && actual is double )
{
if ( double.IsNaN((double)expected) && double.IsNaN((double)actual) )
return true;
// handle infinity specially since subtracting two infinite values gives
// NaN and the following test fails. mono also needs NaN to be handled
// specially although ms.net could use either method.
if (double.IsInfinity((double)expected) || double.IsNaN((double)expected) || double.IsNaN((double)actual))
return expected.Equals( actual );
else
return Math.Abs((double)expected-(double)actual) <= this.delta;
}
// if ( expected is float && actual is float )
// {
// // handle infinity specially since subtracting two infinite values gives
// // NaN and the following test fails. mono also needs NaN to be handled
// // specially although ms.net could use either method.
// if (float.IsInfinity((float)expected) || float.IsNaN((float)expected) || float.IsNaN((float)actual))
// return (float)expected == (float)actual;
// else
// return Math.Abs((float)expected-(float)actual) <= (float)this.delta;
// }
if ( expected.GetType() != actual.GetType() &&
IsNumericType( expected ) && IsNumericType( actual ) )
{
//
// Convert to strings and compare result to avoid
// issues with different types that have the same
// value
//
string sExpected = expected.ToString();
string sActual = actual.ToString();
return sExpected.Equals( sActual );
}
return expected.Equals(actual);
}
/// <summary>
/// Checks the type of the object, returning true if
/// the object is a numeric type.
/// </summary>
/// <param name="obj">The object to check</param>
/// <returns>true if the object is a numeric type</returns>
private bool IsNumericType( Object obj )
{
if( null != obj )
{
if( obj is byte ) return true;
if( obj is sbyte ) return true;
if( obj is decimal ) return true;
if( obj is double ) return true;
if( obj is float ) return true;
if( obj is int ) return true;
if( obj is uint ) return true;
if( obj is long ) return true;
if( obj is short ) return true;
if( obj is ushort ) return true;
if( obj is System.Byte ) return true;
if( obj is System.SByte ) return true;
if( obj is System.Decimal ) return true;
if( obj is System.Double ) return true;
if( obj is System.Single ) return true;
if( obj is System.Int32 ) return true;
if( obj is System.UInt32 ) return true;
if( obj is System.Int64 ) return true;
if( obj is System.UInt64 ) return true;
if( obj is System.Int16 ) return true;
if( obj is System.UInt16 ) return true;
}
return false;
}
/// <summary>
/// Helper method to compare two arrays
/// </summary>
protected virtual bool ArraysEqual( Array expected, Array actual )
{
if ( expected.Rank != actual.Rank )
return false;
if ( expected.Rank != 1 )
throw new ArgumentException( "Multi-dimension array comparison is not supported" );
int iLength = Math.Min( expected.Length, actual.Length );
for( int i = 0; i < iLength; i++ )
if ( !ObjectsEqual( expected.GetValue( i ), actual.GetValue( i ) ) )
return false;
if ( expected.Length != actual.Length )
return false;
return true;
}
}
}

113
src/Libraries/NUnit.Framework/ExpectedExceptionAttribute.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-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' software.
'
' Permission is granted to anyone to use this software for any purpose, including
' commercial applications, and to alter it and redistribute it freely, subject to the
' following restrictions:
'
' 1. The origin of this software must not be misrepresented; you must not claim that
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
'
' 3. This notice may not be removed or altered from any source distribution.
'
'***********************************************************************************/
#endregion
namespace NUnit.Framework
{
using System;
/// <summary>
/// ExpectedExceptionAttribute
/// </summary>
///
[AttributeUsage(AttributeTargets.Method, AllowMultiple=false)]
public sealed class ExpectedExceptionAttribute : Attribute
{
private Type expectedException;
private string expectedExceptionName;
private string expectedMessage;
/// <summary>
/// Constructor for a given type of exception
/// </summary>
/// <param name="exceptionType">The type of the expected exception</param>
public ExpectedExceptionAttribute(Type exceptionType)
{
this.expectedException = exceptionType;
this.expectedExceptionName = exceptionType.FullName;
}
/// <summary>
/// Constructor for a given exception name
/// </summary>
/// <param name="exceptionName">The full name of the expected exception</param>
public ExpectedExceptionAttribute(string exceptionName)
{
this.expectedExceptionName = exceptionName;
}
/// <summary>
/// Constructor for a given type of exception and expected message text
/// </summary>
/// <param name="exceptionType">The type of the expected exception</param>
/// <param name="expectedMessage">The expected message text</param>
public ExpectedExceptionAttribute(Type exceptionType, string expectedMessage)
{
this.expectedException = exceptionType;
this.expectedMessage = expectedMessage;
}
/// <summary>
/// Constructor for a given exception name and expected message text
/// </summary>
/// <param name="exceptionName">The full name of the expected exception</param>
/// <param name="expectedMessage">The expected messge text</param>
public ExpectedExceptionAttribute(string exceptionName, string expectedMessage)
{
this.expectedExceptionName = exceptionName;
this.expectedMessage = expectedMessage;
}
/// <summary>
/// The expected exception type
/// </summary>
public Type ExceptionType
{
get{ return expectedException; }
set{ expectedException = value; }
}
/// <summary>
/// The full Type name of the expected exception
/// </summary>
public string ExceptionName
{
get{ return expectedExceptionName; }
set{ expectedExceptionName = value; }
}
/// <summary>
/// The expected message
/// </summary>
public string ExpectedMessage
{
get { return expectedMessage; }
set { expectedMessage = value; }
}
}
}

21
src/Libraries/NUnit.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()
{
}
}
}

30
src/Libraries/NUnit.Framework/IAsserter.cs

@ -1,30 +0,0 @@ @@ -1,30 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// The interface implemented by an asserter. Asserters
/// encapsulate a condition test and generation of an
/// AssertionException with a tailored message. They
/// are used by the Assert class as helper objects.
///
/// User-defined asserters may be passed to the
/// Assert.DoAssert method in order to implement
/// extended asserts.
/// </summary>
public interface IAsserter
{
/// <summary>
/// Test the condition for the assertion.
/// </summary>
/// <returns>True if the test succeeds</returns>
bool Test();
/// <summary>
/// Return the message giving the failure reason.
/// The return value is unspecified if no failure
/// has occured.
/// </summary>
string Message { get; }
}
}

67
src/Libraries/NUnit.Framework/IgnoreAttribute.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.Framework
{
using System;
/// <summary>
/// IgnoreAttribute.
/// </summary>
///
[AttributeUsage(AttributeTargets.Method|AttributeTargets.Class, AllowMultiple=false)]
public sealed class IgnoreAttribute : Attribute
{
private string reason;
/// <summary>
/// Default constructor
/// </summary>
public IgnoreAttribute()
{
this.reason = "";
}
/// <summary>
/// Constructor with a reason
/// </summary>
/// <param name="reason">The reason for ignoring the test</param>
public IgnoreAttribute(string reason)
{
this.reason = reason;
}
/// <summary>
/// The reason for ignoring a test
/// </summary>
public string Reason
{
get { return reason; }
}
}
}

68
src/Libraries/NUnit.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)
{}
}
}

52
src/Libraries/NUnit.Framework/ListContentsAsserter.cs

@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
using System;
using System.Collections;
namespace NUnit.Framework
{
/// <summary>
/// ListContentsAsserter implements an assertion that a given
/// item is found in an array or other List.
/// </summary>
public class ListContentsAsserter : AbstractAsserter
{
private object expected;
private IList list;
/// <summary>
/// Constructs a ListContentsAsserter for a particular list and object.
/// </summary>
/// <param name="expected">The expected object</param>
/// <param name="list">The list to be examined</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public ListContentsAsserter( object expected, IList list, string message, params object[] args )
: base( message, args )
{
this.expected = expected;
this.list = list;
}
/// <summary>
/// Test that the object is contained in the list
/// </summary>
/// <returns>True if the object is found</returns>
public override bool Test()
{
return list != null && list.Contains( expected );
}
/// <summary>
/// Error message to display after a failure.
/// </summary>
public override string Message
{
get
{
FailureMessage.DisplayExpectedValue( expected );
FailureMessage.DisplayListElements( "\t but was: ", list, 0, 5 );
return FailureMessage.ToString();
}
}
}
}

35
src/Libraries/NUnit.Framework/NotEqualAsserter.cs

@ -1,35 +0,0 @@ @@ -1,35 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// NotEqualAsserter is the asserter class that handles
/// inequality assertions.
/// </summary>
public class NotEqualAsserter : EqualityAsserter
{
/// <summary>
/// Constructor for NotEqualAsserter
/// </summary>
/// <param name="expected">The expected object</param>
/// <param name="actual">The actual object</param>
/// <param name="message">The message to be printed when the two objects are the same object.</param>
/// <param name="args">Arguments to be used in formatting the message</param>
public NotEqualAsserter( object expected, object actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test that the objects are not equal
/// </summary>
public override bool Test()
{
if ( expected == null && actual == null ) return false;
if ( expected == null || actual == null ) return true;
if ( expected.GetType().IsArray && actual.GetType().IsArray )
return !ArraysEqual( (Array)expected, (Array)actual );
else
return !ObjectsEqual( expected, actual );
}
}
}

40
src/Libraries/NUnit.Framework/NotSameAsserter.cs

@ -1,40 +0,0 @@ @@ -1,40 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// Asserter that verifies two objects are different.
/// </summary>
public class NotSameAsserter : ComparisonAsserter
{
/// <summary>
/// Construct a NotSameAsserter object
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">A user-defined message for use in reporting errors</param>
/// <param name="args">Arguments to be used in formatting the user-defined message</param>
public NotSameAsserter( object expected, object actual, string message, params object[] args)
: base( expected, actual, message, args ) { }
/// <summary>
/// Tests that the objects are not the same
/// </summary>
public override bool Test()
{
return !object.ReferenceEquals( expected, actual );
}
/// <summary>
/// Provides a message in case of failure
/// </summary>
public override string Message
{
get
{
FailureMessage.Write( "expected not same" );
return FailureMessage.ToString();
}
}
}
}

58
src/Libraries/NUnit.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()
{}
}
}

51
src/Libraries/NUnit.Framework/PlatformAttribute.cs

@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// PlatformAttribute is used to mark a test fixture or an
/// individual method as applying to a particular platform only.
/// </summary>
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple=false)]
public sealed class PlatformAttribute : Attribute
{
private string include;
private string exclude;
/// <summary>
/// Constructor with no platforms specified, for use
/// with named property syntax.
/// </summary>
public PlatformAttribute() { }
/// <summary>
/// Constructor taking one or more platforms
/// </summary>
/// <param name="platforms">Comma-deliminted list of platforms</param>
public PlatformAttribute( string platforms )
{
this.include = platforms;
}
/// <summary>
/// Name of the platform that is needed in order for
/// a test to run. Multiple platforms may be given,
/// separated by a comma.
/// </summary>
public string Include
{
get { return this.include; }
set { include = value; }
}
/// <summary>
/// Name of the platform to be excluded. Multiple platforms
/// may be given, separated by a comma.
/// </summary>
public string Exclude
{
get { return this.exclude; }
set { this.exclude = value; }
}
}
}

40
src/Libraries/NUnit.Framework/SameAsserter.cs

@ -1,40 +0,0 @@ @@ -1,40 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// Asserter that verifies two objects are the same.
/// </summary>
public class SameAsserter : ComparisonAsserter
{
/// <summary>
/// Construct a SameAsserter object
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">A user-defined message for use in reporting errors</param>
/// <param name="args">Arguments to be used in formatting the user-defined message</param>
public SameAsserter( object expected, object actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test that actual and expected reference the same object
/// </summary>
public override bool Test()
{
return object.ReferenceEquals( expected, actual );
}
/// <summary>
/// Provide error message when the objects are different.
/// </summary>
public override string Message
{
get
{
FailureMessage.Write( "expected same" );
return FailureMessage.ToString();
}
}
}
}

40
src/Libraries/NUnit.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
{}
}

12
src/Libraries/NUnit.Framework/SetUpFixtureAttribute.cs

@ -1,12 +0,0 @@ @@ -1,12 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// SetUpFixtureAttribute is used to identify a SetUpFixture
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false)]
public sealed class SetUpFixtureAttribute : Attribute
{
}
}

155
src/Libraries/NUnit.Framework/StringAssert.cs

@ -1,155 +0,0 @@ @@ -1,155 +0,0 @@
namespace NUnit.Framework
{
/// <summary>
/// Basic Asserts on strings.
/// </summary>
public class StringAssert
{
#region Contains
/// <summary>
/// Asserts that a string is found within another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments used in formatting the message</param>
static public void Contains( string expected, string actual, string message, params object[] args )
{
Assert.DoAssert( new ContainsAsserter( expected, actual, message, args ) );
}
/// <summary>
/// Asserts that a string is found within another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
static public void Contains( string expected, string actual, string message )
{
Contains( expected, actual, message, null );
}
/// <summary>
/// Asserts that a string is found within another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
static public void Contains( string expected, string actual )
{
Contains( expected, actual, string.Empty, null );
}
#endregion
#region StartsWith
/// <summary>
/// Asserts that a string starts with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments used in formatting the message</param>
static public void StartsWith( string expected, string actual, string message, params object[] args )
{
Assert.DoAssert( new StartsWithAsserter( expected, actual, message, args ) );
}
/// <summary>
/// Asserts that a string starts with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
static public void StartsWith( string expected, string actual, string message )
{
StartsWith( expected, actual, message, null );
}
/// <summary>
/// Asserts that a string starts with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
static public void StartsWith( string expected, string actual )
{
StartsWith( expected, actual, string.Empty, null );
}
#endregion
#region EndsWith
/// <summary>
/// Asserts that a string ends with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments used in formatting the message</param>
static public void EndsWith( string expected, string actual, string message, params object[] args )
{
Assert.DoAssert( new EndsWithAsserter( expected, actual, message, args ) );
}
/// <summary>
/// Asserts that a string ends with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
/// <param name="message">The message to display in case of failure</param>
static public void EndsWith( string expected, string actual, string message )
{
EndsWith( expected, actual, message, null );
}
/// <summary>
/// Asserts that a string ends with another string.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The string to be examined</param>
static public void EndsWith( string expected, string actual )
{
EndsWith( expected, actual, string.Empty, null );
}
#endregion
#region AreEqualIgnoringCase
/// <summary>
/// Asserts that two strings are equal, without regard to case.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The actual string</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments used in formatting the message</param>
static public void AreEqualIgnoringCase( string expected, string actual, string message, params object[] args )
{
Assert.DoAssert( new EqualIgnoringCaseAsserter( expected, actual, message, args ) );
}
/// <summary>
/// Asserts that two strings are equal, without regard to case.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The actual string</param>
/// <param name="message">The message to display in case of failure</param>
static public void AreEqualIgnoringCase( string expected, string actual, string message )
{
AreEqualIgnoringCase( expected, actual, message, null );
}
/// <summary>
/// Asserts that two strings are equal, without regard to case.
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The actual string</param>
static public void AreEqualIgnoringCase( string expected, string actual )
{
AreEqualIgnoringCase( expected, actual, string.Empty, null );
}
#endregion
}
}

204
src/Libraries/NUnit.Framework/StringAsserters.cs

@ -1,204 +0,0 @@ @@ -1,204 +0,0 @@
using System;
namespace NUnit.Framework
{
#region StringAsserter
/// <summary>
/// Abstract class used as a base for asserters that compare
/// expected and an actual string values in some way or another.
/// </summary>
public abstract class StringAsserter : AbstractAsserter
{
/// <summary>
/// The expected value, used as the basis for comparison.
/// </summary>
protected string expected;
/// <summary>
/// The actual value to be compared.
/// </summary>
protected string actual;
/// <summary>
/// Constructs a StringAsserter for two strings
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public StringAsserter( string expected, string actual, string message, params object[] args )
: base( message, args )
{
this.expected = expected;
this.actual = actual;
}
/// <summary>
/// Message related to a failure. If no failure has
/// occured, the result is unspecified.
/// </summary>
public override string Message
{
get
{
FailureMessage.AddExpectedLine( Expectation );
FailureMessage.DisplayActualValue( actual );
return FailureMessage.ToString();
}
}
/// <summary>
/// String value that represents what the asserter expected
/// to find. Defaults to the expected value itself.
/// </summary>
protected virtual string Expectation
{
get { return string.Format( "<\"{0}\">", expected ); }
}
}
#endregion
#region ContainsAsserter
/// <summary>
/// Summary description for ContainsAsserter.
/// </summary>
public class ContainsAsserter : StringAsserter
{
/// <summary>
/// Constructs a ContainsAsserter for two strings
/// </summary>
/// <param name="expected">The expected substring</param>
/// <param name="actual">The actual string to be examined</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public ContainsAsserter( string expected, string actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test the assertion.
/// </summary>
/// <returns>True if the test succeeds</returns>
public override bool Test()
{
return actual.IndexOf( expected ) >= 0;
}
/// <summary>
/// String value that represents what the asserter expected
/// </summary>
protected override string Expectation
{
get { return string.Format( "String containing \"{0}\"", expected ); }
}
}
#endregion
#region StartsWithAsserter
/// <summary>
/// Summary description for StartsWithAsserter.
/// </summary>
public class StartsWithAsserter : StringAsserter
{
/// <summary>
/// Constructs a StartsWithAsserter for two strings
/// </summary>
/// <param name="expected">The expected substring</param>
/// <param name="actual">The actual string to be examined</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public StartsWithAsserter( string expected, string actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test the assertion.
/// </summary>
/// <returns>True if the test succeeds</returns>
public override bool Test()
{
return actual.StartsWith( expected );
}
/// <summary>
/// String value that represents what the asserter expected
/// </summary>
protected override string Expectation
{
get { return string.Format( "String starting with \"{0}\"", expected ); }
}
}
#endregion
#region EndsWithAsserter
/// <summary>
/// Summary description for EndsWithAsserter.
/// </summary>
public class EndsWithAsserter : StringAsserter
{
/// <summary>
/// Constructs a EndsWithAsserter for two strings
/// </summary>
/// <param name="expected">The expected substring</param>
/// <param name="actual">The actual string to be examined</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public EndsWithAsserter( string expected, string actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test the assertion.
/// </summary>
/// <returns>True if the test succeeds</returns>
public override bool Test()
{
return actual.EndsWith( expected );
}
/// <summary>
/// String value that represents what the asserter expected
/// </summary>
protected override string Expectation
{
get { return string.Format( "String ending with \"{0}\"", expected ); }
}
}
#endregion
#region EqualIgnoringCaseAsserter
/// <summary>
/// Asserter that implements AreEqualIgnoringCase
/// </summary>
public class EqualIgnoringCaseAsserter : StringAsserter
{
/// <summary>
/// Constructs an EqualIgnoringCaseAsserter for two strings
/// </summary>
/// <param name="expected">The expected string</param>
/// <param name="actual">The actual string</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public EqualIgnoringCaseAsserter( string expected, string actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test the assertion.
/// </summary>
/// <returns>True if the test succeeds</returns>
public override bool Test()
{
return string.Compare( expected, actual, true ) == 0;
}
/// <summary>
/// String value that represents what the asserter expected
/// </summary>
public override string Message
{
get
{
FailureMessage.DisplayDifferences( expected, actual, true );
return FailureMessage.ToString();
}
}
}
#endregion
}

40
src/Libraries/NUnit.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/NUnit.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/NUnit.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/NUnit.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/NUnit.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/NUnit.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
{
}
}

208
src/Libraries/NUnit.Framework/TypeAsserters.cs

@ -1,208 +0,0 @@ @@ -1,208 +0,0 @@
using System;
namespace NUnit.Framework
{
#region TypeAsserter
/// <summary>
/// The abstract asserter from which all specific type asserters
/// will inherit from in order to limit code-reproduction.
/// </summary>
public abstract class TypeAsserter : AbstractAsserter
{
/// <summary>
/// The expected Type
/// </summary>
protected System.Type expected;
/// <summary>
/// The actual object to be compared
/// </summary>
protected object actual;
/// <summary>
/// Construct a TypeAsserter
/// </summary>
/// <param name="expected">The expected Type</param>
/// <param name="actual">The object to be examined</param>
/// <param name="message">A message to display on failure</param>
/// <param name="args">Arguments to be used in formatting the message</param>
public TypeAsserter( System.Type expected, object actual, string message, params object[] args )
: base( message, args )
{
this.expected = expected;
this.actual = actual;
}
/// <summary>
/// The complete message text in case of a failure.
/// </summary>
public override string Message
{
get
{
FailureMessage.AddExpectedLine( Expectation );
FailureMessage.AddActualLine( actual.GetType().ToString() );
return FailureMessage.ToString();
}
}
/// <summary>
/// A string representing what was expected. Used as a part of the message text.
/// </summary>
protected virtual string Expectation
{
get { return expected.ToString(); }
}
}
#endregion
#region AssignableFromAsserter
/// <summary>
/// Class to Assert that an object may be assigned from a given Type.
/// </summary>
public class AssignableFromAsserter : TypeAsserter
{
/// <summary>
/// Construct an AssignableFromAsserter
/// </summary>
/// <param name="expected">The expected Type</param>
/// <param name="actual">The object being examined</param>
/// <param name="message">A message to display in case of failure</param>
/// <param name="args">Arguments for use in formatting the message</param>
public AssignableFromAsserter( System.Type expected, object actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test the object to determine if it can be assigned from the expected Type
/// </summary>
/// <returns>True if the object is assignable</returns>
public override bool Test()
{
return actual.GetType().IsAssignableFrom(expected);
}
/// <summary>
/// A string representing what was expected. Used as a part of the message text.
/// </summary>
protected override string Expectation
{
get { return string.Format( "Type assignable from {0}", expected ); }
}
}
#endregion
#region NotAssignableFromAsserter
/// <summary>
/// Class to Assert that an object may not be assigned from a given Type.
/// </summary>
public class NotAssignableFromAsserter : TypeAsserter
{
/// <summary>
/// Construct a NotAssignableFromAsserter
/// </summary>
/// <param name="expected">The expected Type</param>
/// <param name="actual">The object to be examined</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments to use in formatting the message</param>
public NotAssignableFromAsserter( System.Type expected, object actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test the object to determine if it can be assigned from the expected Type
/// </summary>
/// <returns>True if the object is not assignable</returns>
public override bool Test()
{
return !actual.GetType().IsAssignableFrom(expected);
}
/// <summary>
/// A string representing what was expected. Used as a part of the message text.
/// </summary>
protected override string Expectation
{
get { return string.Format( "Type not assignable from {0}", expected ); }
}
}
#endregion
#region InstanceOfTypeAsserter
/// <summary>
/// Class to Assert that an object is an instance of a given Type.
/// </summary>
public class InstanceOfTypeAsserter : TypeAsserter
{
/// <summary>
/// Construct an InstanceOfTypeAsserter
/// </summary>
/// <param name="expected">The expected Type</param>
/// <param name="actual">The object to be examined</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments to use in formatting the message</param>
public InstanceOfTypeAsserter( System.Type expected, object actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test the object to determine if it is an instance of the expected Type
/// </summary>
/// <returns>True if the object is an instance of the expected Type</returns>
public override bool Test()
{
return expected.IsInstanceOfType( actual );
}
/// <summary>
/// A string representing what was expected. Used as a part of the message text.
/// </summary>
protected override string Expectation
{
get
{
return string.Format( "Object to be instance of {0}", expected );
}
}
}
#endregion
#region NotInstanceOfTypeAsserter
/// <summary>
/// Class to Assert that an object is not an instance of a given Type.
/// </summary>
public class NotInstanceOfTypeAsserter : TypeAsserter
{
/// <summary>
/// Construct a NotInstanceOfTypeAsserter
/// </summary>
/// <param name="expected">The expected Type</param>
/// <param name="actual">The object to be examined</param>
/// <param name="message">The message to display in case of failure</param>
/// <param name="args">Arguments to use in formatting the message</param>
public NotInstanceOfTypeAsserter( System.Type expected, object actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test the object to determine if it is an instance of the expected Type
/// </summary>
/// <returns>True if the object is not an instance of the expected Type</returns>
public override bool Test()
{
return !expected.IsInstanceOfType( actual );
}
/// <summary>
/// A string representing what was expected. Used as a part of the message text.
/// </summary>
protected override string Expectation
{
get
{
return string.Format( "Object not an instance of {0}", expected );
}
}
}
#endregion
}

42
src/Libraries/NUnit.Framework/greaterasserter.cs

@ -1,42 +0,0 @@ @@ -1,42 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// Class to assert that the actual value is greater than the expected value.
/// </summary>
public class GreaterAsserter : ComparisonAsserter
{
/// <summary>
/// Constructs a GreaterAsserter for two objects implementing IComparable
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public GreaterAsserter( IComparable expected, IComparable actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test whether the actual is greater than the expected, building up
/// the failure message for later use if they are not.
/// </summary>
/// <returns>True if actual is greater than expected</returns>
public override bool Test()
{
if ( ((IComparable)actual).CompareTo(expected) > 0 ) return true;
DisplayDifferences();
return false;
}
private void DisplayDifferences()
{
FailureMessage.AddExpectedLine( string.Format( "Value greater than {0}", expected ) );
FailureMessage.AddActualLine(actual.ToString());
}
}
}

41
src/Libraries/NUnit.Framework/lessasserter.cs

@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
using System;
namespace NUnit.Framework
{
/// <summary>
/// Class to assert that the actual value is greater than the expected value.
/// </summary>
public class LessAsserter : ComparisonAsserter
{
/// <summary>
/// Constructs a GreaterAsserter for two objects implementing IComparable
/// </summary>
/// <param name="expected">The expected value</param>
/// <param name="actual">The actual value</param>
/// <param name="message">The message to issue on failure</param>
/// <param name="args">Arguments to apply in formatting the message</param>
public LessAsserter( IComparable expected, IComparable actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
/// <summary>
/// Test whether the actual is greater than the expected, building up
/// the failure message for later use if they are not.
/// </summary>
/// <returns>True if actual is greater than expected</returns>
public override bool Test()
{
if ( ((IComparable)expected).CompareTo(actual) < 0 ) return true;
DisplayDifferences();
return false;
}
private void DisplayDifferences()
{
FailureMessage.AddExpectedLine( string.Format( "Value less than {0}", expected ) );
FailureMessage.AddActualLine(actual.ToString());
}
}
}

31
src/Libraries/NUnit.Framework/nunit.framework.build

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
<?xml version="1.0"?>
<project name="NUnit.Framework" default="build">
<include buildfile="../../nunit.project.include"/>
<property name="current.build.output" value="nunit.framework"/>
<target name="build" depends="make-build-dir">
<csc target="library"
output="${current.build.dir}/nunit.framework.dll"
debug="${build.debug}"
define="${build.defines.csc},StronglyNamedAssembly"
nowarn="618,672">
<sources basedir=".">
<include name="*.cs"/>
<include name="../../CommonAssemblyInfo.cs"/>
</sources>
</csc>
</target>
<target name="package">
<copy todir="${package.src.dir}/NUnitFramework/framework">
<fileset basedir=".">
<include name="*.csproj"/>
<include name="*.build"/>
<include name="*.snk"/>
<include name="*.cs"/>
</fileset>
</copy>
</target>
</project>

145
src/Libraries/NUnit.Framework/nunit.framework.dll.csproj

@ -1,145 +0,0 @@ @@ -1,145 +0,0 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<AssemblyName>nunit.framework</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<RootNamespace>NUnit.Framework</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<SignAssembly>true</SignAssembly>
<OutputPath>..\..\..\bin\</OutputPath>
<AssemblyOriginatorKeyFile>nunit.key</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release2005|AnyCPU' ">
<DefineConstants>TRACE;VS2005</DefineConstants>
<BaseAddress>285212672</BaseAddress>
<DocumentationFile>nunit.framework.xml</DocumentationFile>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug2005|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DefineConstants>TRACE;DEBUG;VS2005</DefineConstants>
<BaseAddress>285212672</BaseAddress>
<DocumentationFile>nunit.framework.xml</DocumentationFile>
<NoWarn>1701;1702;1699</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<Name>System</Name>
</Reference>
<Reference Include="System.Data">
<Name>System.Data</Name>
</Reference>
<Reference Include="System.Xml">
<Name>System.XML</Name>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CommonAssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AbstractAsserter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Assert.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Assertion.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AssertionException.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AssertionFailureMessage.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="CategoryAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ComparisonAsserter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ConditionAsserters.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="EqualAsserter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="EqualityAsserter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ExpectedExceptionAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ExplicitAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GreaterAsserter.cs" />
<Compile Include="IAsserter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IgnoreAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IgnoreException.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LessAsserter.cs" />
<Compile Include="ListContentsAsserter.cs" />
<Compile Include="NotEqualAsserter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="NotSameAsserter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="OldTestCase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PlatformAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SameAsserter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SetUpAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SetUpFixtureAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="StringAssert.cs" />
<Compile Include="StringAsserters.cs" />
<Compile Include="SuiteAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="TearDownAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="TestAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="TestFixtureAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="TestFixtureSetUpAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="TestFixtureTearDownAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="TypeAsserters.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

BIN
src/Libraries/NUnit.Framework/nunit.key

Binary file not shown.

1
src/Main/Base/Project/Configuration/AssemblyInfo.cs

@ -23,4 +23,3 @@ using System.Runtime.CompilerServices; @@ -23,4 +23,3 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("2.0.0.1")]

20
src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/CompilerMessageView.cs

@ -31,12 +31,23 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -31,12 +31,23 @@ namespace ICSharpCode.SharpDevelop.Gui
{
static CompilerMessageView instance;
/// <summary>
/// Gets the instance of the CompilerMessageView. This property is thread-safe, but
/// most instance methods of the CompilerMessageView aren't.
/// </summary>
public static CompilerMessageView Instance {
get {
if (instance == null)
WorkbenchSingleton.SafeThreadCall((MethodInvoker)InitializeInstance);
return instance;
}
}
static void InitializeInstance()
{
WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).CreatePad();
}
//TextEditorControl textEditorControl = new TextEditorControl();
RichTextBox textEditorControl = new RichTextBox();
Panel myPanel = new Panel();
@ -158,8 +169,15 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -158,8 +169,15 @@ namespace ICSharpCode.SharpDevelop.Gui
}
#region Category handling
/// <summary>
/// Adds a category to the compiler message view. This method is thread-safe.
/// </summary>
public void AddCategory(MessageViewCategory category)
{
if (WorkbenchSingleton.InvokeRequired) {
WorkbenchSingleton.SafeThreadAsyncCall((Action<MessageViewCategory>)AddCategory, category);
return;
}
messageCategories.Add(category);
category.Cleared += new EventHandler(CategoryTextCleared);
category.TextSet += new TextEventHandler(CategoryTextSet);
@ -304,8 +322,6 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -304,8 +322,6 @@ namespace ICSharpCode.SharpDevelop.Gui
}
#endregion
delegate void StringDelegate(string text);
/// <summary>
/// Makes this pad visible (usually BEFORE build or debug events)
/// </summary>

9
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs

@ -47,14 +47,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -47,14 +47,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{
public static void AddProject(ISolutionFolderNode solutionFolderNode, string fileName)
{
IProject newProject;
ILanguageBinding binding = LanguageBindingService.GetBindingPerProjectFile(fileName);
if (binding != null) {
newProject = binding.LoadProject(fileName, Path.GetFileNameWithoutExtension(fileName));
} else {
newProject = new UnknownProject(fileName);
newProject.IdGuid = "{" + Guid.NewGuid().ToString() + "}";
}
IProject newProject = LanguageBindingService.LoadProject(fileName, Path.GetFileNameWithoutExtension(fileName));
newProject.Location = FileUtility.GetRelativePath(solutionFolderNode.Solution.Directory, fileName);
ParserService.CreateProjectContentForAddedProject(newProject);
solutionFolderNode.Container.AddFolder(newProject);

6
src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs

@ -116,6 +116,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -116,6 +116,9 @@ namespace ICSharpCode.SharpDevelop.Gui
public object Call(Delegate method, object[] arguments)
{
if (method == null) {
throw new ArgumentNullException("method");
}
return ctl.Invoke(method, arguments);
}
@ -134,6 +137,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -134,6 +137,9 @@ namespace ICSharpCode.SharpDevelop.Gui
public void BeginCall(Delegate method, object[] arguments)
{
if (method == null) {
throw new ArgumentNullException("method");
}
ctl.BeginInvoke(method, arguments);
}

4
src/Main/Base/Project/Src/Internal/Doozers/PadDescriptor.cs

@ -93,6 +93,10 @@ namespace ICSharpCode.Core @@ -93,6 +93,10 @@ namespace ICSharpCode.Core
public void CreatePad()
{
#if DEBUG
if (WorkbenchSingleton.InvokeRequired)
throw new InvalidOperationException("This action could trigger pad creation and is only valid on the main thread!");
#endif
if (!padContentCreated) {
padContentCreated = true;
padContent = (IPadContent)codon.AddIn.CreateObject(Class);

3
src/Main/Base/Project/Src/Project/Converter/PrjxToSolutionProject.cs

@ -259,8 +259,7 @@ namespace ICSharpCode.SharpDevelop.Project.Converter @@ -259,8 +259,7 @@ namespace ICSharpCode.SharpDevelop.Project.Converter
RunConverter(fileName, convertedFileName + ".user", "CSharp_prjx2csproj_user.xsl", conversion);
ILanguageBinding binding = LanguageBindingService.GetBindingPerProjectFile(convertedFileName);
return binding.LoadProject(convertedFileName, Conversion.GetProjectName(fileName));
return LanguageBindingService.LoadProject(convertedFileName, Conversion.GetProjectName(fileName));
}
public static void ConvertVSNetProject(string fileName)

14
src/Main/Base/Project/Src/Project/Solution/Solution.cs

@ -439,19 +439,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -439,19 +439,7 @@ namespace ICSharpCode.SharpDevelop.Project
SolutionFolder newFolder = SolutionFolder.ReadFolder(sr, title, location, guid);
newSolution.AddFolder(newFolder);
} else {
IProject newProject;
if (!File.Exists(location)) {
newProject = new MissingProject(location);
newProject.TypeGuid = projectGuid;
} else {
ILanguageBinding binding = LanguageBindingService.GetBindingPerProjectFile(location);
if (binding != null) {
newProject = binding.LoadProject(location, title);
} else {
newProject = new UnknownProject(location);
newProject.TypeGuid = projectGuid;
}
}
IProject newProject = LanguageBindingService.LoadProject(location, title, projectGuid);
newProject.IdGuid = guid;
newSolution.AddFolder(newProject);
}

29
src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingService.cs

@ -75,6 +75,35 @@ namespace ICSharpCode.Core @@ -75,6 +75,35 @@ namespace ICSharpCode.Core
return null;
}
public static IProject LoadProject(string location, string title)
{
return LoadProject(location, title, "{" + new Guid().ToString() + "}");
}
public static IProject LoadProject(string location, string title, string projectTypeGuid)
{
IProject newProject;
if (!File.Exists(location)) {
newProject = new MissingProject(location);
newProject.TypeGuid = projectTypeGuid;
} else {
ILanguageBinding binding = LanguageBindingService.GetBindingPerProjectFile(location);
if (binding != null) {
try {
newProject = binding.LoadProject(location, title);
} catch (XmlException ex) {
MessageService.ShowError("Error loading " + location + ":\n" + ex.Message);
newProject = new UnknownProject(location);
newProject.TypeGuid = projectTypeGuid;
}
} else {
newProject = new UnknownProject(location);
newProject.TypeGuid = projectTypeGuid;
}
}
return newProject;
}
static LanguageBindingService()
{
try {

7
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -109,7 +109,12 @@ namespace ICSharpCode.Core @@ -109,7 +109,12 @@ namespace ICSharpCode.Core
if (loadSolutionProjectsThread != null) {
if (!abortLoadSolutionProjectsThread)
throw new InvalidOperationException("Cannot open new combine without closing old combine!");
loadSolutionProjectsThread.Join();
if (!loadSolutionProjectsThread.Join(50)) {
// loadSolutionProjects might be waiting for main thread, so give it
// a chance to complete asynchronous calls
WorkbenchSingleton.SafeThreadAsyncCall((ThreadStart)OnSolutionLoaded);
return;
}
}
loadSolutionProjectsThread = new Thread(new ThreadStart(LoadSolutionProjects));
loadSolutionProjectsThread.Priority = ThreadPriority.BelowNormal;

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

Loading…
Cancel
Save