Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1057 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
71 changed files with 5587 additions and 3 deletions
After Width: | Height: | Size: 580 B |
After Width: | Height: | Size: 619 B |
After Width: | Height: | Size: 167 B |
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||
# SharpDevelop 2.0.0.960 |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "Project\CodeCoverage.csproj", "{B7F1A068-01F5-49E7-83EF-05DE281B09FD}" |
||||
EndProject |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage.Tests", "Test\CodeCoverage.Tests.csproj", "{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}" |
||||
EndProject |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MbUnitPad", "..\MbUnitPad\Project\MbUnitPad.csproj", "{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}" |
||||
EndProject |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" |
||||
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}") = "WinFormsUI", "..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj", "{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}" |
||||
EndProject |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" |
||||
EndProject |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" |
||||
EndProject |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" |
||||
EndProject |
||||
Global |
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
Debug|Any CPU = Debug|Any CPU |
||||
Release|Any CPU = Release|Any CPU |
||||
EndGlobalSection |
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
{B7F1A068-01F5-49E7-83EF-05DE281B09FD}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{B7F1A068-01F5-49E7-83EF-05DE281B09FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{B7F1A068-01F5-49E7-83EF-05DE281B09FD}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{B7F1A068-01F5-49E7-83EF-05DE281B09FD}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
{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 |
||||
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
{83DD7E12-A705-4DBA-9D71-09C8973D9382}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{83DD7E12-A705-4DBA-9D71-09C8973D9382}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{83DD7E12-A705-4DBA-9D71-09C8973D9382}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{83DD7E12-A705-4DBA-9D71-09C8973D9382}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
{F6A02431-167E-4347-BC43-65532C31CDB7}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{F6A02431-167E-4347-BC43-65532C31CDB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{F6A02431-167E-4347-BC43-65532C31CDB7}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{F6A02431-167E-4347-BC43-65532C31CDB7}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
EndGlobalSection |
||||
EndGlobal |
@ -0,0 +1,106 @@
@@ -0,0 +1,106 @@
|
||||
<AddIn name = "CodeCoverageAddIn" |
||||
author = "Matt Ward" |
||||
url = "http://ncover.org" |
||||
description = "Code Coverage AddIn for SharpDevelop using NCover"> |
||||
|
||||
<Manifest> |
||||
<Identity name = "ICSharpCode.CodeCoverage"/> |
||||
<Dependency addin = "ICSharpCode.MbUnitPad"/> |
||||
</Manifest> |
||||
|
||||
<Runtime> |
||||
<Import assembly = "CodeCoverage.dll"/> |
||||
<Import assembly = "MbUnitPad.dll"/> |
||||
</Runtime> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/Pads"> |
||||
<Pad id = "CodeCoveragePad" |
||||
category = "Tools" |
||||
title = "Code Coverage" |
||||
insertafter = "Bookmarks" |
||||
insertbefore = "DefinitionView" |
||||
icon = "CodeCoverage.Icons.16x16.Pad" |
||||
class = "ICSharpCode.CodeCoverage.CodeCoveragePad"/> |
||||
</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> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions"> |
||||
<DialogPanel id = "CodeCoverageOptionsPanel" |
||||
label = "Code Coverage" |
||||
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"> |
||||
<MenuItem id = "RunWithCodeCoverage" |
||||
insertafter = "RunWithDebugger" |
||||
label = "Run with code coverage" |
||||
icon = "CodeCoverage.Icons.16x16.Run" |
||||
class = "ICSharpCode.CodeCoverage.RunTestWithCodeCoverageCommand"/> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
<Path path = "/SharpDevelop/BackendBindings/ProjectOptions/C#"> |
||||
<DialogPanel id = "CodeCoverage" |
||||
label = "Code Coverage" |
||||
insertafter = "Publish" |
||||
class = "ICSharpCode.CodeCoverage.CodeCoverageProjectOptionsPanel"/> |
||||
</Path> |
||||
</AddIn> |
@ -0,0 +1,111 @@
@@ -0,0 +1,111 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.CodeCoverage</RootNamespace> |
||||
<AssemblyName>CodeCoverage</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{B7F1A068-01F5-49E7-83EF-05DE281B09FD}</ProjectGuid> |
||||
<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' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\CodeCoverage\</OutputPath> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\CodeCoverage\</OutputPath> |
||||
<Optimize>True</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<DebugSymbols>false</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Src\CodeCoverageControl.cs" /> |
||||
<Compile Include="Src\CodeCoveragePad.cs" /> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\CodeCoverageModule.cs" /> |
||||
<Compile Include="Src\CodeCoverageResults.cs" /> |
||||
<Compile Include="Src\CodeCoverageMethod.cs" /> |
||||
<Compile Include="Src\CodeCoverageSequencePoint.cs" /> |
||||
<Compile Include="Src\CodeCoverageTreeView.cs" /> |
||||
<Compile Include="Src\CodeCoverageModuleTreeNode.cs" /> |
||||
<Compile Include="Src\CodeCoverageTreeNode.cs" /> |
||||
<Compile Include="Src\CodeCoverageMethodTreeNode.cs" /> |
||||
<Compile Include="Src\CodeCoverageClassTreeNode.cs" /> |
||||
<Compile Include="Src\CodeCoverageNamespaceTreeNode.cs" /> |
||||
<Compile Include="Src\ToggleCodeCoverageCommand.cs" /> |
||||
<Compile Include="Src\CodeCoverageHighlighter.cs" /> |
||||
<Compile Include="Src\CodeCoverageTextMarker.cs" /> |
||||
<Compile Include="Src\CodeCoverageOptions.cs" /> |
||||
<Compile Include="Src\CodeCoverageOptionsPanel.cs" /> |
||||
<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" /> |
||||
<Compile Include="Src\NCoverRunner.cs" /> |
||||
<Compile Include="Src\NCoverRunnerSingleton.cs" /> |
||||
<Compile Include="Src\NCoverExitEventArgs.cs" /> |
||||
<Compile Include="Src\LineReceivedEventArgs.cs" /> |
||||
<Compile Include="Src\CodeCoverageException.cs" /> |
||||
<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"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
</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> |
||||
<ProjectReference Include="..\..\MbUnitPad\Project\MbUnitPad.csproj"> |
||||
<Project>{B1CE28A0-04E8-490D-8256-E0C4D52C93C8}</Project> |
||||
<Name>MbUnitPad</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<Content Include="PostBuildEvent.proj" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<Import Project="PostBuildEvent.proj" /> |
||||
</Project> |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
// <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; |
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("CodeCoverage AddIn")] |
||||
[assembly: AssemblyDescription("CodeCoverage AddIn for SharpDevelop 2.0")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("ic#code")] |
||||
[assembly: AssemblyProduct("SharpDevelop")] |
||||
[assembly: AssemblyCopyright("2005-2006 AlphaSierraPapa")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all values by your own or you can build default build and revision
|
||||
// numbers with the '*' character (the default):
|
||||
|
||||
[assembly: AssemblyVersion("2.0.0.1")] |
||||
|
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<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 |
||||
loaded twice by SharpDevelop --> |
||||
<Delete Files="$(OutputPath)\MbUnitPad.addin" ContinueOnError="True"/> |
||||
</Target> |
||||
</Project> |
@ -0,0 +1,142 @@
@@ -0,0 +1,142 @@
|
||||
<Components version="1.0"> |
||||
<System.Windows.Forms.UserControl> |
||||
<Name value="CodeCoverageOptionsPanel" /> |
||||
<Text value="CodeCoverageOptionsPanel" /> |
||||
<ClientSize value="{Width=351, Height=281}" /> |
||||
<Controls> |
||||
<System.Windows.Forms.GroupBox> |
||||
<Name value="codeCoverageColoursGroupBox" /> |
||||
<Location value="{X=10,Y=85}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="Code Coverage Colours" /> |
||||
<Anchor value="Top, Left, Right" /> |
||||
<Size value="{Width=333, Height=159}" /> |
||||
<TabIndex value="1" /> |
||||
<Controls> |
||||
<ICSharpCode.CodeCoverage.ColorPickerComboBox> |
||||
<Name value="backgroundColorPickerComboBox" /> |
||||
<Size value="{Width=116, Height=22}" /> |
||||
<TabIndex value="6" /> |
||||
<SelectedColor value="Color [Black]" /> |
||||
<DrawMode value="OwnerDrawFixed" /> |
||||
<FormattingEnabled value="True" /> |
||||
<DropDownStyle value="DropDownList" /> |
||||
<Location value="{X=177,Y=91}" /> |
||||
<Anchor value="Top, Left, Right" /> |
||||
</ICSharpCode.CodeCoverage.ColorPickerComboBox> |
||||
<ICSharpCode.CodeCoverage.ColorPickerComboBox> |
||||
<Name value="foregroundColorPickerComboBox" /> |
||||
<Size value="{Width=116, Height=22}" /> |
||||
<TabIndex value="3" /> |
||||
<SelectedColor value="Color [Black]" /> |
||||
<DrawMode value="OwnerDrawFixed" /> |
||||
<FormattingEnabled value="True" /> |
||||
<DropDownStyle value="DropDownList" /> |
||||
<Location value="{X=179,Y=44}" /> |
||||
<Anchor value="Top, Left, Right" /> |
||||
</ICSharpCode.CodeCoverage.ColorPickerComboBox> |
||||
<System.Windows.Forms.Label> |
||||
<Name value="sampleTextLabel" /> |
||||
<Location value="{X=6,Y=117}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="AaBbCcXxYyZz" /> |
||||
<Anchor value="Top, Bottom, Left, Right" /> |
||||
<TextAlign value="MiddleCenter" /> |
||||
<Size value="{Width=321, Height=39}" /> |
||||
<TabIndex value="8" /> |
||||
</System.Windows.Forms.Label> |
||||
<System.Windows.Forms.ListBox> |
||||
<Name value="displayItemsListBox" /> |
||||
<Size value="{Width=164, Height=69}" /> |
||||
<TabIndex value="1" /> |
||||
<FormattingEnabled value="True" /> |
||||
<Location value="{X=6,Y=44}" /> |
||||
</System.Windows.Forms.ListBox> |
||||
<System.Windows.Forms.Label> |
||||
<Name value="displayItemsLabel" /> |
||||
<Location value="{X=6,Y=29}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="&Display Items:" /> |
||||
<Size value="{Width=107, Height=21}" /> |
||||
<TabIndex value="0" /> |
||||
</System.Windows.Forms.Label> |
||||
<System.Windows.Forms.Button> |
||||
<Name value="backgroundCustomColourButton" /> |
||||
<Location value="{X=299,Y=91}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="..." /> |
||||
<Anchor value="Top, Right" /> |
||||
<UseVisualStyleBackColor value="True" /> |
||||
<Size value="{Width=28, Height=22}" /> |
||||
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" /> |
||||
<TabIndex value="7" /> |
||||
</System.Windows.Forms.Button> |
||||
<System.Windows.Forms.Label> |
||||
<Name value="itemBackgroundColourLabel" /> |
||||
<Location value="{X=176,Y=73}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="Item bac&kground:" /> |
||||
<Size value="{Width=116, Height=21}" /> |
||||
<TabIndex value="5" /> |
||||
</System.Windows.Forms.Label> |
||||
<System.Windows.Forms.Button> |
||||
<Name value="foregroundCustomColourButton" /> |
||||
<Location value="{X=299,Y=44}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="..." /> |
||||
<Anchor value="Top, Right" /> |
||||
<UseVisualStyleBackColor value="True" /> |
||||
<Size value="{Width=28, Height=22}" /> |
||||
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" /> |
||||
<TabIndex value="4" /> |
||||
</System.Windows.Forms.Button> |
||||
<System.Windows.Forms.Label> |
||||
<Name value="itemForegroundColourLabel" /> |
||||
<Location value="{X=176,Y=29}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="Item fo&reground:" /> |
||||
<Size value="{Width=117, Height=22}" /> |
||||
<TabIndex value="2" /> |
||||
</System.Windows.Forms.Label> |
||||
</Controls> |
||||
</System.Windows.Forms.GroupBox> |
||||
<System.Windows.Forms.GroupBox> |
||||
<Name value="configurationGroupBox" /> |
||||
<Location value="{X=10,Y=7}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="NCover Configuration" /> |
||||
<Anchor value="Top, Left, Right" /> |
||||
<Size value="{Width=334, Height=72}" /> |
||||
<TabIndex value="0" /> |
||||
<Controls> |
||||
<System.Windows.Forms.Button> |
||||
<Name value="browseButton" /> |
||||
<Location value="{X=299,Y=24}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="..." /> |
||||
<Anchor value="Top, Right" /> |
||||
<UseVisualStyleBackColor value="True" /> |
||||
<Size value="{Width=30, Height=21}" /> |
||||
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" /> |
||||
<TabIndex value="2" /> |
||||
</System.Windows.Forms.Button> |
||||
<System.Windows.Forms.TextBox> |
||||
<Name value="commandTextBox" /> |
||||
<TabIndex value="1" /> |
||||
<Size value="{Width=187, Height=21}" /> |
||||
<Location value="{X=106,Y=24}" /> |
||||
<Anchor value="Top, Left, Right" /> |
||||
</System.Windows.Forms.TextBox> |
||||
<System.Windows.Forms.Label> |
||||
<Name value="commandLabel" /> |
||||
<Location value="{X=6,Y=24}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="&Command:" /> |
||||
<Size value="{Width=103, Height=26}" /> |
||||
<TabIndex value="0" /> |
||||
</System.Windows.Forms.Label> |
||||
</Controls> |
||||
</System.Windows.Forms.GroupBox> |
||||
</Controls> |
||||
</System.Windows.Forms.UserControl> |
||||
</Components> |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
<Components version="1.0"> |
||||
<System.Windows.Forms.UserControl> |
||||
<Name value="CodeCoverageProjectOptionsPanel" /> |
||||
<ClientSize value="{Width=342, Height=266}" /> |
||||
<Controls> |
||||
<System.Windows.Forms.TextBox> |
||||
<Name value="assemblyListTextBox" /> |
||||
<TabIndex value="1" /> |
||||
<Size value="{Width=317, Height=21}" /> |
||||
<Location value="{X=12,Y=36}" /> |
||||
<Anchor value="Top, Left, Right" /> |
||||
</System.Windows.Forms.TextBox> |
||||
<System.Windows.Forms.Label> |
||||
<Name value="assemblyListLabel" /> |
||||
<Location value="{X=12,Y=12}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="&Assemblies to watch:" /> |
||||
<Size value="{Width=114, Height=21}" /> |
||||
<TabIndex value="0" /> |
||||
</System.Windows.Forms.Label> |
||||
</Controls> |
||||
</System.Windows.Forms.UserControl> |
||||
</Components> |
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
<Components version="1.0"> |
||||
<System.Windows.Forms.Form> |
||||
<Name value="CodeCoverageRunnerNotFoundForm" /> |
||||
<FormBorderStyle value="SizableToolWindow" /> |
||||
<AcceptButton value="okButton [System.Windows.Forms.Button], Text: OK" /> |
||||
<MinimizeBox value="False" /> |
||||
<StartPosition value="CenterParent" /> |
||||
<MinimumSize value="{Width=365, Height=147}" /> |
||||
<Text value="SharpDevelop" /> |
||||
<MaximizeBox value="False" /> |
||||
<ClientSize value="{Width=357, Height=121}" /> |
||||
<CancelButton value="okButton [System.Windows.Forms.Button], Text: OK" /> |
||||
<Controls> |
||||
<System.Windows.Forms.PictureBox> |
||||
<Name value="iconPictureBox" /> |
||||
<Location value="{X=10,Y=11}" /> |
||||
<Size value="{Width=32, Height=32}" /> |
||||
</System.Windows.Forms.PictureBox> |
||||
<System.Windows.Forms.Button> |
||||
<Name value="okButton" /> |
||||
<DialogResult value="OK" /> |
||||
<Location value="{X=142,Y=82}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Text value="OK" /> |
||||
<Anchor value="Bottom" /> |
||||
<UseVisualStyleBackColor value="True" /> |
||||
<Size value="{Width=73, Height=29}" /> |
||||
<FlatAppearance value="System.Windows.Forms.FlatButtonAppearance" /> |
||||
<TabIndex value="1" /> |
||||
</System.Windows.Forms.Button> |
||||
<System.Windows.Forms.LinkLabel> |
||||
<Name value="linkLabel" /> |
||||
<Size value="{Width=93, Height=26}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<TabIndex value="1" /> |
||||
<Text value="NCover.org" /> |
||||
<Location value="{X=12,Y=86}" /> |
||||
<Anchor value="Bottom, Left" /> |
||||
</System.Windows.Forms.LinkLabel> |
||||
<System.Windows.Forms.Label> |
||||
<Name value="messageLabel" /> |
||||
<Location value="{X=48,Y=11}" /> |
||||
<UseCompatibleTextRendering value="True" /> |
||||
<Anchor value="Top, Bottom, Left, Right" /> |
||||
<Size value="{Width=302, Height=68}" /> |
||||
<TabIndex value="2" /> |
||||
</System.Windows.Forms.Label> |
||||
</Controls> |
||||
</System.Windows.Forms.Form> |
||||
</Components> |
@ -0,0 +1,287 @@
@@ -0,0 +1,287 @@
|
||||
// <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); |
||||
} |
||||
|
||||
// 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 mbunitResultsFileName = Path.Combine(ncoverOutputDirectory, "mbunit.xml"); |
||||
DisplayMbUnitResults(mbunitResultsFileName); |
||||
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(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// <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 System; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageClassTreeNode : CodeCoverageTreeNode |
||||
{ |
||||
public CodeCoverageClassTreeNode(string name) : base(name) |
||||
{ |
||||
ImageIndex = ClassBrowserIconService.ClassIndex; |
||||
SelectedImageIndex = ImageIndex; |
||||
} |
||||
|
||||
public override void ActivateItem() |
||||
{ |
||||
if (Nodes.Count > 0) { |
||||
CodeCoverageMethodTreeNode methodNode = (CodeCoverageMethodTreeNode)Nodes[0]; |
||||
if (methodNode.Method.SequencePoints.Count > 0) { |
||||
FileService.OpenFile(methodNode.Method.SequencePoints[0].Document); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,158 @@
@@ -0,0 +1,158 @@
|
||||
// <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 System; |
||||
using System.Collections.Generic; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageControl : UserControl |
||||
{ |
||||
CodeCoverageTreeView treeView; |
||||
ListView listView; |
||||
SplitContainer splitContainer; |
||||
ColumnHeader visitCountColumnHeader; |
||||
ColumnHeader startLineColumnHeader; |
||||
ColumnHeader endLineColumnHeader; |
||||
ColumnHeader startColumnColumnHeader; |
||||
ColumnHeader endColumnColumnHeader; |
||||
ToolStrip toolStrip; |
||||
|
||||
public CodeCoverageControl() |
||||
{ |
||||
// TreeView
|
||||
treeView = new CodeCoverageTreeView(); |
||||
treeView.Dock = DockStyle.Fill; |
||||
treeView.ImageList = ClassBrowserIconService.ImageList; |
||||
treeView.AfterSelect += CodeCoverageTreeViewAfterSelect; |
||||
|
||||
// ListView
|
||||
listView = new ListView(); |
||||
listView.View = View.Details; |
||||
listView.Dock = DockStyle.Fill; |
||||
listView.FullRowSelect = true; |
||||
listView.HideSelection = false; |
||||
listView.ItemActivate += ListViewItemActivate; |
||||
|
||||
visitCountColumnHeader = new ColumnHeader(); |
||||
visitCountColumnHeader.Text = "Visit Count"; |
||||
visitCountColumnHeader.Width = 80; |
||||
|
||||
startLineColumnHeader = new ColumnHeader(); |
||||
startLineColumnHeader.Text = "Line"; |
||||
startLineColumnHeader.Width = 80; |
||||
|
||||
startColumnColumnHeader = new ColumnHeader(); |
||||
startColumnColumnHeader.Text = "Column"; |
||||
startColumnColumnHeader.Width = 80; |
||||
|
||||
endLineColumnHeader = new ColumnHeader(); |
||||
endLineColumnHeader.Text = "End Line"; |
||||
endLineColumnHeader.Width = 80; |
||||
|
||||
endColumnColumnHeader = new ColumnHeader(); |
||||
endColumnColumnHeader.Text = "End Column"; |
||||
endColumnColumnHeader.Width = 80; |
||||
|
||||
listView.Columns.AddRange(new ColumnHeader[] {visitCountColumnHeader, |
||||
startLineColumnHeader, |
||||
startColumnColumnHeader, |
||||
endLineColumnHeader, |
||||
endColumnColumnHeader}); |
||||
|
||||
// SplitContainer.
|
||||
splitContainer = new SplitContainer(); |
||||
splitContainer.SplitterWidth = 2; |
||||
splitContainer.Dock = DockStyle.Fill; |
||||
splitContainer.Panel1.Controls.Add(treeView); |
||||
splitContainer.Panel2.Controls.Add(listView); |
||||
|
||||
Controls.Add(splitContainer); |
||||
|
||||
// Toolstrip
|
||||
toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/CodeCoveragePad/Toolbar"); |
||||
toolStrip.GripStyle = ToolStripGripStyle.Hidden; |
||||
Controls.Add(toolStrip); |
||||
} |
||||
|
||||
public void UpdateToolbar() |
||||
{ |
||||
ToolbarService.UpdateToolbar(toolStrip); |
||||
toolStrip.Refresh(); |
||||
} |
||||
|
||||
public void AddModules(List<CodeCoverageModule> modules) |
||||
{ |
||||
LoggingService.Debug("AddModules..."); |
||||
treeView.AddModules(modules); |
||||
} |
||||
|
||||
public void Clear() |
||||
{ |
||||
treeView.Clear(); |
||||
listView.Items.Clear(); |
||||
} |
||||
|
||||
void CodeCoverageTreeViewAfterSelect(object sender, TreeViewEventArgs e) |
||||
{ |
||||
UpdateListView((CodeCoverageTreeNode)e.Node); |
||||
} |
||||
|
||||
void UpdateListView(CodeCoverageTreeNode node) |
||||
{ |
||||
listView.BeginUpdate(); |
||||
try { |
||||
listView.Items.Clear(); |
||||
if (node is CodeCoverageClassTreeNode) { |
||||
AddClass((CodeCoverageClassTreeNode)node); |
||||
} else if (node is CodeCoverageMethodTreeNode) { |
||||
AddMethod((CodeCoverageMethodTreeNode)node); |
||||
} |
||||
} finally { |
||||
listView.EndUpdate(); |
||||
} |
||||
} |
||||
|
||||
void AddClass(CodeCoverageClassTreeNode node) |
||||
{ |
||||
foreach (CodeCoverageMethodTreeNode method in node.Nodes) { |
||||
AddMethod(method); |
||||
} |
||||
} |
||||
|
||||
void AddMethod(CodeCoverageMethodTreeNode node) |
||||
{ |
||||
foreach (CodeCoverageSequencePoint sequencePoint in node.Method.SequencePoints) { |
||||
AddSequencePoint(sequencePoint); |
||||
} |
||||
} |
||||
|
||||
void AddSequencePoint(CodeCoverageSequencePoint sequencePoint) |
||||
{ |
||||
ListViewItem item = new ListViewItem(sequencePoint.VisitCount.ToString()); |
||||
item.SubItems.Add(sequencePoint.Line.ToString()); |
||||
item.SubItems.Add(sequencePoint.Column.ToString()); |
||||
item.SubItems.Add(sequencePoint.EndLine.ToString()); |
||||
item.SubItems.Add(sequencePoint.EndColumn.ToString()); |
||||
item.Tag = sequencePoint; |
||||
|
||||
listView.Items.Add(item); |
||||
} |
||||
|
||||
void ListViewItemActivate(object sender, EventArgs e) |
||||
{ |
||||
if (listView.SelectedItems.Count > 0) { |
||||
CodeCoverageSequencePoint sequencePoint = (CodeCoverageSequencePoint)listView.SelectedItems[0].Tag; |
||||
if (sequencePoint.Document.Length > 0) { |
||||
FileService.JumpToFilePosition(sequencePoint.Document, sequencePoint.Line - 1, sequencePoint.Column - 1); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
// <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.Drawing; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a code coverage display item that can have its colour customised
|
||||
/// (e.g. Visited code and Not visited code.
|
||||
/// </summary>
|
||||
public class CodeCoverageDisplayItem |
||||
{ |
||||
string item = String.Empty; |
||||
string itemBackColorPropertyName = String.Empty; |
||||
string itemForeColorPropertyName = String.Empty; |
||||
Color backColor; |
||||
Color foreColor; |
||||
bool changed; |
||||
|
||||
public CodeCoverageDisplayItem(string item, string itemBackColorPropertyName, Color backColor, string itemForeColorPropertyName, Color foreColor) |
||||
{ |
||||
this.item = item; |
||||
this.backColor = backColor; |
||||
this.foreColor = foreColor; |
||||
this.itemBackColorPropertyName = itemBackColorPropertyName; |
||||
this.itemForeColorPropertyName = itemForeColorPropertyName; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether any of the colours has changed from their origina values.
|
||||
/// </summary>
|
||||
public bool HasChanged { |
||||
get { |
||||
return changed; |
||||
} |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return item; |
||||
} |
||||
|
||||
public string BackColorPropertyName { |
||||
get { |
||||
return itemBackColorPropertyName; |
||||
} |
||||
} |
||||
|
||||
public Color BackColor { |
||||
get { |
||||
return backColor; |
||||
} |
||||
set { |
||||
if (backColor != value) { |
||||
backColor = value; |
||||
changed = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public string ForeColorPropertyName { |
||||
get { |
||||
return itemForeColorPropertyName; |
||||
} |
||||
} |
||||
|
||||
public Color ForeColor { |
||||
get { |
||||
return foreColor; |
||||
} |
||||
set { |
||||
if (foreColor != null) { |
||||
foreColor = value; |
||||
changed = true; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// The exception that is thrown when a non-fatal
|
||||
/// error occurs in the code coverage add-in.
|
||||
/// </summary>
|
||||
public class CodeCoverageException : ApplicationException |
||||
{ |
||||
public CodeCoverageException() |
||||
{ |
||||
} |
||||
|
||||
public CodeCoverageException(string message) |
||||
: base(message) |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,107 @@
@@ -0,0 +1,107 @@
|
||||
// <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.TextEditor.Document; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Highlights the covered and not covered code in the text editor.
|
||||
/// </summary>
|
||||
public class CodeCoverageHighlighter |
||||
{ |
||||
public CodeCoverageHighlighter() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds text markers for the code coverage sequence points.
|
||||
/// </summary>
|
||||
/// <remarks>The sequence points are added to the marker strategy even
|
||||
/// if they are not all for the same document.</remarks>
|
||||
public void AddMarkers(MarkerStrategy markerStrategy, List<CodeCoverageSequencePoint> sequencePoints) |
||||
{ |
||||
foreach (CodeCoverageSequencePoint sequencePoint in sequencePoints) { |
||||
AddMarker(markerStrategy, sequencePoint); |
||||
} |
||||
} |
||||
|
||||
public void AddMarker(MarkerStrategy markerStrategy, CodeCoverageSequencePoint sequencePoint) |
||||
{ |
||||
if (!IsValidSequencePoint(markerStrategy.Document, sequencePoint)) { |
||||
return; |
||||
} |
||||
|
||||
if (sequencePoint.EndLine == sequencePoint.Line) { |
||||
LineSegment lineSegment = markerStrategy.Document.GetLineSegment(sequencePoint.Line - 1); |
||||
markerStrategy.AddMarker(new CodeCoverageTextMarker(lineSegment.Offset + sequencePoint.Column, sequencePoint)); |
||||
} else { |
||||
// Sequence point spread across lines.
|
||||
for (int line = sequencePoint.Line; line <= sequencePoint.EndLine; ++line) { |
||||
LineSegment lineSegment = markerStrategy.Document.GetLineSegment(line - 1); |
||||
if (line == sequencePoint.Line) { |
||||
// First line.
|
||||
markerStrategy.AddMarker(new CodeCoverageTextMarker(lineSegment.Offset + sequencePoint.Column, lineSegment.Length - (lineSegment.DelimiterLength - 1) - sequencePoint.Column, sequencePoint)); |
||||
} else if (line == sequencePoint.EndLine) { |
||||
// Last line.
|
||||
markerStrategy.AddMarker(new CodeCoverageTextMarker(lineSegment.Offset, sequencePoint.EndColumn - 1, sequencePoint)); |
||||
} else { |
||||
markerStrategy.AddMarker(new CodeCoverageTextMarker(lineSegment.Offset, lineSegment.Length - (lineSegment.DelimiterLength - 1), sequencePoint)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes all CodeCoverageMarkers from the marker strategy.
|
||||
/// </summary>
|
||||
public void RemoveMarkers(MarkerStrategy markerStrategy) |
||||
{ |
||||
markerStrategy.RemoveAll(IsCodeCoverageTextMarkerMatch); |
||||
} |
||||
|
||||
bool IsCodeCoverageTextMarkerMatch(TextMarker marker) |
||||
{ |
||||
if (marker is CodeCoverageTextMarker) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Checks whether the sequence point can be added to the document.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Checks for invalid start lines, start columns, end columns and end
|
||||
/// lines that cannot fit in the document.</remarks>
|
||||
bool IsValidSequencePoint(IDocument document, CodeCoverageSequencePoint sequencePoint) |
||||
{ |
||||
if (sequencePoint.Line <= 0 || sequencePoint.EndLine <= 0 || sequencePoint.Column <= 0 || sequencePoint.EndColumn <= 0) { |
||||
return false; |
||||
} else if (sequencePoint.Line > document.TotalNumberOfLines) { |
||||
return false; |
||||
} else if (sequencePoint.EndLine > document.TotalNumberOfLines) { |
||||
return false; |
||||
} else if (sequencePoint.Line == sequencePoint.EndLine && sequencePoint.Column > sequencePoint.EndColumn) { |
||||
return false; |
||||
} else { |
||||
// Check the columns exist on the line.
|
||||
LineSegment lineSegment = document.GetLineSegment(sequencePoint.Line - 1); |
||||
if (sequencePoint.Column > lineSegment.Length) { |
||||
return false; |
||||
} |
||||
LineSegment endLineSegment = document.GetLineSegment(sequencePoint.EndLine - 1); |
||||
if (sequencePoint.EndColumn > endLineSegment.Length + 1) { |
||||
return false; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
// <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 System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageMethod |
||||
{ |
||||
string name = String.Empty; |
||||
string className = String.Empty; |
||||
string fullClassName = String.Empty; |
||||
string classNamespace = String.Empty; |
||||
List<CodeCoverageSequencePoint> sequencePoints = new List<CodeCoverageSequencePoint>(); |
||||
|
||||
public CodeCoverageMethod(string name, string className) |
||||
{ |
||||
this.name = name; |
||||
this.fullClassName = className; |
||||
|
||||
int index = fullClassName.LastIndexOf('.'); |
||||
this.classNamespace = fullClassName.Substring(0, index); |
||||
|
||||
index = fullClassName.LastIndexOf('.'); |
||||
if (index > 0) { |
||||
this.className = fullClassName.Substring(index + 1); |
||||
} else { |
||||
this.className = fullClassName; |
||||
} |
||||
} |
||||
|
||||
public string Name { |
||||
get { |
||||
return name; |
||||
} |
||||
} |
||||
|
||||
public string ClassName { |
||||
get { |
||||
return className; |
||||
} |
||||
} |
||||
|
||||
public string FullClassName { |
||||
get { |
||||
return fullClassName; |
||||
} |
||||
} |
||||
|
||||
public string ClassNamespace { |
||||
get { |
||||
return classNamespace; |
||||
} |
||||
} |
||||
|
||||
public List<CodeCoverageSequencePoint> SequencePoints { |
||||
get { |
||||
return sequencePoints; |
||||
} |
||||
} |
||||
|
||||
public int VisitedSequencePointsCount { |
||||
get { |
||||
int count = 0; |
||||
foreach (CodeCoverageSequencePoint sequencePoint in sequencePoints) { |
||||
if (sequencePoint.VisitCount > 0) { |
||||
count++; |
||||
} |
||||
} |
||||
return count; |
||||
} |
||||
} |
||||
|
||||
public int NotVisitedSequencePointsCount { |
||||
get { |
||||
int count = 0; |
||||
foreach (CodeCoverageSequencePoint sequencePoint in sequencePoints) { |
||||
if (sequencePoint.VisitCount == 0) { |
||||
count++; |
||||
} |
||||
} |
||||
return count; |
||||
} |
||||
} |
||||
|
||||
public List<CodeCoverageSequencePoint> GetSequencePoints(string fileName) |
||||
{ |
||||
List<CodeCoverageSequencePoint> matchedSequencePoints = new List<CodeCoverageSequencePoint>(); |
||||
foreach (CodeCoverageSequencePoint sequencePoint in sequencePoints) { |
||||
if (FileUtility.IsEqualFileName(fileName, sequencePoint.Document)) { |
||||
matchedSequencePoints.Add(sequencePoint); |
||||
} |
||||
} |
||||
return matchedSequencePoints; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageMethodTreeNode : CodeCoverageTreeNode |
||||
{ |
||||
CodeCoverageMethod method; |
||||
|
||||
public CodeCoverageMethodTreeNode(CodeCoverageMethod method) : base(method.Name, method.VisitedSequencePointsCount, method.NotVisitedSequencePointsCount) |
||||
{ |
||||
ImageIndex = ClassBrowserIconService.MethodIndex; |
||||
SelectedImageIndex = ImageIndex; |
||||
this.method = method; |
||||
} |
||||
|
||||
public CodeCoverageMethod Method { |
||||
get { |
||||
return method; |
||||
} |
||||
} |
||||
|
||||
public override void ActivateItem() |
||||
{ |
||||
if (method != null && method.SequencePoints.Count > 0) { |
||||
CodeCoverageSequencePoint firstSequencePoint = method.SequencePoints[0]; |
||||
int line = firstSequencePoint.Line; |
||||
int column = firstSequencePoint.Column; |
||||
|
||||
for (int i = 1; i < method.SequencePoints.Count; ++i) { |
||||
CodeCoverageSequencePoint sequencePoint = method.SequencePoints[0]; |
||||
if (line > sequencePoint.Line) { |
||||
line = sequencePoint.Line; |
||||
column = sequencePoint.Column; |
||||
} |
||||
} |
||||
|
||||
FileService.JumpToFilePosition(firstSequencePoint.Document, line - 1, column - 1); |
||||
|
||||
} else if (Parent != null) { |
||||
((ExtTreeNode)Parent).ActivateItem(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageModule |
||||
{ |
||||
string name = String.Empty; |
||||
List<CodeCoverageMethod> methods = new List<CodeCoverageMethod>(); |
||||
|
||||
public CodeCoverageModule(string name) |
||||
{ |
||||
this.name = name; |
||||
} |
||||
|
||||
public string Name { |
||||
get { |
||||
return name; |
||||
} |
||||
} |
||||
|
||||
public List<CodeCoverageMethod> Methods { |
||||
get { |
||||
return methods; |
||||
} |
||||
} |
||||
|
||||
public int VisitedSequencePointsCount { |
||||
get { |
||||
int count = 0; |
||||
foreach (CodeCoverageMethod method in methods) { |
||||
count += method.VisitedSequencePointsCount; |
||||
} |
||||
return count; |
||||
} |
||||
} |
||||
|
||||
public int NotVisitedSequencePointsCount { |
||||
get { |
||||
int count = 0; |
||||
foreach (CodeCoverageMethod method in methods) { |
||||
count += method.NotVisitedSequencePointsCount; |
||||
} |
||||
return count; |
||||
} |
||||
} |
||||
|
||||
public List<CodeCoverageSequencePoint> GetSequencePoints(string fileName) |
||||
{ |
||||
List<CodeCoverageSequencePoint> sequencePoints = new List<CodeCoverageSequencePoint>(); |
||||
foreach (CodeCoverageMethod method in methods) { |
||||
sequencePoints.AddRange(method.GetSequencePoints(fileName)); |
||||
} |
||||
return sequencePoints; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,126 @@
@@ -0,0 +1,126 @@
|
||||
// <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.Collections.Generic; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageModuleTreeNode : CodeCoverageTreeNode |
||||
{ |
||||
public CodeCoverageModuleTreeNode(CodeCoverageModule module) : base(module.Name, module.VisitedSequencePointsCount, module.NotVisitedSequencePointsCount) |
||||
{ |
||||
ImageIndex = 2; |
||||
SelectedImageIndex = ImageIndex; |
||||
|
||||
foreach (CodeCoverageMethod method in module.Methods) { |
||||
AddMethod(method); |
||||
} |
||||
|
||||
// Update percentage totals for namespace nodes.
|
||||
UpdateNamespacePercentages(Nodes); |
||||
} |
||||
|
||||
void AddMethod(CodeCoverageMethod method) |
||||
{ |
||||
ExtTreeNode parentNode = GetParentNamespaceNode(method.ClassNamespace); |
||||
|
||||
// Add class node.
|
||||
ExtTreeNode classNode = FindNode(parentNode.Nodes, method.ClassName); |
||||
if (classNode == null) { |
||||
classNode = new CodeCoverageClassTreeNode(method.ClassName); |
||||
classNode.AddTo(parentNode); |
||||
} |
||||
|
||||
// Add method node.
|
||||
CodeCoverageMethodTreeNode methodNode = new CodeCoverageMethodTreeNode(method); |
||||
methodNode.AddTo(classNode); |
||||
} |
||||
|
||||
ExtTreeNode GetParentNamespaceNode(string classNamespace) |
||||
{ |
||||
string[] treePath = classNamespace.Split('.'); |
||||
|
||||
ExtTreeNode node = this; |
||||
ExtTreeNode currentNode = node; |
||||
|
||||
foreach (string path in treePath) { |
||||
if (currentNode != null) { |
||||
currentNode = FindNode(currentNode.Nodes, path); |
||||
} |
||||
|
||||
if (currentNode == null) { |
||||
CodeCoverageNamespaceTreeNode newNode = new CodeCoverageNamespaceTreeNode(path); |
||||
newNode.AddTo(node); |
||||
node = newNode; |
||||
} else { |
||||
node = currentNode; |
||||
} |
||||
} |
||||
|
||||
return node; |
||||
} |
||||
|
||||
ExtTreeNode FindNode(TreeNodeCollection nodes, string name) |
||||
{ |
||||
foreach (ExtTreeNode node in nodes) { |
||||
if (node.Text == name) { |
||||
return node; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
void UpdateNamespacePercentages(TreeNodeCollection nodes) |
||||
{ |
||||
foreach (ExtTreeNode node in nodes) { |
||||
CodeCoverageNamespaceTreeNode namespaceNode = node as CodeCoverageNamespaceTreeNode; |
||||
if (namespaceNode != null) { |
||||
SumVisits(namespaceNode); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void SumVisits(CodeCoverageNamespaceTreeNode parentNode) |
||||
{ |
||||
int visitedCount = 0; |
||||
int notVisitedCount = 0; |
||||
|
||||
foreach (CodeCoverageTreeNode node in parentNode.Nodes) { |
||||
CodeCoverageNamespaceTreeNode namespaceNode = node as CodeCoverageNamespaceTreeNode; |
||||
CodeCoverageClassTreeNode classNode = node as CodeCoverageClassTreeNode; |
||||
if (namespaceNode != null) { |
||||
SumVisits(namespaceNode); |
||||
} else if (classNode != null) { |
||||
SumVisits(classNode); |
||||
} |
||||
|
||||
visitedCount += node.VisitedCount; |
||||
notVisitedCount += node.NotVisitedCount; |
||||
} |
||||
|
||||
parentNode.VisitedCount = visitedCount; |
||||
parentNode.NotVisitedCount = notVisitedCount; |
||||
} |
||||
|
||||
void SumVisits(CodeCoverageClassTreeNode parentNode) |
||||
{ |
||||
int visitedCount = 0; |
||||
int notVisitedCount = 0; |
||||
|
||||
foreach (CodeCoverageTreeNode node in parentNode.Nodes) { |
||||
visitedCount += node.VisitedCount; |
||||
notVisitedCount += node.NotVisitedCount; |
||||
} |
||||
|
||||
parentNode.VisitedCount = visitedCount; |
||||
parentNode.NotVisitedCount = notVisitedCount; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
// <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 System; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageNamespaceTreeNode : CodeCoverageTreeNode |
||||
{ |
||||
public CodeCoverageNamespaceTreeNode(string name) : base(name) |
||||
{ |
||||
ImageIndex = ClassBrowserIconService.NamespaceIndex; |
||||
SelectedImageIndex = ImageIndex; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,123 @@
@@ -0,0 +1,123 @@
|
||||
// <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 System; |
||||
using System.Drawing; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageOptions |
||||
{ |
||||
public static readonly string OptionsProperty = "CodeCoverage.Options"; |
||||
|
||||
#region Property names
|
||||
public static readonly string VisitedColorProperty = "VisitedColor"; |
||||
public static readonly string VisitedForeColorProperty = "VisitedForeColor"; |
||||
public static readonly string NotVisitedColorProperty = "NotVisitedColor"; |
||||
public static readonly string NotVisitedForeColorProperty = "NotVisitedForeColor"; |
||||
public static readonly string NCoverFileNameProperty = "NCoverFileName"; |
||||
public static readonly string CodeCoverageHighlightedProperty = "CodeCoverageHighlighted"; |
||||
#endregion
|
||||
|
||||
static Properties properties; |
||||
|
||||
static CodeCoverageOptions() |
||||
{ |
||||
properties = PropertyService.Get(OptionsProperty, new Properties()); |
||||
} |
||||
|
||||
public static Properties Properties { |
||||
get { |
||||
return properties; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The full path to the NCover console executable.
|
||||
/// </summary>
|
||||
public static string NCoverFileName { |
||||
get { |
||||
return Properties.Get<String>(NCoverFileNameProperty, String.Empty); |
||||
} |
||||
set { |
||||
Properties.Set<String>(NCoverFileNameProperty, value); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Enables/disables code coverage highlighting.
|
||||
/// </summary>
|
||||
public static bool CodeCoverageHighlighted { |
||||
get { |
||||
return Properties.Get<bool>(CodeCoverageHighlightedProperty, false); |
||||
} |
||||
set { |
||||
Properties.Set<bool>(CodeCoverageHighlightedProperty, value); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the colour that will be used when highlighting visited code.
|
||||
/// </summary>
|
||||
public static Color VisitedColor |
||||
{ |
||||
get { |
||||
return Properties.Get<Color>(VisitedColorProperty, Color.Lime); |
||||
} |
||||
|
||||
set { |
||||
Properties.Set<Color>(VisitedColorProperty, value); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the foreground colour that will be used when highlighting
|
||||
/// visited code.
|
||||
/// </summary>
|
||||
public static Color VisitedForeColor |
||||
{ |
||||
get { |
||||
return Properties.Get<Color>(VisitedForeColorProperty, Color.Black); |
||||
} |
||||
|
||||
set { |
||||
Properties.Set<Color>(VisitedForeColorProperty, value); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the colour that will be used when highlighting code that has not
|
||||
/// been visited.
|
||||
/// </summary>
|
||||
public static Color NotVisitedColor |
||||
{ |
||||
get { |
||||
return Properties.Get<Color>(NotVisitedColorProperty, Color.Red); |
||||
} |
||||
|
||||
set { |
||||
Properties.Set<Color>(NotVisitedColorProperty, value); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the foreground colour that will be used when highlighting
|
||||
/// code that has not been visited.
|
||||
/// </summary>
|
||||
public static Color NotVisitedForeColor |
||||
{ |
||||
get { |
||||
return Properties.Get<Color>(NotVisitedForeColorProperty, Color.White); |
||||
} |
||||
|
||||
set { |
||||
Properties.Set<Color>(NotVisitedForeColorProperty, value); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,137 @@
@@ -0,0 +1,137 @@
|
||||
// <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 System; |
||||
using System.Collections; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageOptionsPanel : AbstractOptionPanel |
||||
{ |
||||
static readonly string foregroundCustomColourButtonName = "foregroundCustomColourButton"; |
||||
static readonly string backgroundCustomColourButtonName = "backgroundCustomColourButton"; |
||||
static readonly string foregroundColourComboBoxName = "foregroundColorPickerComboBox"; |
||||
static readonly string backgroundColourComboBoxName = "backgroundColorPickerComboBox"; |
||||
static readonly string displayItemsListBoxName = "displayItemsListBox"; |
||||
static readonly string sampleTextLabelName = "sampleTextLabel"; |
||||
static readonly string browseButtonName = "browseButton"; |
||||
static readonly string commandTextBoxName = "commandTextBox"; |
||||
|
||||
ColorPickerComboBox foregroundColorPickerComboBox; |
||||
ColorPickerComboBox backgroundColorPickerComboBox; |
||||
ListBox displayItemsListBox; |
||||
Label sampleTextLabel; |
||||
TextBox commandTextBox; |
||||
|
||||
public override void LoadPanelContents() |
||||
{ |
||||
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.CodeCoverage.Resources.CodeCoverageOptionsPanel.xfrm")); |
||||
|
||||
ControlDictionary[foregroundCustomColourButtonName].Click += new EventHandler(ForegroundCustomColourButtonClick); |
||||
ControlDictionary[backgroundCustomColourButtonName].Click += new EventHandler(BackgroundCustomColourButtonClick); |
||||
ControlDictionary[browseButtonName].Click += new EventHandler(BrowseButtonClick); |
||||
|
||||
foregroundColorPickerComboBox = (ColorPickerComboBox)ControlDictionary[foregroundColourComboBoxName]; |
||||
foregroundColorPickerComboBox.SelectedIndexChanged += ForegroundColorPickerComboBoxSelectedIndexChanged; |
||||
|
||||
backgroundColorPickerComboBox = (ColorPickerComboBox)ControlDictionary[backgroundColourComboBoxName]; |
||||
backgroundColorPickerComboBox.SelectedIndexChanged += BackgroundColorPickerComboBoxSelectedIndexChanged; |
||||
|
||||
sampleTextLabel = (Label)ControlDictionary[sampleTextLabelName]; |
||||
|
||||
commandTextBox = (TextBox)ControlDictionary[commandTextBoxName]; |
||||
commandTextBox.Text = CodeCoverageOptions.NCoverFileName; |
||||
|
||||
displayItemsListBox = (ListBox)ControlDictionary[displayItemsListBoxName]; |
||||
displayItemsListBox.Items.Add(new CodeCoverageDisplayItem("Code Covered", CodeCoverageOptions.VisitedColorProperty, CodeCoverageOptions.VisitedColor, CodeCoverageOptions.VisitedForeColorProperty, CodeCoverageOptions.VisitedForeColor)); |
||||
displayItemsListBox.Items.Add(new CodeCoverageDisplayItem("Code Not Covered", CodeCoverageOptions.NotVisitedColorProperty, CodeCoverageOptions.NotVisitedColor, CodeCoverageOptions.NotVisitedForeColorProperty, CodeCoverageOptions.NotVisitedForeColor)); |
||||
displayItemsListBox.SelectedIndexChanged += DisplayItemsListBoxSelectedIndexChanged; |
||||
displayItemsListBox.SelectedIndex = 0; |
||||
} |
||||
|
||||
public override bool StorePanelContents() |
||||
{ |
||||
bool codeCoverageColorsChanged = false; |
||||
|
||||
foreach (CodeCoverageDisplayItem item in displayItemsListBox.Items) { |
||||
CodeCoverageOptions.Properties.Set<Color>(item.ForeColorPropertyName, item.ForeColor); |
||||
CodeCoverageOptions.Properties.Set<Color>(item.BackColorPropertyName, item.BackColor); |
||||
if (item.HasChanged) { |
||||
codeCoverageColorsChanged = true; |
||||
} |
||||
} |
||||
|
||||
if (codeCoverageColorsChanged) { |
||||
CodeCoverageService.RefreshCodeCoverageHighlights(); |
||||
} |
||||
|
||||
CodeCoverageOptions.NCoverFileName = commandTextBox.Text; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
void ForegroundCustomColourButtonClick(object sender, EventArgs e) |
||||
{ |
||||
SelectCustomColour(foregroundColorPickerComboBox); |
||||
} |
||||
|
||||
void BackgroundCustomColourButtonClick(object sender, EventArgs e) |
||||
{ |
||||
SelectCustomColour(backgroundColorPickerComboBox); |
||||
} |
||||
|
||||
void SelectCustomColour(ColorPickerComboBox comboBox) |
||||
{ |
||||
using (ColorDialog colorDialog = new ColorDialog()) { |
||||
colorDialog.FullOpen = true; |
||||
if (colorDialog.ShowDialog() == DialogResult.OK) { |
||||
comboBox.SelectedColor = colorDialog.Color; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void DisplayItemsListBoxSelectedIndexChanged(object sender, EventArgs e) |
||||
{ |
||||
CodeCoverageDisplayItem item = (CodeCoverageDisplayItem)displayItemsListBox.SelectedItem; |
||||
sampleTextLabel.BackColor = item.BackColor; |
||||
sampleTextLabel.ForeColor = item.ForeColor; |
||||
foregroundColorPickerComboBox.SelectedColor = item.ForeColor; |
||||
backgroundColorPickerComboBox.SelectedColor = item.BackColor; |
||||
} |
||||
|
||||
void ForegroundColorPickerComboBoxSelectedIndexChanged(object sender, EventArgs e) |
||||
{ |
||||
CodeCoverageDisplayItem item = (CodeCoverageDisplayItem)displayItemsListBox.SelectedItem; |
||||
sampleTextLabel.ForeColor = foregroundColorPickerComboBox.SelectedColor; |
||||
item.ForeColor = foregroundColorPickerComboBox.SelectedColor; |
||||
} |
||||
|
||||
void BackgroundColorPickerComboBoxSelectedIndexChanged(object sender, EventArgs e) |
||||
{ |
||||
CodeCoverageDisplayItem item = (CodeCoverageDisplayItem)displayItemsListBox.SelectedItem; |
||||
sampleTextLabel.BackColor = backgroundColorPickerComboBox.SelectedColor; |
||||
item.BackColor = backgroundColorPickerComboBox.SelectedColor; |
||||
} |
||||
|
||||
void BrowseButtonClick(object sender, EventArgs e) |
||||
{ |
||||
using (OpenFileDialog openFileDialog = new OpenFileDialog()) { |
||||
openFileDialog.CheckFileExists = true; |
||||
openFileDialog.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe|${res:SharpDevelop.FileFilter.AllFiles}|*.*"); |
||||
if (openFileDialog.ShowDialog() == DialogResult.OK) { |
||||
ControlDictionary[commandTextBoxName].Text = openFileDialog.FileName; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
// <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.SharpDevelop.Project; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoveragePad : AbstractPadContent |
||||
{ |
||||
static CodeCoveragePad instance; |
||||
bool disposed; |
||||
CodeCoverageControl codeCoverageControl; |
||||
|
||||
public CodeCoveragePad() |
||||
{ |
||||
instance = this; |
||||
|
||||
codeCoverageControl = new CodeCoverageControl(); |
||||
if (CodeCoverageService.Results != null) { |
||||
codeCoverageControl.AddModules(CodeCoverageService.Results.Modules); |
||||
} |
||||
codeCoverageControl.UpdateToolbar(); |
||||
|
||||
ProjectService.SolutionClosed += SolutionClosed; |
||||
ProjectService.SolutionLoaded += SolutionLoaded; |
||||
} |
||||
|
||||
public static CodeCoveragePad Instance { |
||||
get { |
||||
return instance; |
||||
} |
||||
} |
||||
|
||||
public override Control Control { |
||||
get { |
||||
return codeCoverageControl; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Cleans up all used resources
|
||||
/// </summary>
|
||||
public override void Dispose() |
||||
{ |
||||
if (!disposed) { |
||||
disposed = true; |
||||
ProjectService.SolutionClosed -= SolutionClosed; |
||||
ProjectService.SolutionLoaded -= SolutionLoaded; |
||||
codeCoverageControl.Dispose(); |
||||
} |
||||
} |
||||
|
||||
public void UpdateToolbar() |
||||
{ |
||||
codeCoverageControl.UpdateToolbar(); |
||||
} |
||||
|
||||
public void ShowResults(CodeCoverageResults results) |
||||
{ |
||||
codeCoverageControl.Clear(); |
||||
if (results != null) { |
||||
codeCoverageControl.AddModules(results.Modules); |
||||
} |
||||
} |
||||
|
||||
public void ClearCodeCoverageResults() |
||||
{ |
||||
codeCoverageControl.Clear(); |
||||
} |
||||
|
||||
void SolutionLoaded(object sender, EventArgs e) |
||||
{ |
||||
codeCoverageControl.UpdateToolbar(); |
||||
} |
||||
|
||||
void SolutionClosed(object sender, EventArgs e) |
||||
{ |
||||
codeCoverageControl.UpdateToolbar(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// <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 ICSharpCode.SharpDevelop.Gui.OptionPanels; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using System; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageProjectOptionsPanel : AbstractProjectOptionPanel |
||||
{ |
||||
static readonly string AssemblyListTextBoxName = "assemblyListTextBox"; |
||||
|
||||
TextBox assemblyListTextBox; |
||||
|
||||
public CodeCoverageProjectOptionsPanel() |
||||
{ |
||||
} |
||||
|
||||
public override void LoadPanelContents() |
||||
{ |
||||
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.CodeCoverage.Resources.CodeCoverageProjectOptionsPanel.xfrm")); |
||||
InitializeHelper(); |
||||
|
||||
assemblyListTextBox = (TextBox)ControlDictionary[AssemblyListTextBoxName]; |
||||
|
||||
ReadNCoverSettings(); |
||||
|
||||
assemblyListTextBox.TextChanged += AssemblyListTextBoxTextChanged; |
||||
} |
||||
|
||||
public override bool StorePanelContents() |
||||
{ |
||||
SaveNCoverSettings(); |
||||
IsDirty = false; |
||||
return true; |
||||
} |
||||
|
||||
void AssemblyListTextBoxTextChanged(object sender, EventArgs e) |
||||
{ |
||||
IsDirty = true; |
||||
} |
||||
|
||||
void SaveNCoverSettings() |
||||
{ |
||||
NCoverSettings settings = new NCoverSettings(); |
||||
settings.AssemblyList = assemblyListTextBox.Text; |
||||
settings.Save(NCoverSettings.GetFileName(project)); |
||||
} |
||||
|
||||
void ReadNCoverSettings() |
||||
{ |
||||
string settingsFileName = NCoverSettings.GetFileName(project); |
||||
if (File.Exists(settingsFileName)) { |
||||
NCoverSettings settings = new NCoverSettings(settingsFileName); |
||||
assemblyListTextBox.Text = settings.AssemblyList; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageResults |
||||
{ |
||||
List<CodeCoverageModule> modules = new List<CodeCoverageModule>(); |
||||
|
||||
public CodeCoverageResults(string fileName) : this(new StreamReader(fileName, true)) |
||||
{ |
||||
} |
||||
|
||||
public CodeCoverageResults(XmlReader reader) |
||||
{ |
||||
ReadResults(reader); |
||||
} |
||||
|
||||
public CodeCoverageResults(TextReader reader) : this(new XmlTextReader(reader)) |
||||
{ |
||||
} |
||||
|
||||
public List<CodeCoverageSequencePoint> GetSequencePoints(string fileName) |
||||
{ |
||||
List<CodeCoverageSequencePoint> sequencePoints = new List<CodeCoverageSequencePoint>(); |
||||
foreach (CodeCoverageModule module in modules) { |
||||
sequencePoints.AddRange(module.GetSequencePoints(fileName)); |
||||
} |
||||
return sequencePoints; |
||||
} |
||||
|
||||
public List<CodeCoverageModule> Modules { |
||||
get { |
||||
return modules; |
||||
} |
||||
} |
||||
|
||||
void ReadResults(XmlReader reader) |
||||
{ |
||||
CodeCoverageModule currentModule = null; |
||||
CodeCoverageMethod currentMethod = null; |
||||
|
||||
while (reader.Read()) { |
||||
switch (reader.NodeType) { |
||||
case XmlNodeType.Element: |
||||
if (reader.Name == "module") { |
||||
currentModule = AddModule(reader); |
||||
} else if (reader.Name == "method" && currentModule != null) { |
||||
currentMethod = AddMethod(currentModule, reader); |
||||
} else if (reader.Name == "seqpnt" && currentMethod != null) { |
||||
AddSequencePoint(currentMethod, reader); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
reader.Close(); |
||||
} |
||||
|
||||
CodeCoverageModule AddModule(XmlReader reader) |
||||
{ |
||||
CodeCoverageModule module = new CodeCoverageModule(reader.GetAttribute("assembly")); |
||||
modules.Add(module); |
||||
return module; |
||||
} |
||||
|
||||
CodeCoverageMethod AddMethod(CodeCoverageModule module, XmlReader reader) |
||||
{ |
||||
CodeCoverageMethod method = new CodeCoverageMethod(reader.GetAttribute("name"), reader.GetAttribute("class")); |
||||
module.Methods.Add(method); |
||||
return method; |
||||
} |
||||
|
||||
void AddSequencePoint(CodeCoverageMethod method, XmlReader reader) |
||||
{ |
||||
CodeCoverageSequencePoint sequencePoint = new CodeCoverageSequencePoint(reader.GetAttribute("document"), |
||||
GetInteger(reader.GetAttribute("visitcount")), |
||||
GetInteger(reader.GetAttribute("line")), |
||||
GetInteger(reader.GetAttribute("column")), |
||||
GetInteger(reader.GetAttribute("endline")), |
||||
GetInteger(reader.GetAttribute("endcolumn"))); |
||||
method.SequencePoints.Add(sequencePoint); |
||||
} |
||||
|
||||
int GetInteger(string s) |
||||
{ |
||||
int val; |
||||
if (Int32.TryParse(s, out val)) { |
||||
return val; |
||||
} |
||||
return 0; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// <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.XmlForms; |
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageRunnerNotFoundForm : XmlForm |
||||
{ |
||||
public CodeCoverageRunnerNotFoundForm() |
||||
{ |
||||
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.CodeCoverage.Resources.CodeCoverageRunnerNotFoundForm.xfrm")); |
||||
|
||||
((Label)ControlDictionary["messageLabel"]).Text = "Unable to locate the NCover console application.\n\nIf NCover is installed, please specify the location of the application in the Code Coverage options."; |
||||
((PictureBox)ControlDictionary["iconPictureBox"]).Image = ResourceService.GetBitmap("Icons.32x32.Information"); |
||||
((LinkLabel)ControlDictionary["linkLabel"]).Click += LinkLabelClicked; |
||||
} |
||||
|
||||
void LinkLabelClicked(object sender, EventArgs e) |
||||
{ |
||||
Process.Start("http://ncover.org"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageSequencePoint |
||||
{ |
||||
string document = String.Empty; |
||||
int visitCount = 0; |
||||
int line = 0; |
||||
int column = 0; |
||||
int endLine = 0; |
||||
int endColumn = 0; |
||||
|
||||
public CodeCoverageSequencePoint(string document, int visitCount, int line, int column, int endLine, int endColumn) |
||||
{ |
||||
this.document = document; |
||||
this.visitCount = visitCount; |
||||
this.line = line; |
||||
this.column = column; |
||||
this.endLine = endLine; |
||||
this.endColumn = endColumn; |
||||
} |
||||
|
||||
public string Document { |
||||
get { |
||||
return document; |
||||
} |
||||
} |
||||
|
||||
public int VisitCount { |
||||
get { |
||||
return visitCount; |
||||
} |
||||
} |
||||
|
||||
public int Line { |
||||
get { |
||||
return line; |
||||
} |
||||
} |
||||
|
||||
public int Column { |
||||
get { |
||||
return column; |
||||
} |
||||
} |
||||
|
||||
public int EndLine { |
||||
get { |
||||
return endLine; |
||||
} |
||||
} |
||||
|
||||
public int EndColumn { |
||||
get { |
||||
return endColumn; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,150 @@
@@ -0,0 +1,150 @@
|
||||
// <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.DefaultEditor.Gui.Editor; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageService |
||||
{ |
||||
static CodeCoverageResults results; |
||||
static CodeCoverageHighlighter codeCoverageHighlighter = new CodeCoverageHighlighter(); |
||||
|
||||
CodeCoverageService() |
||||
{ |
||||
} |
||||
|
||||
static CodeCoverageService() |
||||
{ |
||||
WorkbenchSingleton.Workbench.ViewOpened += ViewOpened; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Shows/hides the code coverage in the source code.
|
||||
/// </summary>
|
||||
public static bool CodeCoverageHighlighted { |
||||
get { |
||||
return CodeCoverageOptions.CodeCoverageHighlighted; |
||||
} |
||||
set { |
||||
CodeCoveragePad pad = CodeCoveragePad.Instance; |
||||
if (pad != null) { |
||||
pad.UpdateToolbar(); |
||||
} |
||||
if (CodeCoverageOptions.CodeCoverageHighlighted != value) { |
||||
CodeCoverageOptions.CodeCoverageHighlighted = value; |
||||
if (CodeCoverageResultsExist) { |
||||
if (CodeCoverageOptions.CodeCoverageHighlighted) { |
||||
ShowCodeCoverage(); |
||||
} else { |
||||
HideCodeCoverage(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the results from the last code coverage run.
|
||||
/// </summary>
|
||||
public static CodeCoverageResults Results { |
||||
get { |
||||
return results; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Clears any code coverage results currently on display.
|
||||
/// </summary>
|
||||
public static void ClearResults() |
||||
{ |
||||
CodeCoveragePad pad = CodeCoveragePad.Instance; |
||||
if (pad != null) { |
||||
pad.ClearCodeCoverageResults(); |
||||
} |
||||
HideCodeCoverage(); |
||||
results = null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Shows the code coverage results in the code coverage pad and
|
||||
/// highlights any source code files that have been profiled.
|
||||
/// </summary>
|
||||
public static void ShowResults(CodeCoverageResults results) |
||||
{ |
||||
CodeCoverageService.results = results; |
||||
CodeCoveragePad pad = CodeCoveragePad.Instance; |
||||
if (pad != null) { |
||||
pad.ShowResults(results); |
||||
} |
||||
if (results != null) { |
||||
RefreshCodeCoverageHighlights(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Updates the highlighted code coverage text to reflect any changes
|
||||
/// in the configured colours.
|
||||
/// </summary>
|
||||
public static void RefreshCodeCoverageHighlights() |
||||
{ |
||||
if (CodeCoverageOptions.CodeCoverageHighlighted && CodeCoverageResultsExist) { |
||||
HideCodeCoverage(); |
||||
ShowCodeCoverage(); |
||||
} |
||||
} |
||||
|
||||
static void ShowCodeCoverage() |
||||
{ |
||||
// Highlight any open files.
|
||||
foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) { |
||||
ShowCodeCoverage(view); |
||||
} |
||||
} |
||||
|
||||
static void HideCodeCoverage() |
||||
{ |
||||
foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) { |
||||
TextEditorDisplayBindingWrapper textEditor = view as TextEditorDisplayBindingWrapper; |
||||
if (textEditor != null) { |
||||
codeCoverageHighlighter.RemoveMarkers(textEditor.textAreaControl.Document.MarkerStrategy); |
||||
textEditor.textAreaControl.Refresh(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
static void ViewOpened(object sender, ViewContentEventArgs e) |
||||
{ |
||||
if (CodeCoverageOptions.CodeCoverageHighlighted && CodeCoverageResultsExist) { |
||||
ShowCodeCoverage(e.Content); |
||||
} |
||||
} |
||||
|
||||
static void ShowCodeCoverage(IViewContent view) |
||||
{ |
||||
TextEditorDisplayBindingWrapper textEditor = view as TextEditorDisplayBindingWrapper; |
||||
if (textEditor != null && view.FileName != null) { |
||||
List<CodeCoverageSequencePoint> sequencePoints = results.GetSequencePoints(view.FileName); |
||||
if (sequencePoints.Count > 0) { |
||||
codeCoverageHighlighter.AddMarkers(textEditor.textAreaControl.Document.MarkerStrategy, sequencePoints); |
||||
textEditor.textAreaControl.Refresh(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
static bool CodeCoverageResultsExist { |
||||
get { |
||||
return results != null; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// <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.TextEditor.Document; |
||||
using System; |
||||
using System.Drawing; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Custom text marker used when highlighting code coverage lines.
|
||||
/// </summary>
|
||||
public class CodeCoverageTextMarker : TextMarker |
||||
{ |
||||
public CodeCoverageTextMarker(int offset, CodeCoverageSequencePoint sequencePoint) : this(offset, GetSequencePointLength(sequencePoint), sequencePoint) |
||||
{ |
||||
} |
||||
|
||||
public CodeCoverageTextMarker(int offset, int length, CodeCoverageSequencePoint sequencePoint) : base(offset, length, TextMarkerType.SolidBlock, GetSequencePointColor(sequencePoint), GetSequencePointForeColor(sequencePoint)) |
||||
{ |
||||
} |
||||
|
||||
public static int GetSequencePointLength(CodeCoverageSequencePoint sequencePoint) |
||||
{ |
||||
return sequencePoint.EndColumn - sequencePoint.Column; |
||||
} |
||||
|
||||
public static Color GetSequencePointColor(CodeCoverageSequencePoint sequencePoint) |
||||
{ |
||||
if (sequencePoint.VisitCount > 0) { |
||||
return CodeCoverageOptions.VisitedColor; |
||||
} |
||||
return CodeCoverageOptions.NotVisitedColor; |
||||
} |
||||
|
||||
public static Color GetSequencePointForeColor(CodeCoverageSequencePoint sequencePoint) |
||||
{ |
||||
if (sequencePoint.VisitCount > 0) { |
||||
return CodeCoverageOptions.VisitedForeColor; |
||||
} |
||||
return CodeCoverageOptions.NotVisitedForeColor; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
// <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.SharpDevelop.Gui; |
||||
using System; |
||||
using System.Drawing; |
||||
using System.Collections.Generic; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageTreeNode : ExtTreeNode |
||||
{ |
||||
public static readonly Color PartialCoverageTextColor = Color.Red; |
||||
|
||||
int visitedCount; |
||||
int notVisitedCount; |
||||
|
||||
public CodeCoverageTreeNode(string name) : this(name, 0, 0) |
||||
{ |
||||
} |
||||
|
||||
public CodeCoverageTreeNode(string name, int visitedCount, int notVisitedCount) |
||||
{ |
||||
this.visitedCount = visitedCount; |
||||
this.notVisitedCount = notVisitedCount; |
||||
|
||||
Name = name; |
||||
SetText(); |
||||
} |
||||
|
||||
public int VisitedCount { |
||||
get { |
||||
return visitedCount; |
||||
} |
||||
set { |
||||
visitedCount = value; |
||||
SetText(); |
||||
} |
||||
} |
||||
|
||||
public int NotVisitedCount { |
||||
get { |
||||
return notVisitedCount; |
||||
} |
||||
set { |
||||
notVisitedCount = value; |
||||
SetText(); |
||||
} |
||||
} |
||||
|
||||
static string GetPercentage(int visitedCount, int totalCount) |
||||
{ |
||||
int percentage = (visitedCount * 100) / totalCount; |
||||
return percentage.ToString(); |
||||
} |
||||
|
||||
static string GetNodeText(string name, int visitedCount, int totalCount) |
||||
{ |
||||
if (totalCount > 0) { |
||||
return String.Concat(name, " (", GetPercentage(visitedCount, totalCount), "%)"); |
||||
} |
||||
return name; |
||||
} |
||||
|
||||
void SetText() |
||||
{ |
||||
int total = visitedCount + notVisitedCount; |
||||
|
||||
// Change the text color for partial coverage.
|
||||
if (total != visitedCount) { |
||||
ForeColor = PartialCoverageTextColor; |
||||
} |
||||
|
||||
// Get the text for the node.
|
||||
Text = GetNodeText(Name, visitedCount, total); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
// <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.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class CodeCoverageTreeView : ExtTreeView |
||||
{ |
||||
public CodeCoverageTreeView() |
||||
{ |
||||
} |
||||
|
||||
public void AddModules(List<CodeCoverageModule> modules) |
||||
{ |
||||
foreach (CodeCoverageModule module in modules) { |
||||
Nodes.Add(new CodeCoverageModuleTreeNode(module)); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,144 @@
@@ -0,0 +1,144 @@
|
||||
// <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; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class ColorPickerComboBox : System.Windows.Forms.ComboBox |
||||
{ |
||||
Color customColor = Color.Empty; |
||||
int ColorRectangleLeftOffset = 4; |
||||
int ColorRectangleTopOffset = 2; |
||||
|
||||
public ColorPickerComboBox() |
||||
{ |
||||
base.DropDownStyle = ComboBoxStyle.DropDownList; |
||||
DrawMode = DrawMode.OwnerDrawFixed; |
||||
AddBasicColors(); |
||||
} |
||||
|
||||
public Color SelectedColor { |
||||
get { |
||||
if (SelectedItem != null) { |
||||
return (Color)SelectedItem; |
||||
} |
||||
return Color.Empty; |
||||
} |
||||
set { |
||||
if (Items.Contains(value)) { |
||||
SelectedItem = value; |
||||
} else if (CustomColorExists) { |
||||
UpdateCustomColor(value); |
||||
} else { |
||||
AddCustomColor(value); |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected override void OnDrawItem(DrawItemEventArgs e) |
||||
{ |
||||
if (e.Index >= 0) { |
||||
e.DrawBackground(); |
||||
Graphics g = e.Graphics; |
||||
Color color = (Color)Items[e.Index]; |
||||
Rectangle colorRectangle = GetColorRectangle(e.Bounds.Top); |
||||
g.FillRectangle(new SolidBrush(color), colorRectangle); |
||||
g.DrawRectangle(Pens.Black, colorRectangle); |
||||
int textOffset = (2 * colorRectangle.Left) + colorRectangle.Width; |
||||
SolidBrush brush = GetTextBrush(IsSelected(e.State)); |
||||
g.DrawString(GetColorName(color), e.Font, brush, new Rectangle(textOffset, e.Bounds.Top, e.Bounds.Width - textOffset, ItemHeight)); |
||||
} |
||||
base.OnDrawItem(e); |
||||
} |
||||
|
||||
bool CustomColorExists { |
||||
get { |
||||
return customColor != Color.Empty; |
||||
} |
||||
} |
||||
|
||||
void AddBasicColors() |
||||
{ |
||||
Items.Add(Color.Black); |
||||
Items.Add(Color.White); |
||||
Items.Add(Color.Maroon); |
||||
Items.Add(Color.Green); |
||||
Items.Add(Color.Olive); |
||||
Items.Add(Color.Navy); |
||||
Items.Add(Color.Purple); |
||||
Items.Add(Color.Teal); |
||||
Items.Add(Color.Silver); |
||||
Items.Add(Color.Gray); |
||||
Items.Add(Color.Red); |
||||
Items.Add(Color.Lime); |
||||
Items.Add(Color.Yellow); |
||||
Items.Add(Color.Blue); |
||||
Items.Add(Color.Magenta); |
||||
Items.Add(Color.Cyan); |
||||
SelectedIndex = 0; |
||||
} |
||||
|
||||
void AddCustomColor(Color color) |
||||
{ |
||||
customColor = color; |
||||
SelectedIndex = Items.Add(color); |
||||
} |
||||
|
||||
void UpdateCustomColor(Color color) |
||||
{ |
||||
int index = Items.IndexOf(customColor); |
||||
if (index >= 0) { |
||||
customColor = color; |
||||
Items[index] = color; |
||||
SelectedIndex = index; |
||||
} else { |
||||
AddCustomColor(color); |
||||
} |
||||
} |
||||
|
||||
Rectangle GetColorRectangle(int y) |
||||
{ |
||||
int colorRectangleHeight = ItemHeight - (2 * ColorRectangleTopOffset); |
||||
return new Rectangle(ColorRectangleLeftOffset, y + ColorRectangleTopOffset, colorRectangleHeight, colorRectangleHeight); |
||||
} |
||||
|
||||
string GetColorName(Color color) |
||||
{ |
||||
if (CustomColorExists && color == customColor) { |
||||
return "Custom"; |
||||
} |
||||
return color.Name; |
||||
} |
||||
|
||||
SolidBrush GetTextBrush(bool selected) |
||||
{ |
||||
if (selected) { |
||||
return new SolidBrush(Color.White); |
||||
} |
||||
return new SolidBrush(ForeColor); |
||||
} |
||||
|
||||
bool IsSelected(DrawItemState state) |
||||
{ |
||||
return (state & DrawItemState.Selected) == DrawItemState.Selected; |
||||
} |
||||
|
||||
protected override void OnDropDownStyleChanged(EventArgs e) |
||||
{ |
||||
if (DropDownStyle != ComboBoxStyle.DropDownList) { |
||||
DropDownStyle = ComboBoxStyle.DropDownList; |
||||
} |
||||
base.OnDropDownStyleChanged(e); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public delegate void LineReceivedEventHandler(object sender, LineReceivedEventArgs e); |
||||
|
||||
/// <summary>
|
||||
/// The arguments for the <see cref="LineReceivedEventHandler"/> event.
|
||||
/// </summary>
|
||||
public class LineReceivedEventArgs : EventArgs |
||||
{ |
||||
string line = String.Empty; |
||||
|
||||
public LineReceivedEventArgs(string line) |
||||
{ |
||||
this.line = line; |
||||
} |
||||
|
||||
public string Line { |
||||
get { |
||||
return line; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,113 @@
@@ -0,0 +1,113 @@
|
||||
// <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 != null && 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); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Represents the method that will handle the
|
||||
/// <see cref="NCoverRunner.NCoverExit"/> event.
|
||||
/// </summary>
|
||||
public delegate void NCoverExitEventHandler(object sender, NCoverExitEventArgs e); |
||||
|
||||
/// <summary>
|
||||
/// The <see cref="NCoverRunner.NCoverExit"/> event arguments.
|
||||
/// </summary>
|
||||
public class NCoverExitEventArgs : EventArgs |
||||
{ |
||||
string output; |
||||
int exitCode; |
||||
string error; |
||||
|
||||
public NCoverExitEventArgs(string output, string error, int exitCode) |
||||
{ |
||||
this.output = output; |
||||
this.error = error; |
||||
this.exitCode = exitCode; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the command line output from NAnt.
|
||||
/// </summary>
|
||||
public string Output { |
||||
get { |
||||
return output; |
||||
} |
||||
} |
||||
|
||||
public string Error { |
||||
get { |
||||
return error; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the exit code.
|
||||
/// </summary>
|
||||
public int ExitCode { |
||||
get { |
||||
return exitCode; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,255 @@
@@ -0,0 +1,255 @@
|
||||
// <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.Diagnostics; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Runs NCover.
|
||||
/// </summary>
|
||||
public class NCoverRunner |
||||
{ |
||||
string ncoverFileName = String.Empty; |
||||
string workingDirectory = String.Empty; |
||||
string coverageResultsFileName = String.Empty; |
||||
string profiledApplicationCommand = String.Empty; |
||||
string profiledApplicationCommandLineArguments = String.Empty; |
||||
string assemblyList = String.Empty; |
||||
string logFileName = String.Empty; |
||||
ProcessRunner runner; |
||||
|
||||
/// <summary>
|
||||
/// Triggered when NCover exits.
|
||||
/// </summary>
|
||||
public event NCoverExitEventHandler NCoverExited; |
||||
|
||||
/// <summary>
|
||||
/// The NCover runner was started.
|
||||
/// </summary>
|
||||
public event EventHandler NCoverStarted; |
||||
|
||||
/// <summary>
|
||||
/// The NCover runner was stopped. Being stopped is not the
|
||||
/// same as NCover exiting.
|
||||
/// </summary>
|
||||
public event EventHandler NCoverStopped; |
||||
|
||||
/// <summary>
|
||||
/// Triggered when an output line is received from NCover.
|
||||
/// </summary>
|
||||
public event LineReceivedEventHandler OutputLineReceived; |
||||
|
||||
public NCoverRunner() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the NCover executable path.
|
||||
/// </summary>
|
||||
public string NCoverFileName { |
||||
get { |
||||
return ncoverFileName; |
||||
} |
||||
set { |
||||
ncoverFileName = value; |
||||
} |
||||
} |
||||
|
||||
public string WorkingDirectory { |
||||
get { |
||||
return workingDirectory; |
||||
} |
||||
set { |
||||
workingDirectory = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The list of assemblies that will be profiled.
|
||||
/// </summary>
|
||||
public string AssemblyList { |
||||
get { |
||||
return assemblyList; |
||||
} |
||||
set { |
||||
// Remove any spaces from the assembly list since
|
||||
// NCover will ignore any items after the space.
|
||||
assemblyList = value.Replace(" ", String.Empty); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the full NCover command line that will be used by
|
||||
/// the runner.
|
||||
/// </summary>
|
||||
public string CommandLine { |
||||
get { |
||||
return String.Concat(ncoverFileName, " ", GetArguments()); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the NCover runner is currently running.
|
||||
/// </summary>
|
||||
public bool IsRunning { |
||||
get { |
||||
if (runner != null) { |
||||
return runner.IsRunning; |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Coverage output results file.
|
||||
/// </summary>
|
||||
public string CoverageResultsFileName { |
||||
get { |
||||
return coverageResultsFileName; |
||||
} |
||||
set { |
||||
coverageResultsFileName = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Profiler log file.
|
||||
/// </summary>
|
||||
public string LogFileName { |
||||
get { |
||||
return logFileName; |
||||
} |
||||
set { |
||||
logFileName = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the command that will be used to run the
|
||||
/// profiled application.
|
||||
/// </summary>
|
||||
public string ProfiledApplicationCommand { |
||||
get { |
||||
return profiledApplicationCommand; |
||||
} |
||||
set { |
||||
profiledApplicationCommand = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The arguments that will be used with the profiled application.
|
||||
/// </summary>
|
||||
public string ProfiledApplicationCommandLineArguments { |
||||
get { |
||||
return profiledApplicationCommandLineArguments; |
||||
} |
||||
set { |
||||
profiledApplicationCommandLineArguments = value; |
||||
} |
||||
} |
||||
|
||||
public void Start() |
||||
{ |
||||
string arguments = GetArguments(); |
||||
|
||||
runner = new ProcessRunner(); |
||||
runner.WorkingDirectory = workingDirectory; |
||||
runner.ProcessExited += new EventHandler(ProcessExited); |
||||
|
||||
if (OutputLineReceived != null) { |
||||
runner.OutputLineReceived += new LineReceivedEventHandler(OnOutputLineReceived); |
||||
} |
||||
runner.Start(ncoverFileName, arguments); |
||||
OnNCoverStarted(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Stops the currently running NCover instance.
|
||||
/// </summary>
|
||||
public void Stop() |
||||
{ |
||||
if (runner != null) { |
||||
runner.Kill(); |
||||
OnNCoverStopped(); |
||||
} |
||||
} |
||||
|
||||
protected void OnNCoverExited(string output, string error, int exitCode) |
||||
{ |
||||
if (NCoverExited != null) { |
||||
NCoverExited(this, new NCoverExitEventArgs(output, error, exitCode)); |
||||
} |
||||
} |
||||
|
||||
protected void OnNCoverStarted() |
||||
{ |
||||
if (NCoverStarted != null) { |
||||
NCoverStarted(this, new EventArgs()); |
||||
} |
||||
} |
||||
|
||||
protected void OnNCoverStopped() |
||||
{ |
||||
if (NCoverStopped != null) { |
||||
NCoverStopped(this, new EventArgs()); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="OutputLineReceived"/> event.
|
||||
/// </summary>
|
||||
/// <param name="sender">The event source.</param>
|
||||
/// <param name="e">The event arguments.</param>
|
||||
protected void OnOutputLineReceived(object sender, LineReceivedEventArgs e) |
||||
{ |
||||
if (OutputLineReceived != null) { |
||||
OutputLineReceived(this, e); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Handles the NCover process exit event.
|
||||
/// </summary>
|
||||
/// <param name="sender">The event source.</param>
|
||||
/// <param name="e">The event arguments.</param>
|
||||
void ProcessExited(object sender, EventArgs e) |
||||
{ |
||||
ProcessRunner runner = (ProcessRunner)sender; |
||||
OnNCoverExited(runner.StandardOutput, runner.StandardError, runner.ExitCode); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds extra command line arguments to those specified
|
||||
/// by the user in the <see cref="Arguments"/> string.
|
||||
/// </summary>
|
||||
string GetArguments() |
||||
{ |
||||
StringBuilder ncoverArguments = new StringBuilder(); |
||||
|
||||
if (coverageResultsFileName.Length > 0) { |
||||
ncoverArguments.AppendFormat("//x \"{0}\" ", coverageResultsFileName); |
||||
} |
||||
|
||||
if (assemblyList.Length > 0) { |
||||
ncoverArguments.AppendFormat("//a \"{0}\" ", assemblyList); |
||||
} |
||||
|
||||
if (logFileName.Length > 0) { |
||||
ncoverArguments.AppendFormat("//l \"{0}\" ", logFileName); |
||||
} |
||||
|
||||
ncoverArguments.AppendFormat("\"{0}\" ", profiledApplicationCommand); |
||||
ncoverArguments.Append(profiledApplicationCommandLineArguments); |
||||
|
||||
return ncoverArguments.ToString(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Single NCover runner that is used by all commands.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
public class NCoverRunnerSingleton |
||||
{ |
||||
static NCoverRunner runner; |
||||
|
||||
NCoverRunnerSingleton() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="NCoverRunner"/> instance.
|
||||
/// </summary>
|
||||
public static NCoverRunner Runner { |
||||
get { |
||||
if (runner == null) { |
||||
runner = new NCoverRunner(); |
||||
} |
||||
return runner; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,97 @@
@@ -0,0 +1,97 @@
|
||||
// <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.SharpDevelop.Project; |
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Settings for NCover.
|
||||
/// </summary>
|
||||
public class NCoverSettings |
||||
{ |
||||
static readonly string RootElementName = "ProfilerSettings"; |
||||
static readonly string AssembliesElementName = "Assemblies"; |
||||
|
||||
string assemblyList = String.Empty; |
||||
|
||||
public NCoverSettings() |
||||
{ |
||||
} |
||||
|
||||
public NCoverSettings(string fileName) : this(new StreamReader(fileName, true)) |
||||
{ |
||||
} |
||||
|
||||
public NCoverSettings(XmlReader reader) |
||||
{ |
||||
ReadSettings(reader); |
||||
} |
||||
|
||||
public NCoverSettings(TextReader reader) : this(new XmlTextReader(reader)) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the NCover settings filename for the specified project.
|
||||
/// </summary>
|
||||
public static string GetFileName(IProject project) |
||||
{ |
||||
return Path.ChangeExtension(project.FileName, "NCover.Settings"); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// A semi-colon delimited list of assemblies.
|
||||
/// </summary>
|
||||
public string AssemblyList { |
||||
get { |
||||
return assemblyList; |
||||
} |
||||
set { |
||||
assemblyList = value; |
||||
} |
||||
} |
||||
|
||||
public void Save(TextWriter writer) |
||||
{ |
||||
Save(new XmlTextWriter(writer)); |
||||
} |
||||
|
||||
public void Save(string fileName) |
||||
{ |
||||
Save(new StreamWriter(fileName, false, Encoding.UTF8)); |
||||
} |
||||
|
||||
public void Save(XmlTextWriter writer) |
||||
{ |
||||
writer.Formatting = Formatting.Indented; |
||||
|
||||
using (writer) { |
||||
writer.WriteStartElement(RootElementName); |
||||
writer.WriteElementString(AssembliesElementName, assemblyList); |
||||
writer.WriteEndElement(); |
||||
} |
||||
} |
||||
|
||||
void ReadSettings(XmlReader reader) |
||||
{ |
||||
using (reader) { |
||||
while (reader.Read()) { |
||||
if (reader.NodeType == XmlNodeType.Element) { |
||||
if (reader.Name == AssembliesElementName) { |
||||
assemblyList = reader.ReadString(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,98 @@
@@ -0,0 +1,98 @@
|
||||
// <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.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using System.Threading; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// A threaded <see cref="Process.StandardOutput"/> or
|
||||
/// <see cref="Process.StandardError"/> reader.
|
||||
/// </summary>
|
||||
public class OutputReader |
||||
{ |
||||
StreamReader reader; |
||||
string output = String.Empty; |
||||
Thread thread; |
||||
|
||||
public event LineReceivedEventHandler LineReceived; |
||||
|
||||
public OutputReader(StreamReader reader) |
||||
{ |
||||
this.reader = reader; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Starts reading the output stream.
|
||||
/// </summary>
|
||||
public void Start() |
||||
{ |
||||
thread = new Thread(new ThreadStart(ReadOutput)); |
||||
thread.Start(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the text output read from the reader.
|
||||
/// </summary>
|
||||
public string Output { |
||||
get { |
||||
return output; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Waits for the reader to finish.
|
||||
/// </summary>
|
||||
public void WaitForFinish() |
||||
{ |
||||
if (thread != null) { |
||||
thread.Join(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="LineReceived"/> event.
|
||||
/// </summary>
|
||||
/// <param name="line"></param>
|
||||
protected void OnLineReceived(string line) |
||||
{ |
||||
if (LineReceived != null) { |
||||
LineReceived(this, new LineReceivedEventArgs(line)); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Reads the output stream on a different thread.
|
||||
/// </summary>
|
||||
void ReadOutput() |
||||
{ |
||||
//output = reader.ReadToEnd();
|
||||
output = String.Empty; |
||||
StringBuilder outputBuilder = new StringBuilder(); |
||||
|
||||
bool endOfStream = false; |
||||
while(!endOfStream) |
||||
{ |
||||
string line = reader.ReadLine(); |
||||
|
||||
if (line != null) { |
||||
outputBuilder.Append(line); |
||||
outputBuilder.Append(Environment.NewLine); |
||||
OnLineReceived(line); |
||||
} else { |
||||
endOfStream = true; |
||||
} |
||||
} |
||||
|
||||
output = outputBuilder.ToString(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,266 @@
@@ -0,0 +1,266 @@
|
||||
// <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 System; |
||||
using System.Diagnostics; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Runs a process that sends output to standard output and to
|
||||
/// standard error.
|
||||
/// </summary>
|
||||
public class ProcessRunner : IDisposable |
||||
{ |
||||
Process process; |
||||
string standardOutput = String.Empty; |
||||
string workingDirectory = String.Empty; |
||||
OutputReader standardOutputReader; |
||||
OutputReader standardErrorReader; |
||||
|
||||
/// <summary>
|
||||
/// Triggered when the process has exited.
|
||||
/// </summary>
|
||||
public event EventHandler ProcessExited; |
||||
|
||||
/// <summary>
|
||||
/// Triggered when a line of text is read from the standard output.
|
||||
/// </summary>
|
||||
public event LineReceivedEventHandler OutputLineReceived; |
||||
|
||||
/// <summary>
|
||||
/// Triggered when a line of text is read from the standard error.
|
||||
/// </summary>
|
||||
public event LineReceivedEventHandler ErrorLineReceived; |
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ProcessRunner"/>.
|
||||
/// </summary>
|
||||
public ProcessRunner() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the process's working directory.
|
||||
/// </summary>
|
||||
public string WorkingDirectory { |
||||
get { |
||||
return workingDirectory; |
||||
} |
||||
|
||||
set { |
||||
workingDirectory = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the standard output returned from the process.
|
||||
/// </summary>
|
||||
public string StandardOutput { |
||||
get { |
||||
string output = String.Empty; |
||||
if (standardOutputReader != null) { |
||||
output = standardOutputReader.Output; |
||||
} |
||||
return output; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the standard error output returned from the process.
|
||||
/// </summary>
|
||||
public string StandardError { |
||||
get { |
||||
string output = String.Empty; |
||||
if (standardErrorReader != null) { |
||||
output = standardErrorReader.Output; |
||||
} |
||||
return output; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Releases resources held by the <see cref="ProcessRunner"/>
|
||||
/// </summary>
|
||||
public void Dispose() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the process exit code.
|
||||
/// </summary>
|
||||
public int ExitCode { |
||||
get { |
||||
int exitCode = 0; |
||||
if (process != null) { |
||||
exitCode = process.ExitCode; |
||||
} |
||||
return exitCode; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Waits for the process to exit.
|
||||
/// </summary>
|
||||
public void WaitForExit() |
||||
{ |
||||
WaitForExit(Int32.MaxValue); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Waits for the process to exit.
|
||||
/// </summary>
|
||||
/// <param name="timeout">A timeout in milliseconds.</param>
|
||||
/// <returns><see langword="true"/> if the associated process has
|
||||
/// exited; otherwise, <see langword="false"/></returns>
|
||||
public bool WaitForExit(int timeout) |
||||
{ |
||||
if (process == null) { |
||||
throw new ProcessRunnerException(StringParser.Parse("${res:ICSharpCode.NAntAddIn.ProcessRunner.NoProcessRunningErrorText}")); |
||||
} |
||||
|
||||
bool exited = process.WaitForExit(timeout); |
||||
|
||||
if (exited) { |
||||
standardOutputReader.WaitForFinish(); |
||||
standardErrorReader.WaitForFinish(); |
||||
} |
||||
|
||||
return exited; |
||||
} |
||||
|
||||
public bool IsRunning { |
||||
get { |
||||
bool isRunning = false; |
||||
|
||||
if (process != null) { |
||||
isRunning = !process.HasExited; |
||||
} |
||||
|
||||
return isRunning; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Starts the process.
|
||||
/// </summary>
|
||||
/// <param name="command">The process filename.</param>
|
||||
/// <param name="arguments">The command line arguments to
|
||||
/// pass to the command.</param>
|
||||
public void Start(string command, string arguments) |
||||
{ |
||||
process = new Process(); |
||||
process.StartInfo.CreateNoWindow = true; |
||||
process.StartInfo.FileName = command; |
||||
process.StartInfo.WorkingDirectory = workingDirectory; |
||||
process.StartInfo.RedirectStandardOutput = true; |
||||
process.StartInfo.RedirectStandardError = true; |
||||
process.StartInfo.UseShellExecute = false; |
||||
process.StartInfo.Arguments = arguments; |
||||
|
||||
if (ProcessExited != null) { |
||||
process.EnableRaisingEvents = true; |
||||
process.Exited += new EventHandler(OnProcessExited); |
||||
} |
||||
|
||||
process.Start(); |
||||
|
||||
standardOutputReader = new OutputReader(process.StandardOutput); |
||||
if (OutputLineReceived != null) { |
||||
standardOutputReader.LineReceived += new LineReceivedEventHandler(OnOutputLineReceived); |
||||
} |
||||
|
||||
standardOutputReader.Start(); |
||||
|
||||
standardErrorReader = new OutputReader(process.StandardError); |
||||
if (ErrorLineReceived != null) { |
||||
standardErrorReader.LineReceived += new LineReceivedEventHandler(OnErrorLineReceived); |
||||
} |
||||
|
||||
standardErrorReader.Start(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Starts the process.
|
||||
/// </summary>
|
||||
/// <param name="command">The process filename.</param>
|
||||
public void Start(string command) |
||||
{ |
||||
Start(command, String.Empty); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Kills the running process.
|
||||
/// </summary>
|
||||
public void Kill() |
||||
{ |
||||
if (process != null) { |
||||
if (!process.HasExited) { |
||||
process.Kill(); |
||||
process.Close(); |
||||
process.Dispose(); |
||||
process = null; |
||||
standardOutputReader.WaitForFinish(); |
||||
standardErrorReader.WaitForFinish(); |
||||
} else { |
||||
process = null; |
||||
} |
||||
} |
||||
// Control-C does not seem to work.
|
||||
//GenerateConsoleCtrlEvent((int)ConsoleEvent.ControlC, 0);
|
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="ProcessExited"/> event.
|
||||
/// </summary>
|
||||
protected void OnProcessExited(object sender, EventArgs e) |
||||
{ |
||||
if (ProcessExited != null) { |
||||
|
||||
standardOutputReader.WaitForFinish(); |
||||
standardErrorReader.WaitForFinish(); |
||||
|
||||
ProcessExited(this, e); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="OutputLineReceived"/> event.
|
||||
/// </summary>
|
||||
/// <param name="sender">The event source.</param>
|
||||
/// <param name="e">The line received event arguments.</param>
|
||||
protected void OnOutputLineReceived(object sender, LineReceivedEventArgs e) |
||||
{ |
||||
if (OutputLineReceived != null) { |
||||
OutputLineReceived(this, e); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="ErrorLineReceived"/> event.
|
||||
/// </summary>
|
||||
/// <param name="sender">The event source.</param>
|
||||
/// <param name="e">The line received event arguments.</param>
|
||||
protected void OnErrorLineReceived(object sender, LineReceivedEventArgs e) |
||||
{ |
||||
if (ErrorLineReceived != null) { |
||||
ErrorLineReceived(this, e); |
||||
} |
||||
} |
||||
|
||||
enum ConsoleEvent |
||||
{ |
||||
ControlC = 0, |
||||
ControlBreak = 1 |
||||
}; |
||||
|
||||
[DllImport("kernel32.dll", SetLastError=true)] |
||||
static extern int GenerateConsoleCtrlEvent(int dwCtrlEvent, int dwProcessGroupId); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// An exception thrown by a <see cref="ProcessRunner"/>
|
||||
/// instance.
|
||||
/// </summary>
|
||||
public class ProcessRunnerException : ApplicationException |
||||
{ |
||||
public ProcessRunnerException(string message) |
||||
: base(message) |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
// <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; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// <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; |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
// <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 method in the text editor
|
||||
/// to run tests with code coverage.
|
||||
/// </summary>
|
||||
public class RunTestWithCodeCoverageCommand : 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; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// <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 System; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
public class ToggleCodeCoverageCommand : AbstractCheckableMenuCommand |
||||
{ |
||||
public override bool IsChecked { |
||||
get { |
||||
return CodeCoverageService.CodeCoverageHighlighted; |
||||
} |
||||
set { |
||||
CodeCoverageService.CodeCoverageHighlighted = value; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,144 @@
@@ -0,0 +1,144 @@
|
||||
// <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.CodeCoverage; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class AddCodeCoverageMarkersTestFixture |
||||
{ |
||||
MarkerStrategy markerStrategy; |
||||
CodeCoverageTextMarker markerOne; |
||||
CodeCoverageTextMarker markerTwo; |
||||
CodeCoverageTextMarker markerThree; |
||||
MockDocument document; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
try { |
||||
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests"); |
||||
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); |
||||
} catch (Exception) {} |
||||
|
||||
document = new MockDocument(); |
||||
string code = "\t\t{\r\n" + |
||||
"\t\t\tint count = 0;\r\n" + |
||||
"\t\t}\r\n"; |
||||
document.AddLines(code); |
||||
markerStrategy = new MarkerStrategy(document); |
||||
|
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\Foo.Tests\\bin\\Debug\\Foo.Tests.dll\" assembly=\"Foo.Tests\">\r\n" + |
||||
"\t\t<method name=\"SimpleTest\" class=\"Foo.Tests.FooTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"3\" endline=\"1\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"2\" column=\"4\" endline=\"2\" endcolumn=\"18\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"0\" line=\"3\" column=\"3\" endline=\"3\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
CodeCoverageResults results = new CodeCoverageResults(new StringReader(xml)); |
||||
CodeCoverageMethod method = results.Modules[0].Methods[0]; |
||||
CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter(); |
||||
highlighter.AddMarkers(markerStrategy, method.SequencePoints); |
||||
|
||||
foreach (CodeCoverageTextMarker marker in markerStrategy.TextMarker) { |
||||
if (markerOne == null) { |
||||
markerOne = marker; |
||||
} else if (markerTwo == null) { |
||||
markerTwo = marker; |
||||
} else if (markerThree == null) { |
||||
markerThree = marker; |
||||
} |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerCount() |
||||
{ |
||||
int count = 0; |
||||
foreach (CodeCoverageTextMarker marker in markerStrategy.TextMarker) { |
||||
count++; |
||||
} |
||||
|
||||
Assert.AreEqual(3, count); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerOneOffset() |
||||
{ |
||||
Assert.AreEqual(3, markerOne.Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerOneLength() |
||||
{ |
||||
Assert.AreEqual(1, markerOne.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerOneType() |
||||
{ |
||||
Assert.AreEqual(TextMarkerType.SolidBlock, markerOne.TextMarkerType); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerOneForeColor() |
||||
{ |
||||
Assert.AreEqual(CodeCoverageOptions.VisitedForeColor, markerOne.ForeColor); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerOneColor() |
||||
{ |
||||
Assert.AreEqual(CodeCoverageOptions.VisitedColor, markerOne.Color); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerTwoOffset() |
||||
{ |
||||
Assert.AreEqual(9, markerTwo.Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerTwoLength() |
||||
{ |
||||
Assert.AreEqual(14, markerTwo.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerThreeForeColor() |
||||
{ |
||||
Assert.AreEqual(CodeCoverageOptions.NotVisitedForeColor, markerThree.ForeColor); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerThreeColor() |
||||
{ |
||||
Assert.AreEqual(CodeCoverageOptions.NotVisitedColor, markerThree.Color); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerThreeOffset() |
||||
{ |
||||
Assert.AreEqual(27, markerThree.Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerThreeLength() |
||||
{ |
||||
Assert.AreEqual(1, markerThree.Length); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("")] |
||||
[assembly: AssemblyCopyright("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// 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.*")] |
||||
|
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.CodeCoverage.Tests</RootNamespace> |
||||
<AssemblyName>CodeCoverage.Tests</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}</ProjectGuid> |
||||
<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' "> |
||||
<OutputPath>..\..\..\..\..\bin\UnitTests\</OutputPath> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>..\..\..\..\..\bin\UnitTests\</OutputPath> |
||||
<Optimize>True</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<DebugSymbols>false</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
||||
<Reference Include="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="AssemblyInfo.cs" /> |
||||
<Compile Include="CodeCoverageResultsTestFixture.cs" /> |
||||
<Compile Include="CodeCoverageTreeViewTestFixture.cs" /> |
||||
<Compile Include="ModuleVisitedSequencePointsTestFixture.cs" /> |
||||
<Compile Include="AddCodeCoverageMarkersTestFixture.cs" /> |
||||
<Compile Include="MockDocument.cs" /> |
||||
<Compile Include="RemoveCodeCoverageMarkersTestFixture.cs" /> |
||||
<Compile Include="CodeCoverageMarkersCoverTwoLinesTestFixture.cs" /> |
||||
<Compile Include="CodeCoverageMarkersCoverMultipleLinesTestFixture.cs" /> |
||||
<Compile Include="GetSequencePointsForFileNameTestFixture.cs" /> |
||||
<Compile Include="CodeCoverageMarkersInvalidStartLineTestFixture.cs" /> |
||||
<Compile Include="CodeCoverageMarkersInvalidEndLineTestFixture.cs" /> |
||||
<Compile Include="CodeCoverageMarkersInvalidStartColumnTestFixture.cs" /> |
||||
<Compile Include="CodeCoverageMarkersInvalidEndColumnTestFixture.cs" /> |
||||
<Compile Include="NCoverSettingsTestFixture.cs" /> |
||||
<Compile Include="MbUnitResultsTestFixture.cs" /> |
||||
<EmbeddedResource Include="Strings.resources" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj"> |
||||
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project> |
||||
<Name>ICSharpCode.TextEditor</Name> |
||||
</ProjectReference> |
||||
<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\CodeCoverage.csproj"> |
||||
<Project>{B7F1A068-01F5-49E7-83EF-05DE281B09FD}</Project> |
||||
<Name>CodeCoverageAddIn</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
// <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.CodeCoverage; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CodeCoverageMarkersCoverMultipleLinesTestFixture |
||||
{ |
||||
List<CodeCoverageTextMarker> markers; |
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
try { |
||||
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests"); |
||||
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); |
||||
} catch (Exception) {} |
||||
|
||||
MockDocument document = new MockDocument(); |
||||
string code = "\t\t{\r\n" + |
||||
"\t\t\treturn \"<?xml version=\\\"1.0\\\"?>\\r\\n\" +\r\n" + |
||||
"\t\t\t\t\"<xs:schema xmlns:xs=\\\"http://www.w3.org/2001/XMLSchema\\\"\\r\\n\" +\r\n" + |
||||
"\t\t\t\t\"targetNamespace=\\\"http://www.w3schools.com\\\"\\r\\n\" +\r\n" + |
||||
"\t\t\t\t\"xmlns=\\\"http://www.w3schools.com\\\"\\r\\n\" +\r\n" + |
||||
"\t\t\t\t\"elementFormDefault=\\\"qualified\\\">\\r\\n\" +\r\n" + |
||||
"\t\t\t\t\"<xs:element name=\\\"note\\\">\\r\\n\" +\r\n" + |
||||
"\t\t\t\t\"</xs:element>\\r\\n\" +\r\n" + |
||||
"\t\t\t\t\"</xs:schema>\";\r\n" + |
||||
"\t\t}\r\n"; |
||||
document.AddLines(code); |
||||
MarkerStrategy markerStrategy = new MarkerStrategy(document); |
||||
|
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\XmlEditor\\Test\\XmlEditor.Tests.dll\" assembly=\"XmlEditor.Tests\">\r\n" + |
||||
"\t\t<method name=\"GetSchema\" class=\"XmlEditor.Tests.Schema.SingleElementSchemaTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"3\" endline=\"1\" endcolumn=\"4\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"2\" column=\"4\" endline=\"9\" endcolumn=\"20\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"10\" column=\"3\" endline=\"10\" endcolumn=\"4\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
|
||||
CodeCoverageResults results = new CodeCoverageResults(new StringReader(xml)); |
||||
CodeCoverageMethod method = results.Modules[0].Methods[0]; |
||||
CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter(); |
||||
highlighter.AddMarkers(markerStrategy, method.SequencePoints); |
||||
|
||||
markers = new List<CodeCoverageTextMarker>(); |
||||
foreach (CodeCoverageTextMarker marker in markerStrategy.TextMarker) { |
||||
markers.Add(marker); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerCount() |
||||
{ |
||||
Assert.AreEqual(10, markers.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerThreeOffset() |
||||
{ |
||||
Assert.AreEqual(48, markers[2].Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerFourOffset() |
||||
{ |
||||
Assert.AreEqual(118, markers[3].Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerNineOffset() |
||||
{ |
||||
Assert.AreEqual(338, markers[8].Offset); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,118 @@
@@ -0,0 +1,118 @@
|
||||
// <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.CodeCoverage; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CodeCoverageMarkersCoverTwoLinesTestFixture |
||||
{ |
||||
CodeCoverageTextMarker markerOne; |
||||
CodeCoverageTextMarker markerTwo; |
||||
CodeCoverageTextMarker markerThree; |
||||
CodeCoverageTextMarker markerFour; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
try { |
||||
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests"); |
||||
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); |
||||
} catch (Exception) {} |
||||
|
||||
MockDocument document = new MockDocument(); |
||||
string code = "\t\t{\r\n" + |
||||
"\t\t\tAssert.AreEqual(0, childElementCompletionData.Length, \"\" +\r\n" + |
||||
"\t\t\t \"Not expecting any child elements.\");\r\n" + |
||||
"\t\t}\r\n"; |
||||
document.AddLines(code); |
||||
MarkerStrategy markerStrategy = new MarkerStrategy(document); |
||||
|
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\XmlEditor\\Tests\\XmlEditor.Tests.dll\" assembly=\"XmlEditor.Tests\">\r\n" + |
||||
"\t\t<method name=\"NoteElementHasNoChildElements\" class=\"XmlEditor.Tests.Schema.SingleElementSchemaTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"3\" endline=\"1\" endcolumn=\"4\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"2\" column=\"4\" endline=\"3\" endcolumn=\"57\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"4\" column=\"3\" endline=\"4\" endcolumn=\"4\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
|
||||
CodeCoverageResults results = new CodeCoverageResults(new StringReader(xml)); |
||||
CodeCoverageMethod method = results.Modules[0].Methods[0]; |
||||
CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter(); |
||||
highlighter.AddMarkers(markerStrategy, method.SequencePoints); |
||||
|
||||
foreach (CodeCoverageTextMarker marker in markerStrategy.TextMarker) { |
||||
if (markerOne == null) { |
||||
markerOne = marker; |
||||
} else if (markerTwo == null) { |
||||
markerTwo = marker; |
||||
} else if (markerThree == null) { |
||||
markerThree = marker; |
||||
} else if (markerFour == null) { |
||||
markerFour = marker; |
||||
} |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerOneOffset() |
||||
{ |
||||
Assert.AreEqual(3, markerOne.Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerOneLength() |
||||
{ |
||||
Assert.AreEqual(1, markerOne.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerTwoOffset() |
||||
{ |
||||
Assert.AreEqual(9, markerTwo.Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerTwoLength() |
||||
{ |
||||
Assert.AreEqual(56, markerTwo.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerThreeOffset() |
||||
{ |
||||
Assert.AreEqual(68, markerThree.Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerThreeLength() |
||||
{ |
||||
Assert.AreEqual(56, markerThree.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerFourLength() |
||||
{ |
||||
Assert.AreEqual(1, markerFour.Length); |
||||
} |
||||
|
||||
[Test] |
||||
public void MarkerFourOffset() |
||||
{ |
||||
Assert.AreEqual(129, markerFour.Offset); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
// <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.CodeCoverage; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CodeCoverageMarkersInvalidEndColumnTestFixture |
||||
{ |
||||
List<CodeCoverageTextMarker> markers; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
try { |
||||
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests"); |
||||
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); |
||||
} catch (Exception) {} |
||||
|
||||
MockDocument document = new MockDocument(); |
||||
document.AddLines("abcdefg\r\nabc"); |
||||
MarkerStrategy markerStrategy = new MarkerStrategy(document); |
||||
|
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\XmlEditor\\Test\\XmlEditor.Tests.dll\" assembly=\"XmlEditor.Tests\">\r\n" + |
||||
"\t\t<method name=\"GetSchema\" class=\"XmlEditor.Tests.Schema.SingleElementSchemaTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"1\" endline=\"1\" endcolumn=\"9\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"1\" endline=\"1\" endcolumn=\"0\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"1\" endline=\"1\" endcolumn=\"-1\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"3\" endline=\"1\" endcolumn=\"2\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
|
||||
CodeCoverageResults results = new CodeCoverageResults(new StringReader(xml)); |
||||
CodeCoverageMethod method = results.Modules[0].Methods[0]; |
||||
CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter(); |
||||
highlighter.AddMarkers(markerStrategy, method.SequencePoints); |
||||
|
||||
markers = new List<CodeCoverageTextMarker>(); |
||||
foreach (CodeCoverageTextMarker marker in markerStrategy.TextMarker) { |
||||
markers.Add(marker); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void NoMarkersAdded() |
||||
{ |
||||
Assert.AreEqual(0, markers.Count, |
||||
"Should not be any markers added since all sequence point end columns are invalid."); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
// <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.CodeCoverage; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CodeCoverageMarkersInvalidEndLineTestFixture |
||||
{ |
||||
List<CodeCoverageTextMarker> markers; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
try { |
||||
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests"); |
||||
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); |
||||
} catch (Exception) {} |
||||
|
||||
MockDocument document = new MockDocument(); |
||||
// Give doc 3 lines (end line seems to be counted as an extra line).
|
||||
document.AddLines("abc\r\ndef"); |
||||
MarkerStrategy markerStrategy = new MarkerStrategy(document); |
||||
|
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\XmlEditor\\Test\\XmlEditor.Tests.dll\" assembly=\"XmlEditor.Tests\">\r\n" + |
||||
"\t\t<method name=\"GetSchema\" class=\"XmlEditor.Tests.Schema.SingleElementSchemaTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"3\" column=\"3\" endline=\"4\" endcolumn=\"4\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"4\" endline=\"5\" endcolumn=\"20\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"4\" endline=\"-1\" endcolumn=\"20\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"4\" endline=\"0\" endcolumn=\"20\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
|
||||
CodeCoverageResults results = new CodeCoverageResults(new StringReader(xml)); |
||||
CodeCoverageMethod method = results.Modules[0].Methods[0]; |
||||
CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter(); |
||||
highlighter.AddMarkers(markerStrategy, method.SequencePoints); |
||||
|
||||
markers = new List<CodeCoverageTextMarker>(); |
||||
foreach (CodeCoverageTextMarker marker in markerStrategy.TextMarker) { |
||||
markers.Add(marker); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void NoMarkersAdded() |
||||
{ |
||||
Assert.AreEqual(0, markers.Count, |
||||
"Should not be any markers added since all sequence point end lines are invalid."); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
// <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.CodeCoverage; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CodeCoverageMarkersInvalidStartColumnTestFixture |
||||
{ |
||||
List<CodeCoverageTextMarker> markers; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
try { |
||||
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests"); |
||||
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); |
||||
} catch (Exception) {} |
||||
|
||||
MockDocument document = new MockDocument(); |
||||
document.AddLines("abcdefg\r\nabcdefg"); |
||||
MarkerStrategy markerStrategy = new MarkerStrategy(document); |
||||
|
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\XmlEditor\\Test\\XmlEditor.Tests.dll\" assembly=\"XmlEditor.Tests\">\r\n" + |
||||
"\t\t<method name=\"GetSchema\" class=\"XmlEditor.Tests.Schema.SingleElementSchemaTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"0\" endline=\"1\" endcolumn=\"1\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"-1\" endline=\"1\" endcolumn=\"1\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"8\" endline=\"1\" endcolumn=\"20\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
|
||||
CodeCoverageResults results = new CodeCoverageResults(new StringReader(xml)); |
||||
CodeCoverageMethod method = results.Modules[0].Methods[0]; |
||||
CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter(); |
||||
highlighter.AddMarkers(markerStrategy, method.SequencePoints); |
||||
|
||||
markers = new List<CodeCoverageTextMarker>(); |
||||
foreach (CodeCoverageTextMarker marker in markerStrategy.TextMarker) { |
||||
markers.Add(marker); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void NoMarkersAdded() |
||||
{ |
||||
Assert.AreEqual(0, markers.Count, |
||||
"Should not be any markers added since all sequence point start columns are invalid."); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
// <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.CodeCoverage; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CodeCoverageMarkersInvalidStartLineTestFixture |
||||
{ |
||||
List<CodeCoverageTextMarker> markers; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
try { |
||||
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests"); |
||||
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); |
||||
} catch (Exception) {} |
||||
|
||||
MockDocument document = new MockDocument(); |
||||
MarkerStrategy markerStrategy = new MarkerStrategy(document); |
||||
|
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\XmlEditor\\Test\\XmlEditor.Tests.dll\" assembly=\"XmlEditor.Tests\">\r\n" + |
||||
"\t\t<method name=\"GetSchema\" class=\"XmlEditor.Tests.Schema.SingleElementSchemaTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"0\" column=\"3\" endline=\"0\" endcolumn=\"4\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"-1\" column=\"4\" endline=\"9\" endcolumn=\"20\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"10\" column=\"3\" endline=\"10\" endcolumn=\"4\" document=\"c:\\Projects\\XmlEditor\\Test\\Schema\\SingleElementSchemaTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
|
||||
CodeCoverageResults results = new CodeCoverageResults(new StringReader(xml)); |
||||
CodeCoverageMethod method = results.Modules[0].Methods[0]; |
||||
CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter(); |
||||
highlighter.AddMarkers(markerStrategy, method.SequencePoints); |
||||
|
||||
markers = new List<CodeCoverageTextMarker>(); |
||||
foreach (CodeCoverageTextMarker marker in markerStrategy.TextMarker) { |
||||
markers.Add(marker); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void NoMarkersAdded() |
||||
{ |
||||
Assert.AreEqual(0, markers.Count, |
||||
"Should not be any markers added since all sequence point start lines are invalid."); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,148 @@
@@ -0,0 +1,148 @@
|
||||
// <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.CodeCoverage; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CodeCoverageResultsTestFixture |
||||
{ |
||||
CodeCoverageModule module; |
||||
CodeCoverageResults results; |
||||
CodeCoverageMethod method; |
||||
CodeCoverageSequencePoint point1; |
||||
CodeCoverageSequencePoint point2; |
||||
CodeCoverageSequencePoint point3; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\Foo.Tests\\bin\\Debug\\Foo.Tests.dll\" assembly=\"Foo.Tests\">\r\n" + |
||||
"\t\t<method name=\"SimpleTest\" class=\"Foo.Tests.FooTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"20\" column=\"3\" endline=\"20\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"21\" column=\"13\" endline=\"21\" endcolumn=\"32\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"0\" line=\"24\" column=\"3\" endline=\"24\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
results = new CodeCoverageResults(new StringReader(xml)); |
||||
module = results.Modules[0]; |
||||
method = module.Methods[0]; |
||||
|
||||
point1 = method.SequencePoints[0]; |
||||
point2 = method.SequencePoints[1]; |
||||
point3 = method.SequencePoints[2]; |
||||
} |
||||
|
||||
[Test] |
||||
public void AssemblyName() |
||||
{ |
||||
Assert.AreEqual("Foo.Tests", module.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void ModuleCount() |
||||
{ |
||||
Assert.AreEqual(1, results.Modules.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void MethodCount() |
||||
{ |
||||
Assert.AreEqual(1, module.Methods.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void MethodName() |
||||
{ |
||||
Assert.AreEqual("SimpleTest", method.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void FullClassName() |
||||
{ |
||||
Assert.AreEqual("Foo.Tests.FooTestFixture", method.FullClassName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ClassName() |
||||
{ |
||||
Assert.AreEqual("FooTestFixture", method.ClassName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ClassNamespace() |
||||
{ |
||||
Assert.AreEqual("Foo.Tests", method.ClassNamespace); |
||||
} |
||||
|
||||
[Test] |
||||
public void SequencePointCount() |
||||
{ |
||||
Assert.AreEqual(3, method.SequencePoints.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void SequencePointDocument() |
||||
{ |
||||
Assert.AreEqual("c:\\Projects\\Foo\\FooTestFixture.cs", point1.Document); |
||||
} |
||||
|
||||
[Test] |
||||
public void SequencePoint1VisitCount() |
||||
{ |
||||
Assert.AreEqual(1, point1.VisitCount); |
||||
} |
||||
|
||||
[Test] |
||||
public void SequencePoint3VisitCount() |
||||
{ |
||||
Assert.AreEqual(0, point3.VisitCount); |
||||
} |
||||
|
||||
[Test] |
||||
public void SequencePoint1Line() |
||||
{ |
||||
Assert.AreEqual(20, point1.Line); |
||||
} |
||||
|
||||
[Test] |
||||
public void SequencePoint1Column() |
||||
{ |
||||
Assert.AreEqual(3, point1.Column); |
||||
} |
||||
|
||||
[Test] |
||||
public void SequencePoint1EndLine() |
||||
{ |
||||
Assert.AreEqual(20, point1.EndLine); |
||||
} |
||||
|
||||
[Test] |
||||
public void SequencePoint1EndColumn() |
||||
{ |
||||
Assert.AreEqual(4, point1.EndColumn); |
||||
} |
||||
|
||||
[Test] |
||||
public void MethodVisitedCount() |
||||
{ |
||||
Assert.AreEqual(2, method.VisitedSequencePointsCount); |
||||
} |
||||
|
||||
[Test] |
||||
public void MethodNotVisitedCount() |
||||
{ |
||||
Assert.AreEqual(1, method.NotVisitedSequencePointsCount); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,166 @@
@@ -0,0 +1,166 @@
|
||||
// <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.SharpDevelop.Gui; |
||||
using ICSharpCode.CodeCoverage; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CodeCoverageTreeViewTestFixture |
||||
{ |
||||
TreeNodeCollection nodes; |
||||
CodeCoverageModuleTreeNode fooModuleNode; |
||||
CodeCoverageModuleTreeNode barModuleNode; |
||||
CodeCoverageClassTreeNode class1TreeNode; |
||||
CodeCoverageMethodTreeNode method1TreeNode; |
||||
CodeCoverageMethodTreeNode method2TreeNode; |
||||
CodeCoverageNamespaceTreeNode namespace1TreeNode; |
||||
CodeCoverageNamespaceTreeNode namespace2TreeNode; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
List<CodeCoverageModule> modules = new List<CodeCoverageModule>(); |
||||
CodeCoverageModule m1 = new CodeCoverageModule("Foo.Tests"); |
||||
CodeCoverageMethod method1 = new CodeCoverageMethod("Test1", "Foo.Tests.TestFixture1"); |
||||
method1.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\TestFixture1.cs", 1, 1, 0, 2, 1)); |
||||
method1.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\TestFixture1.cs", 0, 2, 2, 3, 4)); |
||||
CodeCoverageMethod method2 = new CodeCoverageMethod("Test2", "Foo.Tests.TestFixture1"); |
||||
|
||||
m1.Methods.Add(method1); |
||||
m1.Methods.Add(method2); |
||||
|
||||
CodeCoverageModule m2 = new CodeCoverageModule("Bar.Tests"); |
||||
|
||||
modules.Add(m1); |
||||
modules.Add(m2); |
||||
|
||||
using (CodeCoverageTreeView treeView = new CodeCoverageTreeView()) { |
||||
treeView.AddModules(modules); |
||||
treeView.ExpandAll(); |
||||
nodes = treeView.Nodes; |
||||
} |
||||
|
||||
fooModuleNode = (CodeCoverageModuleTreeNode)nodes[0]; |
||||
barModuleNode = (CodeCoverageModuleTreeNode)nodes[1]; |
||||
|
||||
namespace1TreeNode = (CodeCoverageNamespaceTreeNode)fooModuleNode.Nodes[0]; |
||||
namespace2TreeNode = (CodeCoverageNamespaceTreeNode)namespace1TreeNode.Nodes[0]; |
||||
|
||||
class1TreeNode = (CodeCoverageClassTreeNode)namespace2TreeNode.Nodes[0]; |
||||
method1TreeNode = (CodeCoverageMethodTreeNode)class1TreeNode.Nodes[0]; |
||||
method2TreeNode = (CodeCoverageMethodTreeNode)class1TreeNode.Nodes[1]; |
||||
} |
||||
|
||||
[Test] |
||||
public void RootNodesCount() |
||||
{ |
||||
Assert.AreEqual(2, nodes.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void FooModuleTreeNodeText() |
||||
{ |
||||
Assert.AreEqual("Foo.Tests (50%)", fooModuleNode.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void FooModuleTreeNodeForeColor() |
||||
{ |
||||
Assert.AreEqual(CodeCoverageTreeNode.PartialCoverageTextColor, fooModuleNode.ForeColor); |
||||
} |
||||
|
||||
[Test] |
||||
public void FooModuleChildNodesCount() |
||||
{ |
||||
Assert.AreEqual(1, fooModuleNode.Nodes.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void FooModuleTreeNodeName() |
||||
{ |
||||
Assert.AreEqual("Foo.Tests", fooModuleNode.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void BarModuleTreeNodeText() |
||||
{ |
||||
Assert.AreEqual("Bar.Tests", barModuleNode.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void Class1TreeNodeName() |
||||
{ |
||||
Assert.AreEqual("TestFixture1", class1TreeNode.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void Class1TreeNodeText() |
||||
{ |
||||
Assert.AreEqual("TestFixture1 (50%)", class1TreeNode.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void Namespace1TreeNodeName() |
||||
{ |
||||
Assert.AreEqual("Foo", namespace1TreeNode.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void Namespace2TreeNodeName() |
||||
{ |
||||
Assert.AreEqual("Tests", namespace2TreeNode.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void Namespace1TreeNodeText() |
||||
{ |
||||
Assert.AreEqual("Foo (50%)", namespace1TreeNode.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void Namespace2TreeNodeText() |
||||
{ |
||||
Assert.AreEqual("Tests (50%)", namespace2TreeNode.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void Method1TreeNodeName() |
||||
{ |
||||
Assert.AreEqual("Test1", method1TreeNode.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void Method1TreeNodeText() |
||||
{ |
||||
Assert.AreEqual("Test1 (50%)", method1TreeNode.Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void Method2TreeNodeText() |
||||
{ |
||||
Assert.AreEqual("Test2", method2TreeNode.Name); |
||||
} |
||||
|
||||
[Test] |
||||
public void Class1TreeNodeChildNodesCount() |
||||
{ |
||||
Assert.AreEqual(2, class1TreeNode.Nodes.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void Namespace2TreeNodeChildNodesCount() |
||||
{ |
||||
Assert.AreEqual(1, namespace2TreeNode.Nodes.Count); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
// <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.CodeCoverage; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class GetSequencePointsForFileNameTestFixture |
||||
{ |
||||
CodeCoverageResults results; |
||||
List<CodeCoverageSequencePoint> fooTestFixtureSequencePoints; |
||||
List<CodeCoverageSequencePoint> barTestFixtureSequencePoints; |
||||
List<CodeCoverageSequencePoint> simpleTestFixtureSequencePoints; |
||||
List<CodeCoverageSequencePoint> nonExistentFileNameSequencePoints; |
||||
|
||||
[SetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\Foo.Tests\\bin\\Debug\\Foo.Tests.dll\" assembly=\"Foo.Tests\">\r\n" + |
||||
"\t\t<method name=\"FooTest\" class=\"Foo.Tests.FooTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"20\" column=\"3\" endline=\"20\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t\t<method name=\"SimpleTest2\" class=\"Foo.Tests.SimpleTestFixture2\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"20\" column=\"3\" endline=\"20\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\SimpleTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t\t<method name=\"SimpleTest3\" class=\"Foo.Tests.SimpleTestFixture3\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"20\" column=\"3\" endline=\"20\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\SimpleTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\Foo.Tests\\bin\\Debug\\Bar.Tests.dll\" assembly=\"Bar.Tests\">\r\n" + |
||||
"\t\t<method name=\"SimpleTest2\" class=\"Foo.Tests.BarTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"20\" column=\"3\" endline=\"20\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\BarTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
|
||||
results = new CodeCoverageResults(new StringReader(xml)); |
||||
fooTestFixtureSequencePoints = results.GetSequencePoints(@"c:\Projects\Foo\FooTestFixture.cs"); |
||||
barTestFixtureSequencePoints = results.GetSequencePoints(@"c:\Projects\Foo\BarTestFixture.cs"); |
||||
simpleTestFixtureSequencePoints = results.GetSequencePoints(@"c:\Projects\Foo\SimpleTestFixture.cs"); |
||||
nonExistentFileNameSequencePoints = results.GetSequencePoints(@"c:\Projects\Foo\NoSuchTestFixture.cs"); |
||||
} |
||||
|
||||
[Test] |
||||
public void FooTestFixtureHasSequencePoint() |
||||
{ |
||||
Assert.AreEqual(1, fooTestFixtureSequencePoints.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void BarTestFixtureHasSequencePoint() |
||||
{ |
||||
Assert.AreEqual(1, barTestFixtureSequencePoints.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void SimpleTestFixtureHasSequencePoints() |
||||
{ |
||||
Assert.AreEqual(2, simpleTestFixtureSequencePoints.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void NonExistentFileNameHasNoSequencePoints() |
||||
{ |
||||
Assert.AreEqual(0, nonExistentFileNameSequencePoints.Count); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,121 @@
@@ -0,0 +1,121 @@
|
||||
// <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.CodeCoverage; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.IO; |
||||
using System.Resources; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MbUnitResultsTestFixture |
||||
{ |
||||
Task errorTask; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
// Add NUnitPad TestFailedMessage string resource since this resource
|
||||
// contains a format string that has parameters that are otherwise not
|
||||
// set.
|
||||
ResourceManager resourceManager = new ResourceManager("ICSharpCode.CodeCoverage.Tests.Strings", GetType().Assembly); |
||||
ResourceService.RegisterNeutralStrings(resourceManager); |
||||
|
||||
MbUnitResults results = new MbUnitResults(new StringReader(GetMbUnitResultsXml())); |
||||
errorTask = results.Tasks[0]; |
||||
} |
||||
|
||||
[Test] |
||||
public void IsErrorTask() |
||||
{ |
||||
Assert.AreEqual(TaskType.Error, errorTask.TaskType); |
||||
} |
||||
|
||||
[Test] |
||||
public void ErrorTaskFileName() |
||||
{ |
||||
Assert.IsTrue(FileUtility.IsEqualFileName(@"c:\test\NunitFoo\NunitFoo.Tests\FooTest.cs", errorTask.FileName)); |
||||
} |
||||
|
||||
[Test] |
||||
public void ErrorTaskLine() |
||||
{ |
||||
Assert.AreEqual(21, errorTask.Line); |
||||
} |
||||
|
||||
[Test] |
||||
public void ErrorTaskColumn() |
||||
{ |
||||
Assert.AreEqual(0, errorTask.Column); |
||||
} |
||||
|
||||
[Test] |
||||
public void TaskDescription() |
||||
{ |
||||
string description = StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] { |
||||
{"TestCase", "FooTest.Foo"}, |
||||
{"Message", "Foo failed"} |
||||
}); |
||||
|
||||
Assert.AreEqual(description, errorTask.Description); |
||||
} |
||||
|
||||
string GetMbUnitResultsXml() |
||||
{ |
||||
return "<report-result xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" date=\"2006-01-29T23:00:55.8368928+00:00\">\r\n" + |
||||
" <counter duration=\"0.0300432\" run-count=\"2\" success-count=\"1\" failure-count=\"1\" ignore-count=\"0\" skip-count=\"0\" assert-count=\"0\" />\r\n" + |
||||
" <assemblies>\r\n" + |
||||
" <assembly name=\"NunitFoo.Tests\" location=\"file:///C:/test/NunitFoo/NunitFoo.Tests/bin/Debug/NunitFoo.Tests.DLL\" full-name=\"NunitFoo.Tests, Version=1.0.2220.32532, Culture=neutral, PublicKeyToken=null\">\r\n" + |
||||
" <counter duration=\"0.0300432\" run-count=\"2\" success-count=\"1\" failure-count=\"1\" ignore-count=\"0\" skip-count=\"0\" assert-count=\"0\" />\r\n" + |
||||
" <version major=\"1\" minor=\"0\" build=\"2220\" revision=\"32532\" />\r\n" + |
||||
" <namespaces>\r\n" + |
||||
" <namespace name=\"NunitFoo\">\r\n" + |
||||
" <counter duration=\"0.0300432\" run-count=\"2\" success-count=\"1\" failure-count=\"1\" ignore-count=\"0\" skip-count=\"0\" assert-count=\"0\" />\r\n" + |
||||
" <namespaces>\r\n" + |
||||
" <namespace name=\"NunitFoo.Tests\">\r\n" + |
||||
" <counter duration=\"0.0300432\" run-count=\"2\" success-count=\"1\" failure-count=\"1\" ignore-count=\"0\" skip-count=\"0\" assert-count=\"0\" />\r\n" + |
||||
" <namespaces />\r\n" + |
||||
" <fixtures>\r\n" + |
||||
" <fixture name=\"FooTest\" type=\"NunitFoo.Tests.FooTest\">\r\n" + |
||||
" <counter duration=\"0.0300432\" run-count=\"2\" success-count=\"1\" failure-count=\"1\" ignore-count=\"0\" skip-count=\"0\" assert-count=\"0\" />\r\n" + |
||||
" <description />\r\n" + |
||||
" <runs>\r\n" + |
||||
" <run name=\"FooTest.Foo\" result=\"failure\" assert-count=\"0\" duration=\"0.0300432\" memory=\"8192\">\r\n" + |
||||
" <invokers />\r\n" + |
||||
" <warnings />\r\n" + |
||||
" <asserts />\r\n" + |
||||
" <Description />\r\n" + |
||||
" <console-out />\r\n" + |
||||
" <console-error />\r\n" + |
||||
" <exception type=\"NUnit.Framework.AssertionException\">\r\n" + |
||||
" <properties>\r\n" + |
||||
" <property name=\"TargetSite\" value=\"Void Fail(System.String, System.Object[])\" />\r\n" + |
||||
" <property name=\"HelpLink\" value=\"null\" />\r\n" + |
||||
" </properties>\r\n" + |
||||
" <message>Foo failed</message>\r\n" + |
||||
" <source>nunit.framework</source>\r\n" + |
||||
" <stack-trace> at NUnit.Framework.Assert.Fail(String message, Object[] args)\r\n" + |
||||
" at NUnit.Framework.Assert.Fail(String message)\r\n" + |
||||
" at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22</stack-trace>\r\n" + |
||||
" </exception>\r\n" + |
||||
" </run>\r\n" + |
||||
" </runs>\r\n" + |
||||
" </fixture>\r\n" + |
||||
" </fixtures>\r\n" + |
||||
" </namespace>\r\n" + |
||||
" </namespaces>\r\n" + |
||||
" </namespace>\r\n" + |
||||
" </namespaces>\r\n" + |
||||
" </assembly>\r\n" + |
||||
" </assemblies>\r\n" + |
||||
"</report-result>"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,276 @@
@@ -0,0 +1,276 @@
|
||||
// <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.TextEditor.Document; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
/// <summary>
|
||||
/// Helper class that implements the Text Editor library's IDocument interface.
|
||||
/// </summary>
|
||||
public class MockDocument : IDocument |
||||
{ |
||||
List<LineSegment> lineSegments = new List<LineSegment>(); |
||||
|
||||
public MockDocument() |
||||
{ |
||||
} |
||||
|
||||
public event EventHandler UpdateCommited; |
||||
|
||||
public event DocumentEventHandler DocumentAboutToBeChanged; |
||||
|
||||
public event DocumentEventHandler DocumentChanged; |
||||
|
||||
public event EventHandler TextContentChanged; |
||||
|
||||
public void AddLines(string code) |
||||
{ |
||||
int offset = 0; |
||||
string[] lines = code.Split('\n'); |
||||
foreach (string line in lines) { |
||||
int delimiterLength = 1; |
||||
if (line.Length > 0 && line[line.Length - 1] == '\r') { |
||||
delimiterLength = 2; |
||||
} |
||||
LineSegment lineSegment = new LineSegment(offset, offset + line.Length, delimiterLength); |
||||
lineSegments.Add(lineSegment); |
||||
offset += line.Length + lineSegment.DelimiterLength - 1; |
||||
} |
||||
} |
||||
|
||||
public ITextEditorProperties TextEditorProperties { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public ICSharpCode.TextEditor.Undo.UndoStack UndoStack { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool ReadOnly { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IFormattingStrategy FormattingStrategy { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public ITextBufferStrategy TextBufferStrategy { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public FoldingManager FoldingManager { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public IHighlightingStrategy HighlightingStrategy { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public BookmarkManager BookmarkManager { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public ICustomLineManager CustomLineManager { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public MarkerStrategy MarkerStrategy { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public System.Collections.Generic.List<LineSegment> LineSegmentCollection { |
||||
get { |
||||
return lineSegments; |
||||
} |
||||
} |
||||
|
||||
public int TotalNumberOfLines { |
||||
get { |
||||
if (lineSegments.Count == 0) { |
||||
return 1; |
||||
} |
||||
|
||||
return ((LineSegment)lineSegments[lineSegments.Count - 1]).DelimiterLength > 0 ? lineSegments.Count + 1 : lineSegments.Count; |
||||
} |
||||
} |
||||
|
||||
public string TextContent { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int TextLength { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public System.Collections.Generic.List<ICSharpCode.TextEditor.TextAreaUpdate> UpdateQueue { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public void UpdateSegmentListOnDocumentChange<T>(System.Collections.Generic.List<T> list, DocumentEventArgs e) where T : ISegment |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public int GetLineNumberForOffset(int offset) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public LineSegment GetLineSegmentForOffset(int offset) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public LineSegment GetLineSegment(int lineNumber) |
||||
{ |
||||
return lineSegments[lineNumber]; |
||||
} |
||||
|
||||
public int GetFirstLogicalLine(int lineNumber) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public int GetLastLogicalLine(int lineNumber) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public int GetVisibleLine(int lineNumber) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public int GetNextVisibleLineAbove(int lineNumber, int lineCount) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public int GetNextVisibleLineBelow(int lineNumber, int lineCount) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Insert(int offset, string text) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Remove(int offset, int length) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Replace(int offset, int length, string text) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public char GetCharAt(int offset) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public string GetText(int offset, int length) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public string GetText(ISegment segment) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public System.Drawing.Point OffsetToPosition(int offset) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public int PositionToOffset(System.Drawing.Point p) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void RequestUpdate(ICSharpCode.TextEditor.TextAreaUpdate update) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void CommitUpdate() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
void OnUpdateCommited() |
||||
{ |
||||
if (UpdateCommited != null) { |
||||
} |
||||
} |
||||
|
||||
void OnDocumentAboutToBeChanged() |
||||
{ |
||||
if (DocumentAboutToBeChanged != null) { |
||||
} |
||||
} |
||||
|
||||
void OnDocumentChanged() |
||||
{ |
||||
if (DocumentChanged != null) { |
||||
} |
||||
} |
||||
|
||||
void OnTextContentChanged() |
||||
{ |
||||
if (TextContentChanged != null) { |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
// <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.CodeCoverage; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class ModuleVisitedSequencePointsTestFixture |
||||
{ |
||||
CodeCoverageModule fooModule; |
||||
CodeCoverageModule barModule; |
||||
CodeCoverageResults results; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\Foo.Tests\\bin\\Debug\\Foo.Tests.dll\" assembly=\"Foo.Tests\">\r\n" + |
||||
"\t\t<method name=\"SimpleTest1\" class=\"Foo.Tests.FooTestFixture1\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"12\" line=\"20\" column=\"3\" endline=\"20\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"4\" line=\"21\" column=\"13\" endline=\"21\" endcolumn=\"32\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"0\" line=\"24\" column=\"3\" endline=\"24\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t\t<method name=\"SimpleTest2\" class=\"Foo.Tests.FooTestFixture2\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"20\" column=\"3\" endline=\"20\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture2.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"10\" line=\"21\" column=\"13\" endline=\"21\" endcolumn=\"32\" document=\"c:\\Projects\\Foo\\FooTestFixture2.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"0\" line=\"24\" column=\"3\" endline=\"24\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture2.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\Foo.Tests\\bin\\Debug\\Bar.Tests.dll\" assembly=\"Bar.Tests\">\r\n" + |
||||
"\t\t<method name=\"SimpleTest3\" class=\"Bar.Tests.FooTestFixture3\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"5\" line=\"20\" column=\"3\" endline=\"20\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\BarTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"21\" column=\"13\" endline=\"21\" endcolumn=\"32\" document=\"c:\\Projects\\Foo\\BarTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"0\" line=\"24\" column=\"3\" endline=\"24\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\BarTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
results = new CodeCoverageResults(new StringReader(xml)); |
||||
fooModule = results.Modules[0]; |
||||
barModule = results.Modules[1]; |
||||
} |
||||
|
||||
[Test] |
||||
public void FooModuleVisitedCount() |
||||
{ |
||||
Assert.AreEqual(4, fooModule.VisitedSequencePointsCount); |
||||
} |
||||
|
||||
[Test] |
||||
public void FooModuleNotVisitedCount() |
||||
{ |
||||
Assert.AreEqual(2, fooModule.NotVisitedSequencePointsCount); |
||||
} |
||||
|
||||
[Test] |
||||
public void BarModuleVisitedCount() |
||||
{ |
||||
Assert.AreEqual(2, barModule.VisitedSequencePointsCount); |
||||
} |
||||
|
||||
[Test] |
||||
public void BarModuleNotVisitedCount() |
||||
{ |
||||
Assert.AreEqual(1, barModule.NotVisitedSequencePointsCount); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// <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.CodeCoverage; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class NCoverSettingsTestFixture |
||||
{ |
||||
NCoverSettings settings; |
||||
NCoverSettings savedSettings; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
settings = new NCoverSettings(); |
||||
settings.AssemblyList = "MyNamespace.Foo; MyNamespace.Bar"; |
||||
StringBuilder savedSettingsXml = new StringBuilder(); |
||||
settings.Save(new StringWriter(savedSettingsXml)); |
||||
savedSettings = new NCoverSettings(new StringReader(savedSettingsXml.ToString())); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsAssemblyListSaved() |
||||
{ |
||||
Assert.AreEqual(settings.AssemblyList, savedSettings.AssemblyList); |
||||
} |
||||
|
||||
[Test] |
||||
public void NCoverSettingsFileName() |
||||
{ |
||||
MSBuildProject project = new MSBuildProject(); |
||||
project.FileName = @"C:\temp\test.csproj"; |
||||
|
||||
Assert.AreEqual(@"C:\temp\test.NCover.Settings", NCoverSettings.GetFileName(project)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,97 @@
@@ -0,0 +1,97 @@
|
||||
// <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.CodeCoverage; |
||||
using ICSharpCode.TextEditor.Document; |
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class RemoveCodeCoverageMarkersTestFixture |
||||
{ |
||||
MarkerStrategy markerStrategy; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpTestFixture() |
||||
{ |
||||
try { |
||||
string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests"); |
||||
PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests"); |
||||
} catch (Exception) {} |
||||
|
||||
MockDocument document = new MockDocument(); |
||||
string code = "\t\t{\r\n" + |
||||
"\t\t\tint count = 0;\r\n" + |
||||
"\t\t}\r\n"; |
||||
document.AddLines(code); |
||||
markerStrategy = new MarkerStrategy(document); |
||||
|
||||
string xml = "<coverage>\r\n" + |
||||
"\t<module name=\"C:\\Projects\\Foo.Tests\\bin\\Debug\\Foo.Tests.dll\" assembly=\"Foo.Tests\">\r\n" + |
||||
"\t\t<method name=\"SimpleTest\" class=\"Foo.Tests.FooTestFixture\">\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"1\" column=\"3\" endline=\"1\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"1\" line=\"2\" column=\"4\" endline=\"2\" endcolumn=\"18\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t\t<seqpnt visitcount=\"0\" line=\"3\" column=\"3\" endline=\"3\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||
"\t\t</method>\r\n" + |
||||
"\t</module>\r\n" + |
||||
"</coverage>"; |
||||
CodeCoverageResults results = new CodeCoverageResults(new StringReader(xml)); |
||||
CodeCoverageMethod method = results.Modules[0].Methods[0]; |
||||
CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter(); |
||||
highlighter.AddMarkers(markerStrategy, method.SequencePoints); |
||||
|
||||
// Add non-code coverage markers.
|
||||
markerStrategy.AddMarker(new TextMarker(0, 2, TextMarkerType.Underlined)); |
||||
markerStrategy.AddMarker(new TextMarker(4, 5, TextMarkerType.Underlined)); |
||||
} |
||||
|
||||
[Test] |
||||
public void RemoveCodeCoverageMarkers() |
||||
{ |
||||
// Check that code coverage markers exist.
|
||||
Assert.IsTrue(ContainsCodeCoverageMarkers(markerStrategy)); |
||||
|
||||
// Remove code coverage markers.
|
||||
CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter(); |
||||
highlighter.RemoveMarkers(markerStrategy); |
||||
|
||||
// Check that code coverage markers have been removed.
|
||||
Assert.IsFalse(ContainsCodeCoverageMarkers(markerStrategy)); |
||||
|
||||
// Check that non-code coverage markers still exist.
|
||||
Assert.IsTrue(ContainsNonCodeCoverageMarkers(markerStrategy)); |
||||
} |
||||
|
||||
static bool ContainsCodeCoverageMarkers(MarkerStrategy markerStrategy) |
||||
{ |
||||
foreach (TextMarker marker in markerStrategy.TextMarker) { |
||||
if (marker is CodeCoverageTextMarker) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
static bool ContainsNonCodeCoverageMarkers(MarkerStrategy markerStrategy) |
||||
{ |
||||
int count = 0; |
||||
foreach (TextMarker marker in markerStrategy.TextMarker) { |
||||
if (marker is CodeCoverageTextMarker) { |
||||
return false; |
||||
} |
||||
count++; |
||||
} |
||||
return count > 0; |
||||
} |
||||
|
||||
} |
||||
} |
Binary file not shown.
@ -1,6 +1,16 @@
@@ -1,6 +1,16 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||
# SharpDevelop 2.0.0.339 |
||||
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 |
||||
|
Binary file not shown.
Loading…
Reference in new issue