Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@350 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
46 changed files with 44 additions and 998 deletions
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.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("NUnitPad Addin")] |
||||
[assembly: AssemblyDescription("Addin to launch NUnit tests inside SharpDevelop")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("www.icsharpcode.net")] |
||||
[assembly: AssemblyProduct("SharpDevelop")] |
||||
[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("2.0.0.348")] |
||||
|
||||
// The following attributes specify the key for the sign of your assembly. See the
|
||||
// .NET Framework documentation for more information about signing.
|
||||
// This is not required, if you don't want signing let these attributes like they're.
|
||||
[assembly: AssemblyDelaySign(false)] |
||||
[assembly: AssemblyKeyFile("")] |
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
<AddIn |
||||
name = "NUnit-Addin" |
||||
author = "Mike Krueger" |
||||
copyright = "GPL" |
||||
url = "http://www.icsharpcode.net" |
||||
description = "Integrated NUnit test runner for #Develop" |
||||
version = "1.0.0" |
||||
> |
||||
<Runtime> |
||||
<Import assembly="NUnitPad.dll"/> |
||||
</Runtime> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/Pads"> |
||||
<Pad id = "NUnitPad" |
||||
category = "Tools" |
||||
title = "${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}" |
||||
icon = "PadIcons.UnitTest" |
||||
shortcut = "Control|Alt|N" |
||||
class = "ICSharpCode.NUnitPad.NUnitPadContent"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectNode"> |
||||
<MenuItem id = "RunTests" |
||||
insertafter ="AddSeparator" |
||||
insertbefore ="Separator2" |
||||
label = "${res:ProjectComponent.ContextMenu.RunTests}" |
||||
class = "ICSharpCode.NUnitPad.RunTestsInProject"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/MainMenu/Project"> |
||||
<Condition name = "ProjectActive" activeproject="*" action="Disable"> |
||||
<MenuItem id = "RunTests" |
||||
label = "${res:XML.MainMenu.ProjectMenu.RunTests}" |
||||
class = "ICSharpCode.NUnitPad.RunTestsInProject"/> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
|
||||
<Path name = "/NUnitPad/TestTreeView/ContextMenu"> |
||||
<Condition name = "Ownerstate" ownerstate="TestItemSelected"> |
||||
<MenuItem id = "Run" |
||||
label = "${res:NUnitPad.NUnitPadContent.RunTestsContextMenuLabel}" |
||||
class = "ICSharpCode.NUnitPad.RunTestsCommand"/> |
||||
</Condition> |
||||
<Condition name = "Ownerstate" ownerstate="SourceCodeItemSelected"> |
||||
<MenuItem id = "GotoDefinition" |
||||
label = "${res:NUnitPad.NUnitPadContent.GotoDefinitionContextMenuLabel}" |
||||
class = "ICSharpCode.NUnitPad.GotoDefinitionCommand"/> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
</AddIn> |
@ -1,82 +0,0 @@
@@ -1,82 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProductVersion>8.0.41115</ProductVersion> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
<ProjectGuid>{A82F44D7-F336-4AD6-B2EE-D2C082D094EC}</ProjectGuid> |
||||
<RootNamespace>ICSharpCode.NUnitPad</RootNamespace> |
||||
<AssemblyName>NUnitPad</AssemblyName> |
||||
<OutputTarget>Library</OutputTarget> |
||||
<WarningLevel>4</WarningLevel> |
||||
<NoStdLib>False</NoStdLib> |
||||
<NoConfig>False</NoConfig> |
||||
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent> |
||||
<OutputType>Library</OutputType> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<DebugSymbols>True</DebugSymbols> |
||||
<Optimize>False</Optimize> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\NUnitPad\</OutputPath> |
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
||||
<DefineConstants>DEBUG</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<Optimize>True</Optimize> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\NUnitPad\</OutputPath> |
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\Commands\MenuCommands.cs" /> |
||||
<Compile Include="Src\Commands\TestTreeViewContextMenuCommands.cs" /> |
||||
<Compile Include="Src\Gui\NUnitPadContent.cs" /> |
||||
<Compile Include="Src\Gui\TestTreeView.cs"> |
||||
<SubType>UserControl</SubType> |
||||
</Compile> |
||||
<None Include="NUnitPad.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="..\..\..\..\Tools\NUnit\src\NUnitFramework\extensions\nunit.extensions.dll.csproj"> |
||||
<Project>{98B10E98-003C-45A0-9587-119142E39986}</Project> |
||||
<Name>nunit.extensions.dll</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Tools\NUnit\src\NUnitFramework\core\nunit.core.dll.csproj"> |
||||
<Project>{EBD43A7F-AFCA-4281-BB53-5CDD91F966A3}</Project> |
||||
<Name>nunit.core.dll</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Tools\NUnit\src\NUnitFramework\framework\nunit.framework.dll.csproj"> |
||||
<Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project> |
||||
<Name>nunit.framework.dll</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Tools\NUnit\src\ClientUtilities\util\nunit.util.dll.csproj"> |
||||
<Project>{61CE9CE5-943E-44D4-A381-814DC1406767}</Project> |
||||
<Name>nunit.util.dll</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
||||
</Project> |
@ -1,13 +0,0 @@
@@ -1,13 +0,0 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<StartProgram>..\..\..\..\..\bin\SharpDevelop.exe</StartProgram> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<StartProgram>..\..\..\..\..\bin\SharpDevelop.exe</StartProgram> |
||||
</PropertyGroup> |
||||
<PropertyGroup> |
||||
<LastOpenVersion>8.0.41115</LastOpenVersion> |
||||
<ProjectView>ProjectFiles</ProjectView> |
||||
<ProjectTrust>0</ProjectTrust> |
||||
</PropertyGroup> |
||||
</Project> |
@ -1,54 +0,0 @@
@@ -1,54 +0,0 @@
|
||||
<AddIn |
||||
name = "NUnit-Addin" |
||||
author = "Mike Krueger" |
||||
copyright = "GPL" |
||||
url = "http://www.icsharpcode.net" |
||||
description = "Integrated NUnit test runner for #Develop" |
||||
version = "1.0.0" |
||||
> |
||||
<Runtime> |
||||
<Import assembly="NUnitPad.dll"/> |
||||
</Runtime> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/Pads"> |
||||
<Pad id = "NUnitPad" |
||||
category = "Tools" |
||||
title = "${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}" |
||||
icon = "PadIcons.UnitTest" |
||||
shortcut = "Control|Alt|N" |
||||
class = "ICSharpCode.NUnitPad.NUnitPadContent"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectNode"> |
||||
<MenuItem id = "RunTests" |
||||
insertafter ="AddSeparator" |
||||
insertbefore ="Separator2" |
||||
label = "${res:ProjectComponent.ContextMenu.RunTests}" |
||||
class = "ICSharpCode.NUnitPad.RunTestsInProject"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/MainMenu/Project"> |
||||
<Condition name = "ProjectActive" activeproject="*" action="Disable"> |
||||
<MenuItem id = "RunTests" |
||||
insertbefore ="Deploy" |
||||
label = "${res:XML.MainMenu.ProjectMenu.RunTests}" |
||||
description = "${res:XML.MainMenu.ProjectMenu.RunTests.Description}" |
||||
class = "ICSharpCode.NUnitPad.RunTestsInProject"/> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
|
||||
<Path name = "/NUnitPad/TestTreeView/ContextMenu"> |
||||
<Condition name = "Ownerstate" ownerstate="TestItemSelected"> |
||||
<MenuItem id = "Run" |
||||
label = "${res:NUnitPad.NUnitPadContent.RunTestsContextMenuLabel}" |
||||
class = "ICSharpCode.NUnitPad.RunTestsCommand"/> |
||||
</Condition> |
||||
<Condition name = "Ownerstate" ownerstate="SourceCodeItemSelected"> |
||||
<MenuItem id = "GotoDefinition" |
||||
label = "${res:NUnitPad.NUnitPadContent.GotoDefinitionContextMenuLabel}" |
||||
class = "ICSharpCode.NUnitPad.GotoDefinitionCommand"/> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
</AddIn> |
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.NUnitPad |
||||
{ |
||||
public class RunTestsInProject : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
PadDescriptor nunitPad = WorkbenchSingleton.Workbench.GetPad(typeof(NUnitPadContent)); |
||||
if (nunitPad != null) { |
||||
nunitPad.BringPadToFront(); |
||||
((NUnitPadContent)nunitPad.PadContent).RunTests(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,56 +0,0 @@
@@ -1,56 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.NUnitPad |
||||
{ |
||||
/// <summary>
|
||||
/// Description of RunTestsCommand
|
||||
/// </summary>
|
||||
public class RunTestsCommand : AbstractMenuCommand |
||||
{ |
||||
/// <summary>
|
||||
/// Creates a new RunTestsCommand
|
||||
/// </summary>
|
||||
public RunTestsCommand() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Starts the command
|
||||
/// </summary>
|
||||
public override void Run() |
||||
{ |
||||
((TestTreeView)Owner).RunTests(); |
||||
} |
||||
} |
||||
/// <summary>
|
||||
/// Description of GotoDefinitionCommand
|
||||
/// </summary>
|
||||
public class GotoDefinitionCommand : AbstractMenuCommand |
||||
{ |
||||
/// <summary>
|
||||
/// Creates a new GotoDefinitionCommand
|
||||
/// </summary>
|
||||
public GotoDefinitionCommand() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Starts the command
|
||||
/// </summary>
|
||||
public override void Run() |
||||
{ |
||||
((TestTreeView)Owner).GotoDefinition(); |
||||
} |
||||
} |
||||
} |
@ -1,230 +0,0 @@
@@ -1,230 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Threading; |
||||
using System.Windows.Forms; |
||||
|
||||
using NUnit.Util; |
||||
using NUnit.Core; |
||||
using NUnit.Framework; |
||||
using NUnit.Extensions; |
||||
|
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.NUnitPad |
||||
{ |
||||
/// <summary>
|
||||
/// Description of the pad content
|
||||
/// </summary>
|
||||
public class NUnitPadContent : AbstractPadContent |
||||
{ |
||||
TestTreeView testTreeView; |
||||
Panel contentPanel; |
||||
bool autoLoadItems = false; |
||||
ArrayList testDomains = new ArrayList(); |
||||
|
||||
#region AbstractPadContent requirements
|
||||
/// <summary>
|
||||
/// The <see cref="System.Windows.Forms.Control"/> representing the pad
|
||||
/// </summary>
|
||||
public override Control Control { |
||||
get { |
||||
return contentPanel; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates a new NUnitPadContent object
|
||||
/// </summary>
|
||||
public NUnitPadContent() |
||||
{ |
||||
testTreeView = new TestTreeView(); |
||||
testTreeView.Dock = DockStyle.Fill; |
||||
ToolStrip toolStrip = new ToolStrip(); |
||||
toolStrip.Dock = DockStyle.Top; |
||||
toolStrip.Stretch = true; |
||||
toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; |
||||
|
||||
ToolStripButton refreshItem = new ToolStripButton(); |
||||
refreshItem.ToolTipText = StringParser.Parse("${res:NUnitPad.NUnitPadContent.RefreshItem}"); |
||||
refreshItem.Image = IconService.GetBitmap("Icons.16x16.BrowserRefresh"); |
||||
refreshItem.Click += new EventHandler(RefreshItemClick); |
||||
toolStrip.Items.Add(refreshItem); |
||||
|
||||
ToolStripButton cancelItem = new ToolStripButton(); |
||||
cancelItem.ToolTipText = StringParser.Parse("${res:NUnitPad.NUnitPadContent.CancelItem}"); |
||||
cancelItem.Image = IconService.GetBitmap("Icons.16x16.BrowserCancel"); |
||||
cancelItem.Click += new EventHandler(CancelItemClick); |
||||
|
||||
toolStrip.Items.Add(cancelItem); |
||||
|
||||
toolStrip.Items.Add(new ToolStripSeparator()); |
||||
|
||||
ToolStripButton referenceItem = new ToolStripButton(); |
||||
referenceItem.ToolTipText = StringParser.Parse("${res:NUnitPad.NUnitPadContent.ReferenceItem}"); |
||||
referenceItem.Image = IconService.GetBitmap("Icons.16x16.Reference"); |
||||
referenceItem.Click += new EventHandler(AddNUnitReference); |
||||
toolStrip.Items.Add(referenceItem); |
||||
|
||||
toolStrip.Items.Add(new ToolStripSeparator()); |
||||
|
||||
ToolStripButton runItem = new ToolStripButton(); |
||||
runItem.ToolTipText = StringParser.Parse("${res:NUnitPad.NUnitPadContent.RunItem}"); |
||||
runItem.Image = IconService.GetBitmap("Icons.16x16.RunProgramIcon"); |
||||
runItem.Click += new EventHandler(RunItemClick); |
||||
toolStrip.Items.Add(runItem); |
||||
|
||||
contentPanel = new Panel(); |
||||
contentPanel.Controls.Add(testTreeView); |
||||
contentPanel.Controls.Add(toolStrip); |
||||
|
||||
ProjectService.SolutionLoaded += CombineEventHandler; |
||||
ProjectService.SolutionClosed += ProjectServiceCombineClosed; |
||||
ProjectService.StartBuild += ProjectServiceStartBuild; |
||||
ProjectService.EndBuild += ProjectServiceEndBuild; |
||||
testTreeView.SetAutoLoadState(autoLoadItems); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Refreshes the pad
|
||||
/// </summary>
|
||||
public override void RedrawContent() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Cleans up all used resources
|
||||
/// </summary>
|
||||
public override void Dispose() |
||||
{ |
||||
base.Dispose(); |
||||
UnloadAppDomains(); |
||||
testTreeView.Dispose(); |
||||
contentPanel.Dispose(); |
||||
ProjectService.StartBuild -= new EventHandler(ProjectServiceStartBuild); |
||||
ProjectService.EndBuild -= new EventHandler(ProjectServiceEndBuild); |
||||
} |
||||
#endregion
|
||||
|
||||
void ProjectServiceStartBuild(object sender, EventArgs e) |
||||
{ |
||||
} |
||||
|
||||
void CombineEventHandler(object sender, SolutionEventArgs e) |
||||
{ |
||||
if (autoLoadItems) { |
||||
RefreshProjectAssemblies(); |
||||
} |
||||
} |
||||
|
||||
void ProjectServiceEndBuild(object sender, EventArgs e) |
||||
{ |
||||
if (autoLoadItems) { |
||||
RefreshProjectAssemblies(); |
||||
} |
||||
} |
||||
|
||||
void AddNUnitReference(object sender, EventArgs e) |
||||
{ |
||||
if (ProjectService.CurrentProject != null) { |
||||
ProjectService.AddProjectItem(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "nunit.framework")); |
||||
ProjectService.CurrentProject.Save(); |
||||
} |
||||
} |
||||
|
||||
void RunItemClick(object sender, EventArgs e) |
||||
{ |
||||
RunTests(); |
||||
} |
||||
|
||||
void RefreshItemClick(object sender, EventArgs e) |
||||
{ |
||||
autoLoadItems = true; |
||||
RefreshProjectAssemblies(); |
||||
} |
||||
|
||||
void CancelItemClick(object sender, EventArgs e) |
||||
{ |
||||
autoLoadItems = false; |
||||
UnloadAppDomains(); |
||||
testTreeView.SetAutoLoadState(autoLoadItems); |
||||
} |
||||
|
||||
void ProjectServiceCombineClosed(object sender, EventArgs e) |
||||
{ |
||||
UnloadAppDomains(); |
||||
} |
||||
|
||||
void UnloadAppDomains() |
||||
{ |
||||
/*foreach (TestDomain domain in testDomains) { |
||||
try { |
||||
domain.Unload(); |
||||
} catch (Exception) {} |
||||
}*/ |
||||
testDomains.Clear(); |
||||
testTreeView.ClearTests(); |
||||
} |
||||
|
||||
public void RunTests() |
||||
{ |
||||
if (ProjectService.OpenSolution == null) return; |
||||
|
||||
if (!autoLoadItems) { |
||||
autoLoadItems = true; |
||||
RefreshProjectAssemblies(); |
||||
} |
||||
|
||||
testTreeView.RunTests(); |
||||
} |
||||
|
||||
public void RefreshProjectAssemblies() |
||||
{ |
||||
UnloadAppDomains(); |
||||
|
||||
if (ProjectService.OpenSolution == null) { |
||||
return; |
||||
} |
||||
|
||||
foreach (IProject project in ProjectService.OpenSolution.Projects) { |
||||
bool referenceFound = false; |
||||
foreach (ProjectItem item in project.Items) { |
||||
ReferenceProjectItem reference = item as ReferenceProjectItem; |
||||
if (reference != null) { |
||||
string include = reference.Include; |
||||
if (include.IndexOf(',') > 0) { |
||||
include = include.Substring(0, include.IndexOf(',')); |
||||
} |
||||
if (string.Equals(include, "nunit.framework", StringComparison.InvariantCultureIgnoreCase) |
||||
|| string.Equals(include, "nunit.framework.dll", StringComparison.InvariantCultureIgnoreCase)) |
||||
{ |
||||
referenceFound = true; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
if (referenceFound) { |
||||
string outputAssembly = project.OutputAssemblyFullPath; |
||||
LoggingService.Debug("NUnitPad: Load " + outputAssembly); |
||||
try { |
||||
TestDomain testDomain = new TestDomain(); |
||||
Test test = testDomain.Load(outputAssembly); |
||||
|
||||
testTreeView.PrintTests(outputAssembly, test, project); |
||||
} catch (Exception e) { |
||||
LoggingService.Warn("NUnitPad load error", e); |
||||
testTreeView.PrintTestErrors(outputAssembly, e); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,383 +0,0 @@
@@ -1,383 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
using NUnit.Core; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.NUnitPad |
||||
{ |
||||
/// <summary>
|
||||
/// Description of TestTreeView.
|
||||
/// </summary>
|
||||
public class TestTreeView : System.Windows.Forms.UserControl, EventListener, IOwnerState |
||||
{ |
||||
const string ContextMenuAddInTreePath = "/NUnitPad/TestTreeView/ContextMenu"; |
||||
|
||||
[Flags] |
||||
public enum TestTreeViewState { |
||||
Nothing = 0, |
||||
SourceCodeItemSelected = 1, |
||||
TestItemSelected = 2, |
||||
} |
||||
|
||||
sealed class TestItemTag { |
||||
public readonly ITest Test; |
||||
public readonly IProject Project; |
||||
public TestItemTag(ITest test, IProject project) { |
||||
this.Test = test; |
||||
this.Project = project; |
||||
} |
||||
public void Run(EventListener listener) { |
||||
if (Test is Test) |
||||
(Test as Test).Run(listener); |
||||
} |
||||
public Position GetPosition() { |
||||
return ParserService.GetProjectContent(Project).GetPosition(Test.FullName.Replace('+', '.')); |
||||
} |
||||
} |
||||
|
||||
protected TestTreeViewState internalState = TestTreeViewState.Nothing; |
||||
|
||||
public System.Enum InternalState { |
||||
get { |
||||
return internalState; |
||||
} |
||||
} |
||||
|
||||
TreeView treeView; |
||||
Hashtable treeNodeHash = new Hashtable(); |
||||
MessageViewCategory testRunnerCategory; |
||||
|
||||
|
||||
bool IsSourceCodeItemSelected { |
||||
get { |
||||
if (treeView.SelectedNode == null) { |
||||
return false; |
||||
} |
||||
TestItemTag test = treeView.SelectedNode.Tag as TestItemTag; |
||||
if (test != null) { |
||||
|
||||
Position position = test.GetPosition(); |
||||
return position != null && position.Cu != null; |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
bool IsTestItemSelected { |
||||
get { |
||||
if (treeView.SelectedNode == null) { |
||||
return false; |
||||
} |
||||
TestItemTag test = treeView.SelectedNode.Tag as TestItemTag; |
||||
return test != null; |
||||
} |
||||
} |
||||
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) { |
||||
treeView.Dispose(); |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
|
||||
public TestTreeView() |
||||
{ |
||||
|
||||
ImageList imageList = new ImageList(); |
||||
imageList.ColorDepth = ColorDepth.Depth32Bit; |
||||
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.TestRunner.Gray")); |
||||
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.TestRunner.Green")); |
||||
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.TestRunner.Yellow")); |
||||
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.TestRunner.Red")); |
||||
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.AboutIcon")); |
||||
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.Error")); |
||||
|
||||
this.treeView = new TreeView(); |
||||
treeView.ImageList = imageList; |
||||
treeView.Dock = DockStyle.Fill; |
||||
treeView.DoubleClick += new EventHandler(ActivateItem); |
||||
treeView.KeyPress += new KeyPressEventHandler(TestTreeViewKeyPress); |
||||
treeView.MouseDown += new MouseEventHandler(TreeViewMouseDown); |
||||
treeView.HideSelection = false; |
||||
Controls.Add(treeView); |
||||
treeView.ContextMenuStrip = MenuService.CreateContextMenu(this, ContextMenuAddInTreePath); |
||||
} |
||||
void TreeViewMouseDown(object sender, MouseEventArgs e) |
||||
{ |
||||
TreeNode node = treeView.GetNodeAt(e.X, e.Y); |
||||
|
||||
treeView.SelectedNode = node; |
||||
|
||||
internalState = TestTreeViewState.Nothing; |
||||
if (IsSourceCodeItemSelected) { |
||||
internalState |= TestTreeViewState.SourceCodeItemSelected; |
||||
} |
||||
|
||||
if (IsTestItemSelected) { |
||||
internalState |= TestTreeViewState.TestItemSelected; |
||||
} |
||||
} |
||||
|
||||
public void SetAutoLoadState(bool state) |
||||
{ |
||||
if (!state) { |
||||
ClearTests(); |
||||
|
||||
TreeNode noAutoLoad = new TreeNode(StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.ClickOnRunInformationNode}")); |
||||
noAutoLoad.ImageIndex = noAutoLoad.SelectedImageIndex = 4; |
||||
treeView.Nodes.Add(noAutoLoad); |
||||
} |
||||
} |
||||
public void ClearTests() |
||||
{ |
||||
if (!treeView.IsDisposed) { |
||||
treeView.Nodes.Clear(); |
||||
} |
||||
} |
||||
|
||||
public void PrintTestErrors(string assembly, Exception e) |
||||
{ |
||||
TreeNode assemblyNode = new TreeNode(Path.GetFileName(assembly)); |
||||
|
||||
TreeNode failedNode = new TreeNode(StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.LoadingErrorNode}") + ":" + e.Message); |
||||
failedNode.ImageIndex = failedNode.SelectedImageIndex = 5; |
||||
assemblyNode.Nodes.Add(failedNode); |
||||
|
||||
treeView.Nodes.Add(assemblyNode); |
||||
} |
||||
|
||||
public void PrintTests(string assembly, Test test, IProject project) |
||||
{ |
||||
TreeNode assemblyNode = new TreeNode(Path.GetFileName(assembly)); |
||||
assemblyNode.Tag = new TestItemTag(test, project); |
||||
treeView.Nodes.Add(assemblyNode); |
||||
if (test != null) { |
||||
AddTests(assemblyNode, test, project); |
||||
} |
||||
assemblyNode.Expand(); |
||||
} |
||||
|
||||
public void AddTests(TreeNode node, ITest test, IProject project) |
||||
{ |
||||
foreach (ITest childTest in test.Tests) { |
||||
TreeNode newNode = new TreeNode(childTest.Name); |
||||
treeNodeHash[childTest.UniqueName] = newNode; |
||||
newNode.ImageIndex = newNode.SelectedImageIndex = 0; |
||||
newNode.Tag = new TestItemTag(childTest, project); |
||||
if (childTest.IsSuite) { |
||||
AddTests(newNode, childTest, project); |
||||
node.Expand(); |
||||
} |
||||
node.Nodes.Add(newNode); |
||||
} |
||||
} |
||||
|
||||
public void GotoDefinition() |
||||
{ |
||||
if (treeView.SelectedNode != null) { |
||||
TestItemTag testTag = treeView.SelectedNode.Tag as TestItemTag; |
||||
if (testTag != null) { |
||||
|
||||
Position position = testTag.GetPosition(); |
||||
|
||||
if (position != null && position.Cu != null) { |
||||
|
||||
FileService.JumpToFilePosition(position.Cu.FileName, Math.Max(0, position.Line - 1), Math.Max(0, position.Column - 1)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void RunTests() |
||||
{ |
||||
ResetNodeIcons(treeView.Nodes); |
||||
|
||||
if (testRunnerCategory == null) { |
||||
testRunnerCategory = new MessageViewCategory("NUnit"); |
||||
CompilerMessageView cmv = (CompilerMessageView)WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).PadContent; |
||||
cmv.AddCategory(testRunnerCategory); |
||||
} else { |
||||
testRunnerCategory.ClearText(); |
||||
} |
||||
|
||||
TaskService.Clear(); |
||||
|
||||
TreeNode selectedNode = treeView.SelectedNode; |
||||
|
||||
if (selectedNode != null) { |
||||
TestItemTag test = selectedNode.Tag as TestItemTag; |
||||
if (test != null) { |
||||
test.Run(this); |
||||
} else { |
||||
selectedNode.ImageIndex = selectedNode.SelectedImageIndex = 2; |
||||
} |
||||
} else { |
||||
foreach (TreeNode node in treeView.Nodes) { |
||||
TestItemTag test = node.Tag as TestItemTag; |
||||
if (test != null) { |
||||
test.Run(this); |
||||
} else { |
||||
node.ImageIndex = node.SelectedImageIndex = 2; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// If any tasks bring task view to front.
|
||||
if (TaskService.TaskCount > 0) { |
||||
IWorkbench Workbench = ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench; |
||||
PadDescriptor padDescriptor = Workbench.GetPad(typeof(ErrorList)); |
||||
|
||||
if (padDescriptor != null) { |
||||
padDescriptor.BringPadToFront(); |
||||
} |
||||
} |
||||
|
||||
treeView.Focus(); |
||||
} |
||||
|
||||
void ResetNodeIcons(ICollection col) |
||||
{ |
||||
foreach (TreeNode node in col) { |
||||
if (node.ImageIndex <= 3) { |
||||
node.ImageIndex = node.SelectedImageIndex = 0; |
||||
} |
||||
ResetNodeIcons(node.Nodes); |
||||
} |
||||
} |
||||
|
||||
void SetResultIcon(TestResult testResult) |
||||
{ |
||||
TreeNode node = (TreeNode)treeNodeHash[testResult.Test.UniqueName]; |
||||
if (node != null) { |
||||
if (testResult.IsSuccess && testResult.Executed) { |
||||
node.ImageIndex = node.SelectedImageIndex = 1; |
||||
} else if (testResult.IsFailure) { |
||||
node.ImageIndex = node.SelectedImageIndex = 3; |
||||
} else { |
||||
node.ImageIndex = node.SelectedImageIndex = 2; |
||||
} |
||||
if (node.Parent != null || node.Parent.Parent == null) { |
||||
node.Parent.ImageIndex = node.Parent.SelectedImageIndex = node.ImageIndex; |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
void ActivateItem(object sender, EventArgs e) |
||||
{ |
||||
GotoDefinition(); |
||||
} |
||||
|
||||
void TestTreeViewKeyPress(object sender, KeyPressEventArgs e) |
||||
{ |
||||
if (e.KeyChar == '\r') { |
||||
GotoDefinition(); |
||||
} else if (e.KeyChar == ' ') { |
||||
RunTests(); |
||||
} |
||||
} |
||||
|
||||
#region NUnit.Core.EventListener interface implementation
|
||||
public void RunStarted(NUnit.Core.Test[] tests) |
||||
{ |
||||
|
||||
} |
||||
public void RunFinished(NUnit.Core.TestResult[] tests) |
||||
{ |
||||
|
||||
} |
||||
public void RunFinished(Exception exception) |
||||
{ |
||||
|
||||
} |
||||
public void UnhandledException(Exception exception) |
||||
{ |
||||
|
||||
} |
||||
|
||||
public void SuiteStarted(NUnit.Core.TestSuite suite) |
||||
{ |
||||
// testRunnerCategory.AppendText(suite.FullName + " started.\n");
|
||||
} |
||||
|
||||
public void SuiteFinished(NUnit.Core.TestSuiteResult result) |
||||
{ |
||||
SetResultIcon(result); |
||||
// testRunnerCategory.AppendText(result.Test.FullName + " finished.\n");
|
||||
} |
||||
|
||||
public void TestStarted(NUnit.Core.TestCase testCase) |
||||
{ |
||||
// testRunnerCategory.AppendText(testCase.FullName + " started.\n");
|
||||
} |
||||
|
||||
public void TestFinished(NUnit.Core.TestCaseResult result) |
||||
{ |
||||
|
||||
if (!result.IsSuccess) { |
||||
|
||||
string outputMessage = StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] { |
||||
{"TestCase", result.Test.FullName}, |
||||
{"Message", result.Message.Replace("\t", " ").Trim()} |
||||
} |
||||
); |
||||
|
||||
testRunnerCategory.AppendText(outputMessage + Environment.NewLine); |
||||
testRunnerCategory.AppendText(result.Description + Environment.NewLine); |
||||
testRunnerCategory.AppendText(result.StackTrace + Environment.NewLine); |
||||
|
||||
FileLineReference LineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(result.StackTrace, true); |
||||
if (LineRef != null) { |
||||
Task Task = new Task(Path.GetFullPath(LineRef.FileName), |
||||
outputMessage, |
||||
LineRef.Column, |
||||
LineRef.Line, |
||||
TaskType.Error); |
||||
|
||||
TaskService.Add(Task); |
||||
} |
||||
} else if (!result.Executed) { |
||||
|
||||
string outputMessage = StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestNotExecutedMessage}", new string[,] { |
||||
{"TestCase", result.Test.FullName} |
||||
} |
||||
); |
||||
|
||||
testRunnerCategory.AppendText(outputMessage + Environment.NewLine); |
||||
testRunnerCategory.AppendText(result.Message + Environment.NewLine); |
||||
testRunnerCategory.AppendText(result.Description + Environment.NewLine); |
||||
testRunnerCategory.AppendText(result.StackTrace + Environment.NewLine); |
||||
|
||||
FileLineReference LineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(result.StackTrace, true); |
||||
if (LineRef != null) { |
||||
|
||||
Task Task = new Task(Path.GetFullPath(LineRef.FileName), |
||||
outputMessage, |
||||
LineRef.Column, |
||||
LineRef.Line, |
||||
TaskType.Warning); |
||||
|
||||
TaskService.Add(Task); |
||||
} |
||||
} |
||||
|
||||
SetResultIcon(result); |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
Loading…
Reference in new issue