diff --git a/AddIns/ICSharpCode.SharpDevelop.addin b/AddIns/ICSharpCode.SharpDevelop.addin
index 5f925d093e..e08db5d123 100755
--- a/AddIns/ICSharpCode.SharpDevelop.addin
+++ b/AddIns/ICSharpCode.SharpDevelop.addin
@@ -1252,36 +1252,35 @@
-
+ label="${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}"
+ class="ICSharpCode.UnitTesting.UnitTestingOptionsPanel"/>
diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj
index 8cedcf9133..3543d1d00f 100644
--- a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj
+++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj
@@ -1,4 +1,5 @@
-
+
+
Library
ICSharpCode.UnitTesting
@@ -56,6 +57,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -63,13 +74,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
Configuration\GlobalAssemblyInfo.cs
@@ -117,11 +167,6 @@
ICSharpCode.Core
False
-
- {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}
- ICSharpCode.TextEditor
- False
-
{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}
diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.sln b/src/AddIns/Analysis/UnitTesting/UnitTesting.sln
index 79a6a60a1f..67a98ff275 100644
--- a/src/AddIns/Analysis/UnitTesting/UnitTesting.sln
+++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.sln
@@ -1,7 +1,7 @@
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-# SharpDevelop 3.0.0.2745
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+# SharpDevelop 4.0.0.5840
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}"
@@ -18,8 +18,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj", "{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -58,9 +56,5 @@ Global
{8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.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
EndGlobalSection
EndGlobal
diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.csproj b/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.csproj
index 7e73ccbc05..cec7174312 100644
--- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.csproj
+++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.csproj
@@ -1,4 +1,5 @@
-
+
+
Library
Grunwald.BooBinding
@@ -131,11 +132,6 @@
NRefactory
False
-
- {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}
- ICSharpCode.TextEditor
- False
-
{DBCF20A1-BA13-4582-BFA9-74DE4D987B73}
NRefactoryToBooConverter
diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooAdvancedHighlighter.cs b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooAdvancedHighlighter.cs
index 2190e2a846..f151030e52 100644
--- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooAdvancedHighlighter.cs
+++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooAdvancedHighlighter.cs
@@ -14,8 +14,6 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
-using ICSharpCode.TextEditor;
-using ICSharpCode.TextEditor.Document;
namespace Grunwald.BooBinding.CodeCompletion
{
diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs
index c4cc233220..dfa2ea7fd8 100644
--- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs
+++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs
@@ -79,9 +79,12 @@ namespace Grunwald.BooBinding.CodeCompletion
}
}
lineLength[i] = length;
- BooCompiler compiler = new BooCompiler();
- compiler.Parameters.Input.Add(new StringInput(fileName, fileContent));
- ICompilationUnit cu = Parse(projectContent, fileName, lineLength, compiler);
+ ICompilationUnit cu;
+ lock (typeof(BooCompiler)) {
+ BooCompiler compiler = new BooCompiler();
+ compiler.Parameters.Input.Add(new StringInput(fileName, fileContent));
+ cu = Parse(projectContent, fileName, lineLength, compiler);
+ }
AddCommentsAndRegions(cu, fileContent, fileName);
return cu;
}
diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/Designer/BooDesignerLoader.cs b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/Designer/BooDesignerLoader.cs
index 6ca5b050e4..749ac8b589 100644
--- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/Designer/BooDesignerLoader.cs
+++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/Designer/BooDesignerLoader.cs
@@ -18,7 +18,6 @@ using ICSharpCode.Core;
using ICSharpCode.FormsDesigner;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
-using ICSharpCode.TextEditor;
namespace Grunwald.BooBinding.Designer
{
diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
index 5a01c5d831..4a7dfbc62d 100644
--- a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
+++ b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
@@ -87,11 +87,6 @@
ICSharpCode.AvalonEdit
False
-
- {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}
- ICSharpCode.TextEditor
- False
-
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}
NRefactory
diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs
index dfae97e7e9..2290ebbc5f 100644
--- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs
+++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs
@@ -79,17 +79,16 @@ namespace CSharpBinding
return base.GetDefaultItemType(fileName);
}
- public override void StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink)
+ public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink)
{
if (this.MinimumSolutionVersion == Solution.SolutionVersionVS2005) {
MSBuildEngine.StartBuild(this,
- buildServices,
options,
feedbackSink,
MSBuildEngine.AdditionalTargetFiles.Concat(
new [] { Path.Combine(MSBuildEngine.SharpDevelopBinPath, "SharpDevelop.CheckMSBuild35Features.targets") }));
} else {
- base.StartBuild(buildServices, options, feedbackSink);
+ base.StartBuild(options, feedbackSink);
}
}
diff --git a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs
index 09ae65569a..6a08bfcbcc 100644
--- a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs
+++ b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs
@@ -2,12 +2,13 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Microsoft.Build.Construction;
+
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
-using System.Diagnostics;
+using Microsoft.Build.Construction;
+using Microsoft.Build.Exceptions;
namespace ICSharpCode.CppBinding.Project
{
@@ -16,10 +17,15 @@ namespace ICSharpCode.CppBinding.Project
public CppProject(ProjectCreateInformation info)
: base(info)
{
- AddImport(DefaultPropsFile, null);
- AddImport(PropsFile, null);
- AddImport(DefaultTargetsFile, null);
- AddProjectConfigurationsItemGroup();
+ try {
+ AddImport(DefaultPropsFile, null);
+ AddImport(PropsFile, null);
+ AddImport(DefaultTargetsFile, null);
+ AddProjectConfigurationsItemGroup();
+ base.ReevaluateIfNecessary(); // provoke exception if import is invalid
+ } catch (InvalidProjectFileException ex) {
+ throw new ProjectLoadException("Please ensure that the Windows SDK is installed on your computer.\n\n" + ex.Message, ex);
+ }
}
public CppProject(ProjectLoadInformation info)
@@ -60,7 +66,7 @@ namespace ICSharpCode.CppBinding.Project
string outputPath = GetEvaluatedProperty("OutDir") ?? "";
if (!Path.IsPathRooted(outputPath))
return FileUtility.NormalizePath(Path.Combine(Path.Combine(Path.Combine(Directory, ".."), outputPath),
- AssemblyName + GetExtension(OutputType)));
+ AssemblyName + GetExtension(OutputType)));
else
{
// this will be valid if there is an explicit OutDir property in vcxproj file.
@@ -83,11 +89,11 @@ namespace ICSharpCode.CppBinding.Project
string extension = Path.GetExtension(fileName).ToLower();
switch (extension)
{
- case ".cpp": return ItemType.ClCompile;
- case ".c": return ItemType.ClCompile;
- case ".hpp": return ItemType.ClInclude;
- case ".h": return ItemType.ClInclude;
- case ".rc": return new ItemType(RESOURCE_COMPILE);
+ case ".cpp": return ItemType.ClCompile;
+ case ".c": return ItemType.ClCompile;
+ case ".hpp": return ItemType.ClInclude;
+ case ".h": return ItemType.ClInclude;
+ case ".rc": return new ItemType(RESOURCE_COMPILE);
}
return base.GetDefaultItemType(fileName);
}
@@ -162,7 +168,7 @@ namespace ICSharpCode.CppBinding.Project
return result;
}
- public IList GetProjectUndefines(string fileName)
+ public IList GetProjectUndefines(string fileName)
{
if (fileName == null)
throw new ArgumentNullException("fileName");
diff --git a/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.csproj b/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.csproj
index ce5a5dc2ed..bbac3c6b46 100644
--- a/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.csproj
+++ b/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.csproj
@@ -1,4 +1,5 @@
-
+
+
{E954F3CB-A446-492F-A664-2B376EBC86E8}
Debug
@@ -75,11 +76,6 @@
-
- {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}
- ICSharpCode.TextEditor
- False
-
{2748AD25-9C63-4E12-877B-4DCE96FBED54}
ICSharpCode.SharpDevelop
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding.sln b/src/AddIns/BackendBindings/Python/PythonBinding.sln
index c0bb7b11c1..132066a9ec 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding.sln
+++ b/src/AddIns/BackendBindings/Python/PythonBinding.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-# SharpDevelop 4.0.0.5293
+# SharpDevelop 4.0.0.5840
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding", "PythonBinding\Project\PythonBinding.csproj", "{8D732610-8FC6-43BA-94C9-7126FD7FE361}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding.Tests", "PythonBinding\Test\PythonBinding.Tests.csproj", "{23B517C9-1ECC-4419-A13F-0B7136D085CB}"
@@ -30,6 +30,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Wi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "..\..\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "..\..\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "..\..\Analysis\UnitTesting\Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -94,5 +98,13 @@ Global
{0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.Build.0 = Release|Any CPU
{0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.Build.0 = Release|Any CPU
+ {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin
index 7559322692..1cfc29b3b3 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin
@@ -1,7 +1,7 @@
-
@@ -12,15 +12,16 @@
+
+ extensions=".py"
+ name="Python"
+ resource="ICSharpCode.PythonBinding.Resources.Python.xshd"/>
@@ -30,19 +31,19 @@
+ insertbefore="Resources"
+ insertafter="Icons"
+ name="${res:ICSharpCode.PythonBinding.PythonFiles} (*.py)"
+ extensions="*.py"/>
-
+
+ insertbefore="AllFiles"
+ name="${res:ICSharpCode.PythonBinding.PythonProjectFiles} (*.pyproj)"
+ class="ICSharpCode.SharpDevelop.Project.LoadProject"
+ extensions="*.pyproj"/>
@@ -54,27 +55,27 @@
+ insertafter="Search"
+ insertbefore="Tools"
+ label="&Python"
+ type="Menu">
+ icon="Icons.16x16.RunProgramIcon"
+ class="ICSharpCode.PythonBinding.RunDebugPythonCommand"
+ label="${res:XML.MainMenu.RunMenu.Run}"
+ shortcut="Control|Shift|R"/>
+ icon="Icons.16x16.Debug.StartWithoutDebugging"
+ class="ICSharpCode.PythonBinding.RunPythonCommand"
+ label="${res:XML.MainMenu.DebugMenu.RunWithoutDebug}"
+ shortcut="Control|Shift|W"/>
+ icon="Icons.16x16.StopProcess"
+ class="ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand"
+ label="${res:XML.MainMenu.DebugMenu.Stop}"/>
@@ -83,22 +84,22 @@
+ supportedextensions=".py"
+ projectfileextension=".pyproj"
+ class="ICSharpCode.PythonBinding.PythonParser"/>
+ guid="{FD48973F-F585-4F70-812B-4D0503B36CE9}"
+ supportedextensions=".py"
+ projectfileextension=".pyproj"
+ class="ICSharpCode.PythonBinding.PythonProjectBinding" />
-
+
@@ -115,33 +116,33 @@
+ label="Python"
+ class="ICSharpCode.PythonBinding.PythonOptionsPanel"/>
+ label="${res:Dialog.ProjectOptions.ApplicationSettings}"
+ class="ICSharpCode.PythonBinding.ApplicationSettingsPanel"/>
+ label="${res:Dialog.ProjectOptions.BuildEvents}"
+ class="ICSharpCode.SharpDevelop.Gui.OptionPanels.BuildEvents"/>
+ label="${res:Dialog.ProjectOptions.BuildOptions}"
+ class="ICSharpCode.PythonBinding.CompilingOptionsPanel"/>
+ label="${res:Dialog.ProjectOptions.DebugOptions}"
+ class="ICSharpCode.SharpDevelop.Gui.OptionPanels.DebugOptions"/>
+ type="Secondary"
+ fileNamePattern="\.py$"
+ languagePattern="^Python$"
+ class="ICSharpCode.PythonBinding.PythonFormsDesignerDisplayBinding" />
@@ -151,43 +152,49 @@
+ insertafter="CSharp"
+ insertbefore="VBNet"
+ label="Python"
+ class="ICSharpCode.PythonBinding.ConvertToPythonMenuCommand"/>
-
-
-
+
+
+
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
index 03ac606f0d..7f35aa139f 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
@@ -74,11 +74,15 @@
+
+
+
+
@@ -89,11 +93,18 @@
+
+
+
+
+
+
+
@@ -178,9 +189,16 @@
Always
+
+ Always
+
+
+ Always
+
+
@@ -208,6 +226,11 @@
ICSharpCode.SharpDevelop.Dom
False
+
+ {1F261725-6318-4434-A1B1-6C70CE4CD324}
+ UnitTesting
+ False
+
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}
FormsDesigner
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/PythonOptionsPanel.xfrm b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/PythonOptionsPanel.xfrm
index f0194f88e2..fe281e6870 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/PythonOptionsPanel.xfrm
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/PythonOptionsPanel.xfrm
@@ -11,6 +11,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/AddInOptions.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/AddInOptions.cs
index d4df5988ff..fd597347ab 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/AddInOptions.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/AddInOptions.cs
@@ -29,6 +29,7 @@ namespace ICSharpCode.PythonBinding
#region Property names
public static readonly string PythonFileNameProperty = "PythonFileName";
+ public static readonly string PythonLibraryPathProperty = "PythonLibraryPath";
#endregion
Properties properties;
@@ -47,13 +48,20 @@ namespace ICSharpCode.PythonBinding
this.properties = properties;
}
+ public string PythonLibraryPath {
+ get { return properties.Get(PythonLibraryPathProperty, String.Empty); }
+ set { properties.Set(PythonLibraryPathProperty, value); }
+ }
+
+ public bool HasPythonLibraryPath {
+ get { return !String.IsNullOrEmpty(PythonLibraryPath); }
+ }
+
///
/// Gets or sets the python console filename.
///
public string PythonFileName {
- get {
- return properties.Get(PythonFileNameProperty, GetDefaultPythonFileName());
- }
+ get { return properties.Get(PythonFileNameProperty, GetDefaultPythonFileName()); }
set {
if (String.IsNullOrEmpty(value)) {
properties.Set(PythonFileNameProperty, GetDefaultPythonFileName());
@@ -63,23 +71,19 @@ namespace ICSharpCode.PythonBinding
}
}
- ///
- /// Gets the path to the specified addin.
- ///
- /// The addin name: "${addin:ICSharpCode.PythonBinding}"
- protected virtual string GetAddInPath(string addIn)
- {
- return StringParser.Parse(addIn);
- }
-
///
/// Returns the full path to ipyw.exe which is installed in the
/// Python addin folder.
///
string GetDefaultPythonFileName()
{
- string path = GetAddInPath("${addinpath:ICSharpCode.PythonBinding}");
+ string path = GetPythonBindingAddInPath();
return Path.Combine(path, DefaultPythonFileName);
}
+
+ string GetPythonBindingAddInPath()
+ {
+ return StringParser.Parse("${addinpath:ICSharpCode.PythonBinding}");
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/CreateTextWriterInfo.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/CreateTextWriterInfo.cs
new file mode 100644
index 0000000000..264fe024d5
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/CreateTextWriterInfo.cs
@@ -0,0 +1,65 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace ICSharpCode.PythonBinding
+{
+ public class CreateTextWriterInfo
+ {
+ string fileName;
+ Encoding encoding;
+ bool append;
+
+ public CreateTextWriterInfo(string fileName, Encoding encoding, bool append)
+ {
+ this.fileName = fileName;
+ this.encoding = encoding;
+ this.append = append;
+ }
+
+ public string FileName {
+ get { return fileName; }
+ }
+
+ public Encoding Encoding {
+ get { return encoding; }
+ }
+
+ public bool Append {
+ get { return append; }
+ }
+
+ public override bool Equals(object obj)
+ {
+ CreateTextWriterInfo rhs = obj as CreateTextWriterInfo;
+ if (rhs != null) {
+ return Equals(rhs);
+ }
+ return false;
+ }
+
+ bool Equals(CreateTextWriterInfo rhs)
+ {
+ return (fileName == rhs.fileName) &&
+ (encoding == rhs.encoding) &&
+ (append == rhs.append);
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode();
+ }
+
+ public TextWriter CreateTextWriter()
+ {
+ return new StreamWriter(fileName, append, encoding);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IPythonFileService.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IPythonFileService.cs
new file mode 100644
index 0000000000..822fa1adc3
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IPythonFileService.cs
@@ -0,0 +1,20 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace ICSharpCode.PythonBinding
+{
+ public interface IPythonFileService
+ {
+ string GetTempFileName();
+ TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo);
+ void DeleteFile(string fileName);
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs
index 3c276ddd91..f3dbe7d692 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs
@@ -23,18 +23,30 @@ namespace ICSharpCode.PythonBinding
public class PythonAstWalker : PythonWalker
{
DefaultCompilationUnit compilationUnit;
- DefaultClass currentClass;
- DefaultClass globalClass;
- string currentNamespace;
+ IClass currentClass;
+ IClass globalClass;
///
/// All classes in a file take the namespace of the filename.
///
public PythonAstWalker(IProjectContent projectContent, string fileName)
+ {
+ CreateCompilationUnit(projectContent, fileName);
+ }
+
+ void CreateCompilationUnit(IProjectContent projectContent, string fileName)
{
compilationUnit = new DefaultCompilationUnit(projectContent);
compilationUnit.FileName = fileName;
- currentNamespace = Path.GetFileNameWithoutExtension(fileName);
+
+ CreateUsingScopeForCompilationUnit(fileName);
+ }
+
+ void CreateUsingScopeForCompilationUnit(string fileName)
+ {
+ DefaultUsingScope usingScope = new DefaultUsingScope();
+ usingScope.NamespaceName = Path.GetFileNameWithoutExtension(fileName);
+ compilationUnit.UsingScope = usingScope;
}
///
@@ -62,7 +74,7 @@ namespace ICSharpCode.PythonBinding
c.Region = GetRegion(node);
c.BodyRegion = GetBodyRegion(node.Body, node.Header);
AddBaseTypes(c, node.Bases);
-
+
// Save the class.
compilationUnit.Classes.Add(c);
@@ -80,7 +92,7 @@ namespace ICSharpCode.PythonBinding
public override bool Walk(FunctionDefinition node)
{
if (node.Body == null) {
- return true;
+ return false;
}
bool ignoreFirstMethodParameter = true;
@@ -91,7 +103,7 @@ namespace ICSharpCode.PythonBinding
c = globalClass;
ignoreFirstMethodParameter = false;
}
-
+
// Create method.
string methodName = node.Name;
DomRegion bodyRegion = GetBodyRegion(node.Body, node.Header);
@@ -107,7 +119,7 @@ namespace ICSharpCode.PythonBinding
method.Parameters.Add(parameter);
}
c.Methods.Add(method);
- return true;
+ return false;
}
///
@@ -120,7 +132,7 @@ namespace ICSharpCode.PythonBinding
compilationUnit.UsingScope.Usings.Add(import);
return false;
}
-
+
public override bool Walk(FromImportStatement node)
{
PythonFromImport import = new PythonFromImport(compilationUnit.ProjectContent, node);
@@ -185,7 +197,12 @@ namespace ICSharpCode.PythonBinding
///
void AddBaseType(IClass c, string name)
{
- c.BaseTypes.Add(new SearchClassReturnType(c.ProjectContent, c, 0, 0, name, 0));
+ c.BaseTypes.Add(CreateSearchClassReturnType(c, name));
+ }
+
+ SearchClassReturnType CreateSearchClassReturnType(IClass c, string name)
+ {
+ return new SearchClassReturnType(c.ProjectContent, c, 0, 0, name, 0);
}
///
@@ -215,7 +232,7 @@ namespace ICSharpCode.PythonBinding
///
string GetFullyQualifiedClassName(ClassDefinition classDef)
{
- return String.Concat(currentNamespace, ".", classDef.Name);
+ return String.Concat(compilationUnit.UsingScope.NamespaceName, ".", classDef.Name);
}
///
@@ -224,7 +241,7 @@ namespace ICSharpCode.PythonBinding
void CreateGlobalClass()
{
if (globalClass == null) {
- globalClass = new DefaultClass(compilationUnit, currentNamespace);
+ globalClass = new DefaultClass(compilationUnit, compilationUnit.UsingScope.NamespaceName);
compilationUnit.Classes.Add(globalClass);
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs
index 434394315b..3564feabfb 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs
@@ -50,25 +50,15 @@ namespace ICSharpCode.PythonBinding
//textArea.KeyEventHandler -= ProcessKeyPress;
//textArea.DoProcessDialogKey -= ProcessDialogKey;
}
-
+
public TextWriter Output {
- get {
- Console.WriteLine("PythonConsole.Output get");
- return null;
- }
- set {
- Console.WriteLine("PythonConsole.Output set");
- }
+ get { return null; }
+ set { }
}
public TextWriter ErrorOutput {
- get {
- Console.WriteLine("PythonConsole.ErrorOutput get");
- return null;
- }
- set {
- Console.WriteLine("PythonConsole.ErrorOutput get");
- }
+ get { return null; }
+ set { }
}
///
@@ -90,8 +80,6 @@ namespace ICSharpCode.PythonBinding
///
public string ReadLine(int autoIndentSize)
{
- Console.WriteLine("PythonConsole.ReadLine(): autoIndentSize: " + autoIndentSize);
-
string indent = String.Empty;
if (autoIndentSize > 0) {
indent = String.Empty.PadLeft(autoIndentSize);
@@ -100,7 +88,6 @@ namespace ICSharpCode.PythonBinding
string line = ReadLineFromTextEditor();
if (line != null) {
- Console.WriteLine("ReadLine: " + indent + line);
return indent + line;
}
return null;
@@ -111,10 +98,7 @@ namespace ICSharpCode.PythonBinding
///
public void Write(string text, Style style)
{
- Console.WriteLine("PythonConsole.Write(text, style): " + text);
-
textEditor.Write(text);
-
if (style == Style.Prompt) {
promptLength = text.Length;
textEditor.MakeCurrentContentReadOnly();
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleApplication.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleApplication.cs
new file mode 100644
index 0000000000..eff8b57007
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleApplication.cs
@@ -0,0 +1,109 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Diagnostics;
+using System.Text;
+
+namespace ICSharpCode.PythonBinding
+{
+ public class PythonConsoleApplication
+ {
+ string fileName = String.Empty;
+ StringBuilder arguments;
+ bool debug;
+ string pythonScriptFileName = String.Empty;
+ string pythonScriptCommandLineArguments = String.Empty;
+ string workingDirectory = String.Empty;
+
+ public PythonConsoleApplication(AddInOptions options)
+ : this(options.PythonFileName)
+ {
+ }
+
+ public PythonConsoleApplication(string fileName)
+ {
+ this.fileName = fileName;
+ }
+
+ public string FileName {
+ get { return fileName; }
+ }
+
+ public bool Debug {
+ get { return debug; }
+ set { debug = value; }
+ }
+
+ public string PythonScriptFileName {
+ get { return pythonScriptFileName; }
+ set { pythonScriptFileName = value; }
+ }
+
+ public string PythonScriptCommandLineArguments {
+ get { return pythonScriptCommandLineArguments; }
+ set { pythonScriptCommandLineArguments = value; }
+ }
+
+ public string WorkingDirectory {
+ get { return workingDirectory; }
+ set { workingDirectory = value; }
+ }
+
+ public ProcessStartInfo GetProcessStartInfo()
+ {
+ ProcessStartInfo processStartInfo = new ProcessStartInfo();
+ processStartInfo.FileName = fileName;
+ processStartInfo.Arguments = GetArguments();
+ processStartInfo.WorkingDirectory = workingDirectory;
+ return processStartInfo;
+ }
+
+ public string GetArguments()
+ {
+ arguments = new StringBuilder();
+
+ AppendBooleanOptionIfTrue("-X:Debug", debug);
+ AppendQuotedStringIfNotEmpty(pythonScriptFileName);
+ AppendStringIfNotEmpty(pythonScriptCommandLineArguments);
+
+ return arguments.ToString().TrimEnd();
+ }
+
+ void AppendBooleanOptionIfTrue(string option, bool flag)
+ {
+ if (flag) {
+ AppendOption(option);
+ }
+ }
+
+ void AppendOption(string option)
+ {
+ arguments.Append(option + " ");
+ }
+
+ void AppendQuotedStringIfNotEmpty(string option)
+ {
+ if (!String.IsNullOrEmpty(option)) {
+ AppendQuotedString(option);
+ }
+ }
+
+ void AppendQuotedString(string option)
+ {
+ string quotedOption = String.Format("\"{0}\"", option);
+ AppendOption(quotedOption);
+ }
+
+ void AppendStringIfNotEmpty(string option)
+ {
+ if (!String.IsNullOrEmpty(option)) {
+ AppendOption(option);
+ }
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonFileService.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonFileService.cs
new file mode 100644
index 0000000000..afca45eb89
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonFileService.cs
@@ -0,0 +1,31 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace ICSharpCode.PythonBinding
+{
+ public class PythonFileService : IPythonFileService
+ {
+ public string GetTempFileName()
+ {
+ return Path.GetTempFileName();
+ }
+
+ public TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo)
+ {
+ return createTextWriterInfo.CreateTextWriter();
+ }
+
+ public void DeleteFile(string fileName)
+ {
+ File.Delete(fileName);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonOptionsPanel.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonOptionsPanel.cs
index 21f899a422..01c979f66d 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonOptionsPanel.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonOptionsPanel.cs
@@ -5,11 +5,11 @@
// $Revision$
//
-using ICSharpCode.SharpDevelop.Gui.OptionPanels;
using System;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Gui.OptionPanels;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.PythonBinding
@@ -21,6 +21,7 @@ namespace ICSharpCode.PythonBinding
{
AddInOptions options;
TextBox pythonFileNameTextBox;
+ TextBox pythonLibraryPathTextBox;
public PythonOptionsPanel() : this(new AddInOptions())
{
@@ -38,12 +39,16 @@ namespace ICSharpCode.PythonBinding
pythonFileNameTextBox = (TextBox)ControlDictionary["pythonFileNameTextBox"];
pythonFileNameTextBox.Text = options.PythonFileName;
+ pythonLibraryPathTextBox = (TextBox)ControlDictionary["pythonLibraryPathTextBox"];
+ pythonLibraryPathTextBox.Text = options.PythonLibraryPath;
+
ConnectBrowseButton("browseButton", "pythonFileNameTextBox", "${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe", TextBoxEditMode.EditRawProperty);
}
public override bool StorePanelContents()
{
options.PythonFileName = pythonFileNameTextBox.Text;
+ options.PythonLibraryPath = pythonLibraryPathTextBox.Text;
return true;
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonStandardLibraryPath.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonStandardLibraryPath.cs
new file mode 100644
index 0000000000..36da59f78a
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonStandardLibraryPath.cs
@@ -0,0 +1,77 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Security;
+using Microsoft.Win32;
+
+namespace ICSharpCode.PythonBinding
+{
+ public class PythonStandardLibraryPath
+ {
+ List directories = new List();
+ string path = String.Empty;
+
+ public PythonStandardLibraryPath(string path)
+ {
+ Path = path;
+ }
+
+ public PythonStandardLibraryPath()
+ {
+ ReadPathFromRegistry();
+ }
+
+ void ReadPathFromRegistry()
+ {
+ try {
+ using (RegistryKey registryKey = GetPythonLibraryRegistryKey()) {
+ if (registryKey != null) {
+ Path = (string)registryKey.GetValue(String.Empty, String.Empty);
+ }
+ }
+ } catch (SecurityException) {
+ } catch (UnauthorizedAccessException) {
+ } catch (IOException) {
+ }
+ }
+
+ RegistryKey GetPythonLibraryRegistryKey()
+ {
+ return Registry.LocalMachine.OpenSubKey(@"Software\Python\PythonCore\2.6\PythonPath");
+ }
+
+ public string[] Directories {
+ get { return directories.ToArray(); }
+ }
+
+ public string Path {
+ get { return path; }
+ set {
+ path = value;
+ ReadDirectories();
+ }
+ }
+
+ void ReadDirectories()
+ {
+ directories.Clear();
+ foreach (string item in path.Split(';')) {
+ string directory = item.Trim();
+ if (!String.IsNullOrEmpty(directory)) {
+ directories.Add(directory);
+ }
+ }
+ }
+
+ public bool HasPath {
+ get { return directories.Count > 0; }
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs
new file mode 100644
index 0000000000..3e9e6b31f8
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs
@@ -0,0 +1,73 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Diagnostics;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.PythonBinding
+{
+ public class PythonTestDebugger : TestDebuggerBase
+ {
+ AddInOptions options;
+ IPythonFileService fileService;
+ PythonTestRunnerApplication testRunnerApplication;
+ PythonStandardLibraryPath pythonStandardLibraryPath;
+
+ public PythonTestDebugger()
+ : this(new UnitTestDebuggerService(),
+ new UnitTestMessageService(),
+ new TestResultsMonitor(),
+ new AddInOptions(),
+ new PythonStandardLibraryPath(),
+ new PythonFileService())
+ {
+ }
+
+ public PythonTestDebugger(IUnitTestDebuggerService debuggerService,
+ IUnitTestMessageService messageService,
+ ITestResultsMonitor testResultsMonitor,
+ AddInOptions options,
+ PythonStandardLibraryPath pythonStandardLibraryPath,
+ IPythonFileService fileService)
+ : base(debuggerService, messageService, testResultsMonitor)
+ {
+ this.options = options;
+ this.pythonStandardLibraryPath = pythonStandardLibraryPath;
+ this.fileService = fileService;
+ }
+
+ public override void Start(SelectedTests selectedTests)
+ {
+ CreateTestRunnerApplication();
+ testRunnerApplication.CreateResponseFile(selectedTests);
+ base.Start(selectedTests);
+ }
+
+ void CreateTestRunnerApplication()
+ {
+ testRunnerApplication = new PythonTestRunnerApplication(base.TestResultsMonitor.FileName, options, pythonStandardLibraryPath, fileService);
+ }
+
+ protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
+ {
+ testRunnerApplication.Debug = true;
+ return testRunnerApplication.CreateProcessStartInfo(selectedTests);
+ }
+
+ public override void Dispose()
+ {
+ testRunnerApplication.Dispose();
+ base.Dispose();
+ }
+
+ protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
+ {
+ return new PythonTestResult(testResult);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestFramework.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestFramework.cs
new file mode 100644
index 0000000000..57e520f5b1
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestFramework.cs
@@ -0,0 +1,64 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Project;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.PythonBinding
+{
+ public class PythonTestFramework : ITestFramework
+ {
+ public bool IsTestMethod(IMember member)
+ {
+ if (member != null) {
+ return member.Name.StartsWith("test");
+ }
+ return false;
+ }
+
+ public bool IsTestClass(IClass c)
+ {
+ while (c != null) {
+ if (HasTestCaseBaseType(c)) {
+ return true;
+ }
+ c = c.BaseClass;
+ }
+ return false;
+ }
+
+ bool HasTestCaseBaseType(IClass c)
+ {
+ if (c.BaseTypes.Count > 0) {
+ string baseTypeName = c.BaseTypes[0].FullyQualifiedName;
+ return (baseTypeName == "unittest.TestCase") || (baseTypeName == "unittest2.TestCase");
+ }
+ return false;
+ }
+
+ public bool IsTestProject(IProject project)
+ {
+ return project is PythonProject;
+ }
+
+ public ITestRunner CreateTestRunner()
+ {
+ return new PythonTestRunner();
+ }
+
+ public ITestRunner CreateTestDebugger()
+ {
+ return new PythonTestDebugger();
+ }
+
+ public bool IsBuildNeededBeforeTestRun {
+ get { return false; }
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestResult.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestResult.cs
new file mode 100644
index 0000000000..62fc443a6b
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestResult.cs
@@ -0,0 +1,66 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.SharpDevelop.Dom;
+using System.Text.RegularExpressions;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.PythonBinding
+{
+ public class PythonTestResult : TestResult
+ {
+ public PythonTestResult(TestResult testResult)
+ : base(testResult.Name)
+ {
+ ResultType = testResult.ResultType;
+ Message = testResult.Message;
+ StackTrace = testResult.StackTrace;
+ }
+
+ protected override void OnStackTraceChanged()
+ {
+ if (String.IsNullOrEmpty(StackTrace)) {
+ ResetStackTraceFilePosition();
+ } else {
+ GetFilePositionFromStackTrace();
+ }
+ }
+
+ void ResetStackTraceFilePosition()
+ {
+ StackTraceFilePosition = FilePosition.Empty;
+ }
+
+ ///
+ /// Stack trace:
+ /// Traceback (most recent call last):
+ /// File "d:\temp\test\PyTests\Tests\MyClassTest.py", line 19, in testRaiseException
+ /// raise 'abc'
+ ///
+ void GetFilePositionFromStackTrace()
+ {
+ Match match = Regex.Match(StackTrace, "\\sFile\\s\"(.*?)\",\\sline\\s(\\d+),", RegexOptions.Multiline);
+ if (match.Success) {
+ try {
+ SetStackTraceFilePosition(match.Groups);
+ } catch (OverflowException) {
+ // Ignore.
+ }
+ }
+ }
+
+ void SetStackTraceFilePosition(GroupCollection groups)
+ {
+ string fileName = groups[1].Value;
+ int line = Convert.ToInt32(groups[2].Value);
+ int column = 1;
+
+ StackTraceFilePosition = new FilePosition(fileName, line, column);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunner.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunner.cs
new file mode 100644
index 0000000000..461a203135
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunner.cs
@@ -0,0 +1,73 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using ICSharpCode.Core;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.PythonBinding
+{
+ public class PythonTestRunner : TestProcessRunnerBase
+ {
+ AddInOptions options;
+ PythonStandardLibraryPath pythonStandardLibraryPath;
+ IPythonFileService fileService;
+ PythonTestRunnerApplication testRunnerApplication;
+
+ public PythonTestRunner()
+ : this(new UnitTestProcessRunner(),
+ new TestResultsMonitor(),
+ new AddInOptions(),
+ new PythonStandardLibraryPath(),
+ new PythonFileService())
+ {
+ }
+
+ public PythonTestRunner(IUnitTestProcessRunner processRunner,
+ ITestResultsMonitor testResultsMonitor,
+ AddInOptions options,
+ PythonStandardLibraryPath pythonStandardLibraryPath,
+ IPythonFileService fileService)
+ : base(processRunner, testResultsMonitor)
+ {
+ this.options = options;
+ this.pythonStandardLibraryPath = pythonStandardLibraryPath;
+ this.fileService = fileService;
+ }
+
+ public override void Start(SelectedTests selectedTests)
+ {
+ CreateTestRunnerApplication();
+ testRunnerApplication.CreateResponseFile(selectedTests);
+ base.Start(selectedTests);
+ }
+
+ void CreateTestRunnerApplication()
+ {
+ testRunnerApplication = new PythonTestRunnerApplication(base.TestResultsMonitor.FileName, options, pythonStandardLibraryPath, fileService);
+ }
+
+ protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
+ {
+ return testRunnerApplication.CreateProcessStartInfo(selectedTests);
+ }
+
+ public override void Dispose()
+ {
+ testRunnerApplication.Dispose();
+ base.Dispose();
+ }
+
+ protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
+ {
+ return new PythonTestResult(testResult);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerApplication.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerApplication.cs
new file mode 100644
index 0000000000..5414ecf030
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerApplication.cs
@@ -0,0 +1,109 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using ICSharpCode.Core;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.PythonBinding
+{
+ public class PythonTestRunnerApplication
+ {
+ string testResultsFileName = String.Empty;
+ AddInOptions options;
+ PythonStandardLibraryPath pythonStandardLibraryPath;
+ PythonTestRunnerResponseFile responseFile;
+ IPythonFileService fileService;
+ CreateTextWriterInfo textWriterInfo;
+ PythonConsoleApplication consoleApplication;
+
+ public PythonTestRunnerApplication(string testResultsFileName,
+ AddInOptions options,
+ PythonStandardLibraryPath pythonStandardLibraryPath,
+ IPythonFileService fileService)
+ {
+ this.testResultsFileName = testResultsFileName;
+ this.options = options;
+ this.pythonStandardLibraryPath = pythonStandardLibraryPath;
+ this.fileService = fileService;
+ consoleApplication = new PythonConsoleApplication(options);
+ }
+
+ public bool Debug {
+ get { return consoleApplication.Debug; }
+ set { consoleApplication.Debug = value; }
+ }
+
+ public void CreateResponseFile(SelectedTests selectedTests)
+ {
+ CreateResponseFile();
+ using (responseFile) {
+ WritePythonSystemPaths();
+ WriteTestsResultsFileName();
+ WriteTests(selectedTests);
+ }
+ }
+
+ void CreateResponseFile()
+ {
+ TextWriter writer = CreateTextWriter();
+ responseFile = new PythonTestRunnerResponseFile(writer);
+ }
+
+ TextWriter CreateTextWriter()
+ {
+ string fileName = fileService.GetTempFileName();
+ textWriterInfo = new CreateTextWriterInfo(fileName, Encoding.UTF8, false);
+ return fileService.CreateTextWriter(textWriterInfo);
+ }
+
+ void WritePythonSystemPaths()
+ {
+ if (options.HasPythonLibraryPath) {
+ responseFile.WritePath(options.PythonLibraryPath);
+ } else if (pythonStandardLibraryPath.HasPath) {
+ responseFile.WritePaths(pythonStandardLibraryPath.Directories);
+ }
+ }
+
+ void WriteTestsResultsFileName()
+ {
+ responseFile.WriteResultsFileName(testResultsFileName);
+ }
+
+ void WriteTests(SelectedTests selectedTests)
+ {
+ responseFile.WriteTests(selectedTests);
+ }
+
+ public ProcessStartInfo CreateProcessStartInfo(SelectedTests selectedTests)
+ {
+ consoleApplication.PythonScriptFileName = GetSharpDevelopTestPythonScriptFileName();
+ consoleApplication.PythonScriptCommandLineArguments = GetResponseFileNameCommandLineArgument();
+ consoleApplication.WorkingDirectory = selectedTests.Project.Directory;
+ return consoleApplication.GetProcessStartInfo();
+ }
+
+ string GetSharpDevelopTestPythonScriptFileName()
+ {
+ return StringParser.Parse(@"${addinpath:ICSharpCode.PythonBinding}\TestRunner\sdtest.py");
+ }
+
+ string GetResponseFileNameCommandLineArgument()
+ {
+ return String.Format("\"@{0}\"", textWriterInfo.FileName);
+ }
+
+ public void Dispose()
+ {
+ fileService.DeleteFile(textWriterInfo.FileName);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerResponseFile.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerResponseFile.cs
new file mode 100644
index 0000000000..9e526a0d00
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerResponseFile.cs
@@ -0,0 +1,122 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Text;
+using ICSharpCode.SharpDevelop.Project;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.PythonBinding
+{
+ public class PythonTestRunnerResponseFile : IDisposable
+ {
+ TextWriter writer;
+
+ public PythonTestRunnerResponseFile(string fileName)
+ : this(new StreamWriter(fileName, false, Encoding.UTF8))
+ {
+ }
+
+ public PythonTestRunnerResponseFile(TextWriter writer)
+ {
+ this.writer = writer;
+ }
+
+ public void WriteTest(string testName)
+ {
+ writer.WriteLine(testName);
+ }
+
+ public void WritePaths(string[] paths)
+ {
+ foreach (string path in paths) {
+ WritePath(path);
+ }
+ }
+
+ public void WritePathIfNotEmpty(string path)
+ {
+ if (!String.IsNullOrEmpty(path)) {
+ WritePath(path);
+ }
+ }
+
+ public void WritePath(string path)
+ {
+ WriteQuotedArgument("p", path);
+ }
+
+ void WriteQuotedArgument(string option, string value)
+ {
+ writer.WriteLine("/{0}:\"{1}\"", option, value);
+ }
+
+ public void WriteResultsFileName(string fileName)
+ {
+ WriteQuotedArgument("r", fileName);
+ }
+
+ public void Dispose()
+ {
+ writer.Dispose();
+ }
+
+ public void WriteTests(SelectedTests selectedTests)
+ {
+ WritePathsForReferencedProjects(selectedTests.Project);
+
+ if (selectedTests.Method != null) {
+ WriteTest(selectedTests.Method.FullyQualifiedName);
+ } else if (selectedTests.Class != null) {
+ WriteTest(selectedTests.Class.FullyQualifiedName);
+ } else if (!String.IsNullOrEmpty(selectedTests.NamespaceFilter)) {
+ WriteTest(selectedTests.NamespaceFilter);
+ } else {
+ WriteProjectTests(selectedTests.Project);
+ }
+
+ }
+
+ void WriteProjectTests(IProject project)
+ {
+ if (project != null) {
+ WriteProjectFileItems(project.Items);
+ }
+ }
+
+ void WritePathsForReferencedProjects(IProject project)
+ {
+ if (project != null) {
+ foreach (ProjectItem item in project.Items) {
+ ProjectReferenceProjectItem projectRef = item as ProjectReferenceProjectItem;
+ if (projectRef != null) {
+ string directory = Path.GetDirectoryName(projectRef.FileName);
+ WritePathIfNotEmpty(directory);
+ }
+ }
+ }
+ }
+
+ void WriteProjectFileItems(ReadOnlyCollection items)
+ {
+ foreach (ProjectItem item in items) {
+ FileProjectItem fileItem = item as FileProjectItem;
+ if (fileItem != null) {
+ WriteFileNameWithoutExtension(fileItem.FileName);
+ }
+ }
+ }
+
+ void WriteFileNameWithoutExtension(string fileName)
+ {
+ string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
+ WriteTest(fileNameWithoutExtension);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs
index b962b15407..2f53fced95 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs
@@ -23,7 +23,7 @@ namespace ICSharpCode.PythonBinding
IDebugger debugger;
AddInOptions options;
IWorkbench workbench;
- bool debug;
+ PythonConsoleApplication ipy;
public RunPythonCommand()
: this(WorkbenchSingleton.Workbench, new AddInOptions(), DebuggerService.CurrentDebugger)
@@ -35,40 +35,28 @@ namespace ICSharpCode.PythonBinding
this.workbench = workbench;
this.debugger = debugger;
this.options = options;
+ ipy = new PythonConsoleApplication(options);
}
public bool Debug {
- get { return debug; }
- set { debug = value; }
+ get { return ipy.Debug; }
+ set { ipy.Debug = value; }
}
public override void Run()
{
- if (debug) {
- debugger.Start(CreateProcessStartInfo());
+ ProcessStartInfo processStartInfo = GetProcessStartInfo();
+ if (Debug) {
+ debugger.Start(processStartInfo);
} else {
- debugger.StartWithoutDebugging(CreateProcessStartInfo());
+ debugger.StartWithoutDebugging(processStartInfo);
}
}
- ProcessStartInfo CreateProcessStartInfo()
- {
- ProcessStartInfo info = new ProcessStartInfo();
- info.FileName = options.PythonFileName;
- info.Arguments = GetArguments();
-
- return info;
- }
-
- string GetArguments()
+ ProcessStartInfo GetProcessStartInfo()
{
- // Get the python script filename.
- string pythonScriptFileName = "\"" + workbench.ActiveWorkbenchWindow.ActiveViewContent.PrimaryFileName + "\"";
-
- if (Debug) {
- return "-D " + pythonScriptFileName;
- }
- return pythonScriptFileName;
+ ipy.PythonScriptFileName = workbench.ActiveWorkbenchWindow.ActiveViewContent.PrimaryFileName;
+ return ipy.GetProcessStartInfo();
}
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtest.py b/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtest.py
new file mode 100644
index 0000000000..3510f6fcfa
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtest.py
@@ -0,0 +1,95 @@
+
+import sys
+import System.IO
+
+class SharpDevelopTestProgram:
+
+ def __init__(self):
+ self._sysPaths = []
+ self._testNames = []
+
+ def run(self):
+ if self._validateCommandLineArgs():
+ self._runTests()
+ return
+
+ print 'Usage: sdunittest.py test-names-file sys-paths-file test-results-file'
+ print 'Usage: sdunittest.py @response-file'
+ print ''
+ print 'Example response file content: '
+ print '/p:"sys/path/1"'
+ print '/p:"sys/path/2"'
+ print '/r:"path/to/results-file"'
+ print 'test-name1'
+ print 'test-name2'
+ print 'test-name3'
+
+ def _validateCommandLineArgs(self):
+ if len(sys.argv) == 4:
+ self._testNamesFile = sys.argv[1]
+ self._sysPathFile = sys.argv[2]
+ self._testResultsFile = sys.argv[3]
+ self._responseFile = ''
+ return True
+ if len(sys.argv) == 2:
+ return self._getResponseFileName(sys.argv[1])
+ return False
+
+ def _getResponseFileName(self, fileName):
+ if len(fileName) > 0:
+ if fileName[0] == '@':
+ self._responseFile = fileName[1:]
+ return True
+ return False
+
+ def _runTests(self):
+ if len(self._responseFile) > 0:
+ self._readResponseFile()
+ else:
+ self._readSysPathsFromFile()
+ self._readTestNames()
+
+ self._addSysPaths()
+
+ import unittest
+ import sdtestrunner
+
+ suite = unittest.TestLoader().loadTestsFromNames(self._testNames)
+ sdtestrunner.SharpDevelopTestRunner(resultsFileName=self._testResultsFile, verbosity=2).run(suite)
+
+ def _readResponseFile(self):
+ for line in self._readLinesFromFile(self._responseFile):
+ self._readResponseFileArgument(line)
+
+ def _readResponseFileArgument(self, line):
+ if line.startswith('/r:'):
+ line = self._removeQuotes(line[3:])
+ self._testResultsFile = line
+ elif line.startswith('/p:'):
+ line = self._removeQuotes(line[3:])
+ self._sysPaths.append(line)
+ else:
+ self._testNames.append(line)
+
+ def _removeQuotes(self, line):
+ return line.strip('\"')
+
+ def _readLinesFromFile(self, fileName):
+ #f = codecs.open(fileName, 'rb', 'utf-8')
+ #return f.readall().splitlines()
+ return System.IO.File.ReadAllLines(fileName)
+
+ def _readTestNames(self):
+ self._testNames = self._readLinesFromFile(self._testNamesFile)
+
+ def _readSysPathsFromFile(self):
+ self._sysPaths = self._readLinesFromFile(self._sysPathFile)
+
+ def _addSysPaths(self):
+ for path in self._sysPaths:
+ sys.path.append(path)
+
+
+if __name__ == '__main__':
+ program = SharpDevelopTestProgram()
+ program.run()
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtestrunner.py b/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtestrunner.py
new file mode 100644
index 0000000000..9fa36d46c3
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtestrunner.py
@@ -0,0 +1,106 @@
+
+import codecs
+import sys
+import time
+from unittest import TestResult
+from unittest import TextTestRunner
+from unittest import _TextTestResult
+from unittest import _WritelnDecorator
+
+class _SharpDevelopTestResultWriter:
+ def __init__(self, resultsFileName):
+ self.stream = codecs.open(resultsFileName, "w+", "utf-8-sig")
+
+ def _writeln(self, arg):
+ self.stream.write(arg)
+ self.stream.write('\r\n')
+
+ def _writeTestName(self, test):
+ self._writeln("Name: " + test.id())
+
+ def _writeTestResult(self, result):
+ self._writeln("Result: " + result)
+
+ def _writeTestSuccess(self):
+ self._writeTestResult("Success")
+
+ def _writeTestFailure(self, test, err, testResult):
+ self._writeTestResult("Failure")
+
+ exctype, value, tb = err
+ if value != None:
+ message = self._prefixLinesWithSpaceChar(str(value))
+ self._writeln("Message: " + message)
+
+ excInfoString = testResult._exc_info_to_string(err, test)
+ excInfoString = self._prefixLinesWithSpaceChar(excInfoString)
+ self._writeln("StackTrace: " + excInfoString)
+
+ def _prefixLinesWithSpaceChar(self, text):
+ lines = []
+ originalLines = text.splitlines()
+ if len(originalLines) == 0:
+ return text
+
+ lines.append(originalLines[0] + '\r\n')
+
+ for line in originalLines[1:]:
+ lines.append(' ' + line + '\r\n')
+ return ''.join(lines).rstrip()
+
+ def addSuccess(self, test):
+ self._writeTestName(test)
+ self._writeTestSuccess()
+
+ def addError(self, test, err, testResult):
+ self._writeTestName(test)
+ self._writeTestFailure(test, err, testResult)
+
+ def addFailure(self, test, err, testResult):
+ self._writeTestName(test)
+ self._writeTestFailure(test, err, testResult)
+
+class _SharpDevelopNullTestResultWriter:
+ def __init__(self):
+ pass
+
+ def addSuccess(self, test):
+ pass
+
+ def addError(self, test, err, testResult):
+ pass
+
+ def addFailure(self, test, err, testResult):
+ pass
+
+
+class _SharpDevelopTestResult(_TextTestResult):
+ def __init__(self, stream, descriptions, verbosity, resultWriter):
+ _TextTestResult.__init__(self, stream, descriptions, verbosity)
+ self.resultWriter = resultWriter
+
+ def addSuccess(self, test):
+ self.resultWriter.addSuccess(test)
+ _TextTestResult.addSuccess(self, test)
+
+ def addError(self, test, err):
+ self.resultWriter.addError(test, err, self)
+ _TextTestResult.addError(self, test, err)
+
+ def addFailure(self, test, err):
+ self.resultWriter.addFailure(test, err, self)
+ _TextTestResult.addFailure(self, test, err)
+
+
+class SharpDevelopTestRunner(TextTestRunner):
+ def __init__(self, stream=sys.stderr, resultsFileName=None, descriptions=1, verbosity=1):
+ self.stream = _WritelnDecorator(stream)
+ self.descriptions = descriptions
+ self.verbosity = verbosity
+ if resultsFileName is None:
+ self.resultWriter = _SharpDevelopNullTestResultWriter()
+ else:
+ self.resultWriter = _SharpDevelopTestResultWriter(resultsFileName)
+
+ def _makeResult(self):
+ return _SharpDevelopTestResult(self.stream, self.descriptions, self.verbosity, self.resultWriter)
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInOptionsTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInOptionsTestFixture.cs
deleted file mode 100644
index 7306089ba7..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInOptionsTestFixture.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.IO;
-using ICSharpCode.Core;
-using ICSharpCode.PythonBinding;
-using NUnit.Framework;
-using PythonBinding.Tests.Utils;
-
-namespace PythonBinding.Tests
-{
- ///
- /// Tests the AddInOptions class.
- ///
- [TestFixture]
- public class AddInOptionsTestFixture
- {
- [Test]
- public void DefaultPythonConsoleFileName()
- {
- Properties p = new Properties();
- DerivedAddInOptions options = new DerivedAddInOptions(p);
- options.AddInPath = @"C:\Projects\SD\AddIns\Python";
-
- string expectedFileName = Path.Combine(options.AddInPath, "ipy.exe");
- Assert.AreEqual(expectedFileName, options.PythonFileName);
- Assert.AreEqual("${addinpath:ICSharpCode.PythonBinding}", options.AddInPathRequested);
- }
-
- [Test]
- public void SetPythonConsoleFileNameToNull()
- {
- Properties p = new Properties();
- DerivedAddInOptions options = new DerivedAddInOptions(p);
- options.AddInPath = @"C:\Projects\SD\AddIns\Python";
- options.PythonFileName = null;
-
- string expectedFileName = Path.Combine(options.AddInPath, "ipy.exe");
- Assert.AreEqual(expectedFileName, options.PythonFileName);
- }
-
- [Test]
- public void SetPythonConsoleFileNameToEmptyString()
- {
- Properties p = new Properties();
- DerivedAddInOptions options = new DerivedAddInOptions(p);
- options.AddInPath = @"C:\Projects\SD\AddIns\Python";
- options.PythonFileName = String.Empty;
-
- string expectedFileName = Path.Combine(options.AddInPath, "ipy.exe");
- Assert.AreEqual(expectedFileName, options.PythonFileName);
- }
-
- [Test]
- public void SetPythonConsoleFileName()
- {
- Properties p = new Properties();
- AddInOptions options = new AddInOptions(p);
- string fileName = @"C:\IronPython\ipy.exe";
- options.PythonFileName = fileName;
-
- Assert.AreEqual(fileName, options.PythonFileName);
- Assert.AreEqual(fileName, p["PythonFileName"]);
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/CodeCompletionBindingFromImportCompletionTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/CodeCompletionBindingFromImportCompletionTestFixture.cs
deleted file mode 100644
index 8d560b5fb5..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/CodeCompletionBindingFromImportCompletionTestFixture.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using ICSharpCode.Core;
-using ICSharpCode.PythonBinding;
-using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
-using ICSharpCode.SharpDevelop.Dom;
-using NUnit.Framework;
-using PythonBinding.Tests.Utils;
-
-namespace PythonBinding.Tests
-{
- ///
- /// Tests that the From keyword is correctly identified as a
- /// importable code completion keyword.
- ///
- [TestFixture]
- public class FromImportCompletionTestFixture
- {
- DerivedPythonCodeCompletionBinding codeCompletionBinding;
- bool handlesImportKeyword;
- SharpDevelopTextAreaControl textAreaControl;
-
- [TestFixtureSetUp]
- public void SetUpFixture()
- {
- if (!PropertyService.Initialized) {
- PropertyService.InitializeService(String.Empty, String.Empty, String.Empty);
- }
- textAreaControl = new SharpDevelopTextAreaControl();
- codeCompletionBinding = new DerivedPythonCodeCompletionBinding();
- handlesImportKeyword = codeCompletionBinding.HandleKeyword(textAreaControl, "from");
- }
-
- [Test]
- public void HandlesImportKeyWord()
- {
- Assert.IsTrue(handlesImportKeyword);
- }
-
- [Test]
- public void ExpressionContextIsImportable()
- {
- Assert.AreEqual(ExpressionContext.Importable, codeCompletionBinding.ExpressionContext);
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/CodeCompletionBindingImportCompletionTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/CodeCompletionBindingImportCompletionTestFixture.cs
index e50567742b..49d26d4e59 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/CodeCompletionBindingImportCompletionTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/CodeCompletionBindingImportCompletionTestFixture.cs
@@ -8,12 +8,12 @@
using System;
using ICSharpCode.Core;
using ICSharpCode.PythonBinding;
-using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
-namespace PythonBinding.Tests
+namespace PythonBinding.Tests.Completion
{
///
/// Tests the code completion after an "import" statement.
@@ -48,7 +48,7 @@ namespace PythonBinding.Tests
Assert.IsFalse(codeCompletionBinding.HandleKeyword(textEditor, "Unknown"));
}
- [Test]
+ [Test]
public void HandlesUppercaseImportKeyword()
{
Assert.IsTrue(codeCompletionBinding.HandleKeyword(textEditor, "IMPORT"));
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/NamespaceContentsAddedToCtrlSpaceTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/NamespaceContentsAddedToCtrlSpaceTestFixture.cs
index 258b9df69a..fb803ad45f 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/NamespaceContentsAddedToCtrlSpaceTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/NamespaceContentsAddedToCtrlSpaceTestFixture.cs
@@ -12,6 +12,7 @@ using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
@@ -25,14 +26,14 @@ namespace PythonBinding.Tests.Resolver
{
List results;
PythonResolver resolver;
- MockProjectContent mockProjectContent;
+ PythonBinding.Tests.Utils.MockProjectContent mockProjectContent;
MockClass myTestClass;
[TestFixtureSetUp]
public void SetUpFixture()
{
resolver = new PythonResolver();
- mockProjectContent = new MockProjectContent();
+ mockProjectContent = new PythonBinding.Tests.Utils.MockProjectContent();
mockProjectContent.NamespacesToAdd.Add("Test");
myTestClass = new MockClass(mockProjectContent, "MyTestClass");
List namespaceItems = new List();
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInFileTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInFileTestFixture.cs
similarity index 93%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInFileTestFixture.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInFileTestFixture.cs
index 6548db301f..34bd86cf24 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInFileTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInFileTestFixture.cs
@@ -15,7 +15,7 @@ using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
-namespace PythonBinding.Tests
+namespace PythonBinding.Tests.Configuration
{
///
/// Basic PythonBinding.addin file tests.
@@ -50,6 +50,10 @@ namespace PythonBinding.Tests
Codon convertCSharpProjectCodon;
Codon convertVBNetProjectCodon;
Codon formattingStrategyCodon;
+ Runtime sharpdevelopRuntime;
+ Runtime ironpythonModulesRuntime;
+ Runtime unitTestingRuntime;
+ Codon testFrameworkCodon;
[TestFixtureSetUp]
public void SetupFixture()
@@ -83,13 +87,20 @@ namespace PythonBinding.Tests
convertCSharpProjectCodon = GetCodon("/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions/Convert", "CSharpProjectToPythonProjectConverter");
convertVBNetProjectCodon = GetCodon("/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions/Convert", "VBNetProjectToPythonProjectConverter");
formattingStrategyCodon = GetCodon("/AddIns/DefaultTextEditor/Formatter/Python", "PythonFormatter");
-
+ testFrameworkCodon = GetCodon("/SharpDevelop/UnitTesting/TestFrameworks", "pyunit");
+
// Get the PythonBinding runtime.
foreach (Runtime runtime in addin.Runtimes) {
if (runtime.Assembly == "PythonBinding.dll") {
- pythonBindingRuntime = runtime;
+ pythonBindingRuntime = runtime;
} else if (runtime.Assembly == "$ICSharpCode.FormsDesigner/FormsDesigner.dll") {
formsDesignerRuntime = runtime;
+ } else if (runtime.Assembly == "IronPython.Modules.dll") {
+ ironpythonModulesRuntime = runtime;
+ } else if (runtime.Assembly == ":ICSharpCode.SharpDevelop") {
+ sharpdevelopRuntime = runtime;
+ } else if (runtime.Assembly == "$ICSharpCode.UnitTesting/UnitTesting.dll") {
+ unitTestingRuntime = runtime;
}
}
@@ -128,11 +139,29 @@ namespace PythonBinding.Tests
}
[Test]
- public void RuntimeExists()
+ public void PythonBindingRuntimeExists()
{
Assert.IsNotNull(pythonBindingRuntime);
}
+ [Test]
+ public void ICSharpCodeSharpDevelopRuntimeExists()
+ {
+ Assert.IsNotNull(sharpdevelopRuntime);
+ }
+
+ [Test]
+ public void IronPythonModulesRuntimeExists()
+ {
+ Assert.IsNotNull(ironpythonModulesRuntime);
+ }
+
+ [Test]
+ public void UnitTestingRuntimeExists()
+ {
+ Assert.IsNotNull(unitTestingRuntime);
+ }
+
[Test]
public void FileFilterExists()
{
@@ -725,22 +754,40 @@ namespace PythonBinding.Tests
{
Assert.AreEqual(1, pythonWithoutDebuggerRunMenuItemCodon.Conditions.Length);
}
-
+
[Test]
public void PythonDebugRunConditionIsSameAsPythonRunCondition()
{
Assert.AreEqual(pythonWithoutDebuggerRunMenuItemCodon.Conditions[0], pythonRunMenuItemCodon.Conditions[0]);
}
-
+
[Test]
public void PythonFormatterClass()
{
Assert.AreEqual("ICSharpCode.PythonBinding.PythonFormattingStrategy", formattingStrategyCodon["class"]);
}
+ [Test]
+ public void TestFrameworkCodonExists()
+ {
+ Assert.IsNotNull(testFrameworkCodon);
+ }
+
+ [Test]
+ public void TestFrameworkClassIsPythonTestFrameworks()
+ {
+ Assert.AreEqual("ICSharpCode.PythonBinding.PythonTestFramework", testFrameworkCodon["class"]);
+ }
+
+ [Test]
+ public void TestFrameworkSupportedProjectsIsPythonProject()
+ {
+ Assert.AreEqual(".pyproj", testFrameworkCodon["supportedProjects"]);
+ }
+
Codon GetCodon(string name, string extensionPath)
{
return AddInHelper.GetCodon(addin, name, extensionPath);
- }
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInOptionsTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInOptionsTestFixture.cs
new file mode 100644
index 0000000000..3ebb9d18e3
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInOptionsTestFixture.cs
@@ -0,0 +1,94 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.IO;
+using ICSharpCode.Core;
+using ICSharpCode.PythonBinding;
+using NUnit.Framework;
+using PythonBinding.Tests.Utils;
+
+namespace PythonBinding.Tests.Configuration
+{
+ ///
+ /// Tests the AddInOptions class.
+ ///
+ [TestFixture]
+ public class AddInOptionsTestFixture
+ {
+ AddInOptions options;
+ Properties properties;
+ AddIn addin;
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ addin = AddInPathHelper.CreateDummyPythonAddInInsideAddInTree();
+ addin.FileName = @"C:\Projects\SD\AddIns\Python\pythonbinding.addin";
+ }
+
+ [SetUp]
+ public void Init()
+ {
+ properties = new Properties();
+ options = new AddInOptions(properties);
+ }
+
+ [Test]
+ public void DefaultPythonConsoleFileNameIsPythonAddInPathCombinedWithIpyExe()
+ {
+ string expectedFileName = @"C:\Projects\SD\AddIns\Python\ipy.exe";
+ Assert.AreEqual(expectedFileName, options.PythonFileName);
+ }
+
+ [Test]
+ public void RequestingPythonFileNameWhenPythonConsoleFileNameSetToNullReturnsDefaultPythonConsoleFileName()
+ {
+ options.PythonFileName = null;
+ string expectedFileName = @"C:\Projects\SD\AddIns\Python\ipy.exe";
+ Assert.AreEqual(expectedFileName, options.PythonFileName);
+ }
+
+ [Test]
+ public void RequestingPythonFileNameWhenPythonConsoleFileNameToEmptyStringReturnsDefaultPythonConsoleFileName()
+ {
+ options.PythonFileName = String.Empty;
+ string expectedFileName = @"C:\Projects\SD\AddIns\Python\ipy.exe";
+ Assert.AreEqual(expectedFileName, options.PythonFileName);
+ }
+
+ [Test]
+ public void SetPythonConsoleFileNameUpdatesAddInOptionsPythonFileName()
+ {
+ string fileName = @"C:\IronPython\ipy.exe";
+ options.PythonFileName = fileName;
+ Assert.AreEqual(fileName, options.PythonFileName);
+ }
+
+ [Test]
+ public void SetPythonConsoleFileNameUpdatesProperties()
+ {
+ string fileName = @"C:\IronPython\ipy.exe";
+ options.PythonFileName = fileName;
+ Assert.AreEqual(fileName, properties["PythonFileName"]);
+ }
+
+ [Test]
+ public void PythonLibraryPathTakenFromProperties()
+ {
+ string expectedPythonLibraryPath = @"c:\python26\lib;c:\python26\lib\lib-tk";
+ properties["PythonLibraryPath"] = expectedPythonLibraryPath;
+ Assert.AreEqual(expectedPythonLibraryPath, options.PythonLibraryPath);
+ }
+
+ [Test]
+ public void DefaultPythonLibraryPathIsEmptyString()
+ {
+ Assert.AreEqual(String.Empty, options.PythonLibraryPath);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForLoopConversionTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForLoopConversionTestFixture.cs
index 32e2f86734..0939669caf 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForLoopConversionTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForLoopConversionTestFixture.cs
@@ -51,7 +51,6 @@ namespace PythonBinding.Tests.Converter
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
string code = converter.Convert(csharp);
- System.Console.WriteLine(code);
string expectedCode = "class Foo(object):\r\n" +
"\tdef GetCount(self):\r\n" +
"\t\tcount = 0\r\n" +
@@ -60,7 +59,7 @@ namespace PythonBinding.Tests.Converter
"\t\t\tcount += 1\r\n" +
"\t\t\ti = i + 1\r\n" +
"\t\treturn count";
-
+
Assert.AreEqual(expectedCode, code);
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ProjectHasStartupObjectTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ProjectHasStartupObjectTestFixture.cs
index bf5770363e..66d959d2e8 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ProjectHasStartupObjectTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ProjectHasStartupObjectTestFixture.cs
@@ -17,6 +17,7 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Converter
{
@@ -31,7 +32,7 @@ namespace PythonBinding.Tests.Converter
MSBuildBasedProject sourceProject;
PythonProject targetProject;
MockTextEditorProperties mockTextEditorProperties;
- MockProjectContent mockProjectContent;
+ PythonBinding.Tests.Utils.MockProjectContent mockProjectContent;
string startupObject = "RootNamespace.Main";
@@ -64,7 +65,7 @@ namespace PythonBinding.Tests.Converter
// Set up IProjectContent so the ConvertProjectToPythonProjectCommand can
// locate the startup object and determine it's filename.
- mockProjectContent = new MockProjectContent();
+ mockProjectContent = new PythonBinding.Tests.Utils.MockProjectContent();
MockClass mainClass = new MockClass(mockProjectContent, startupObject);
mainClass.CompilationUnit.FileName = @"d:\projects\test\src\Main2.cs";
mockProjectContent.ClassToReturnFromGetClass = mainClass;
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
index 723eff78d7..8e1e8e9e64 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
@@ -20,6 +20,7 @@ using ICSharpCode.FormsDesigner;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
@@ -71,7 +72,7 @@ namespace PythonBinding.Tests.Designer
[Test]
public void GetDomRegion()
{
- MockMethod method = new MockMethod();
+ MockMethod method = new MockMethod(MockClass.CreateMockClassWithoutAnyAttributes());
DomRegion bodyRegion = new DomRegion(0, 4, 1, 4);
method.BodyRegion = bodyRegion;
DomRegion expectedRegion = new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine + 1, 1);
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonDesignerLoaderTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonDesignerLoaderTestFixture.cs
index 6e6d37d7f7..bc4b6948c9 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonDesignerLoaderTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonDesignerLoaderTestFixture.cs
@@ -68,9 +68,7 @@ namespace PythonBinding.Tests.Designer
serializationManager = new DesignerSerializationManager(mockDesignerLoaderHost);
- System.Console.WriteLine("Before BeginLoad");
loader.BeginLoad(mockDesignerLoaderHost);
- System.Console.WriteLine("After BeginLoad");
rootComponent = mockDesignerLoaderHost.RootComponent;
designedForm = new Form();
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs
index 8c82afa474..e414ac077f 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs
@@ -17,6 +17,7 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
@@ -26,7 +27,7 @@ namespace PythonBinding.Tests.Designer
[Test]
public void GetMethodReplaceRegion()
{
- MockMethod method = new MockMethod();
+ MockMethod method = new MockMethod(MockClass.CreateMockClassWithoutAnyAttributes());
DomRegion bodyRegion = new DomRegion(0, 4, 1, 4);
method.BodyRegion = bodyRegion;
DomRegion expectedRegion = new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine + 1, 1);
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AppSettingsPanelTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/AppSettingsPanelTestFixture.cs
similarity index 99%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/AppSettingsPanelTestFixture.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/AppSettingsPanelTestFixture.cs
index 2c911e6355..77c59a6125 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AppSettingsPanelTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/AppSettingsPanelTestFixture.cs
@@ -16,7 +16,7 @@ using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
-namespace PythonBinding.Tests
+namespace PythonBinding.Tests.Gui
{
///
/// Tests the ApplicationSettingsPanel class.
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/CompilingOptionsPanelTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/CompilingOptionsPanelTestFixture.cs
similarity index 99%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/CompilingOptionsPanelTestFixture.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/CompilingOptionsPanelTestFixture.cs
index 1d10376d14..7e6b51e07f 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/CompilingOptionsPanelTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/CompilingOptionsPanelTestFixture.cs
@@ -16,7 +16,7 @@ using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
-namespace PythonBinding.Tests
+namespace PythonBinding.Tests.Gui
{
///
/// Tests the CompilingOptionsPanel.
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/DebugPythonCommandTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTestFixture.cs
similarity index 88%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/DebugPythonCommandTestFixture.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTestFixture.cs
index ed886eb6cc..eff903c3e9 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/DebugPythonCommandTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTestFixture.cs
@@ -13,7 +13,7 @@ using ICSharpCode.PythonBinding;
using PythonBinding.Tests.Utils;
using NUnit.Framework;
-namespace PythonBinding.Tests
+namespace PythonBinding.Tests.Gui
{
[TestFixture]
public class DebugPythonCommandTestFixture
@@ -26,7 +26,7 @@ namespace PythonBinding.Tests
{
// Create dummy view content with the Python script.
MockViewContent viewContent = new MockViewContent();
- viewContent.PrimaryFileName = new FileName(@"C:\Projects\test.py");
+ viewContent.PrimaryFileName = new FileName(@"C:\Projects\test.py");
MockWorkbenchWindow workbenchWindow = new MockWorkbenchWindow();
workbenchWindow.ActiveViewContent = viewContent;
MockWorkbench workbench = new MockWorkbench();
@@ -57,7 +57,7 @@ namespace PythonBinding.Tests
[Test]
public void ProcessInfoArgs()
{
- Assert.AreEqual("-D \"C:\\Projects\\test.py\"", debugger.ProcessStartInfo.Arguments);
+ Assert.AreEqual("-X:Debug \"C:\\Projects\\test.py\"", debugger.ProcessStartInfo.Arguments);
}
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/FormsDesignerDisplayBindingTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/FormsDesignerDisplayBindingTestFixture.cs
similarity index 95%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/FormsDesignerDisplayBindingTestFixture.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/FormsDesignerDisplayBindingTestFixture.cs
index ae257c9c6a..6580488bc6 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/FormsDesignerDisplayBindingTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/FormsDesignerDisplayBindingTestFixture.cs
@@ -8,12 +8,13 @@
using System;
using ICSharpCode.FormsDesigner;
using ICSharpCode.PythonBinding;
+using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
-namespace PythonBinding.Tests
+namespace PythonBinding.Tests.Gui
{
///
/// Tests the PythonFormsDesignerDisplayBinding.
@@ -23,8 +24,8 @@ namespace PythonBinding.Tests
{
DerivedPythonFormsDesignerDisplayBinding displayBinding;
MockTextEditorViewContent viewContent;
- ParseInformation parseInfo;
bool canAttachToDesignableClass;
+ ParseInformation parseInfo;
[SetUp]
public void SetUp()
@@ -32,7 +33,7 @@ namespace PythonBinding.Tests
displayBinding = new DerivedPythonFormsDesignerDisplayBinding();
viewContent = new MockTextEditorViewContent();
parseInfo = new ParseInformation(new DefaultCompilationUnit(new DefaultProjectContent()));
- viewContent.PrimaryFileName = new ICSharpCode.Core.FileName("test.py");
+ viewContent.PrimaryFileName = new FileName("test.py");
viewContent.TextEditor.Document.Text = "text content";
displayBinding.ParseServiceParseInfoToReturn = parseInfo;
displayBinding.IsParseInfoDesignable = true;
@@ -99,7 +100,7 @@ namespace PythonBinding.Tests
[Test]
public void NonPythonFileNameCannotBeAttachedTo()
{
- viewContent.PrimaryFileName = new ICSharpCode.Core.FileName("test.cs");
+ viewContent.PrimaryFileName = new FileName("test.cs");
Assert.IsFalse(displayBinding.CanAttachTo(viewContent));
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonIndentationTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonIndentationTests.cs
similarity index 98%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonIndentationTests.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonIndentationTests.cs
index 866a632a5b..9bcfc0f973 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonIndentationTests.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonIndentationTests.cs
@@ -13,13 +13,13 @@ using ICSharpCode.TextEditor.Actions;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
-namespace PythonBinding.Tests.Indentation
+namespace PythonBinding.Tests
{
///
/// Tests that the PythonFormattingStrategy indents the new line added after pressing the ':' character.
///
[TestFixture]
- public class PythonNewMethodIndentationTestFixture
+ public class PythonIndentationTestFixture
{
TextEditorControl textEditor;
PythonFormattingStrategy formattingStrategy;
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonOptionsPanelTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonOptionsPanelTestFixture.cs
similarity index 67%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonOptionsPanelTestFixture.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonOptionsPanelTestFixture.cs
index c02b17827e..e5d645ff59 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonOptionsPanelTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonOptionsPanelTestFixture.cs
@@ -5,16 +5,16 @@
// $Revision$
//
-using ICSharpCode.SharpDevelop.Gui.OptionPanels;
using System;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Gui.OptionPanels;
using NUnit.Framework;
-namespace PythonBinding.Tests
+namespace PythonBinding.Tests.Gui
{
///
/// Tests the PythonOptionsPanel.
@@ -26,6 +26,7 @@ namespace PythonBinding.Tests
Properties properties;
AddInOptions options;
TextBox fileNameTextBox;
+ TextBox pythonLibraryPathTextBox;
[SetUp]
public void SetUp()
@@ -33,9 +34,11 @@ namespace PythonBinding.Tests
properties = new Properties();
options = new AddInOptions(properties);
options.PythonFileName = @"C:\Python\ipy.exe";
+ options.PythonLibraryPath = @"C:\Python26\lib";
optionsPanel = new PythonOptionsPanel(options);
optionsPanel.LoadPanelContents();
fileNameTextBox = (TextBox)optionsPanel.ControlDictionary["pythonFileNameTextBox"];
+ pythonLibraryPathTextBox = (TextBox)optionsPanel.ControlDictionary["pythonLibraryPathTextBox"];
}
[TearDown]
@@ -47,7 +50,13 @@ namespace PythonBinding.Tests
[Test]
public void PythonFileNameDisplayed()
{
- Assert.AreEqual(options.PythonFileName, fileNameTextBox.Text);
+ Assert.AreEqual(@"C:\Python\ipy.exe", fileNameTextBox.Text);
+ }
+
+ [Test]
+ public void PythonLibraryPathIsDisplayed()
+ {
+ Assert.AreEqual(@"C:\Python26\lib", pythonLibraryPathTextBox.Text);
}
[Test]
@@ -57,12 +66,21 @@ namespace PythonBinding.Tests
}
[Test]
- public void SaveOptions()
+ public void SavingOptionsUpdatesIronPythonFileName()
{
string fileName = @"C:\Program Files\IronPython\ipy.exe";
fileNameTextBox.Text = fileName;
optionsPanel.StorePanelContents();
Assert.AreEqual(fileName, options.PythonFileName);
}
+
+ [Test]
+ public void SavingOptionsUpdatesIronPythonLibraryPath()
+ {
+ string path = @"c:\Program Files\Python\lib";
+ pythonLibraryPathTextBox.Text = path;
+ optionsPanel.StorePanelContents();
+ Assert.AreEqual(path, options.PythonLibraryPath);
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonSyntaxModeTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonSyntaxModeTestFixture.cs
similarity index 99%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonSyntaxModeTestFixture.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonSyntaxModeTestFixture.cs
index 261749e7e6..64209fb9eb 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonSyntaxModeTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonSyntaxModeTestFixture.cs
@@ -16,8 +16,9 @@ using ICSharpCode.AvalonEdit.AddIn;
using ICSharpCode.Core;
using ICSharpCode.TextEditor.Document;
using NUnit.Framework;
+using PythonBinding.Tests.Utils;
-namespace PythonBinding.Tests
+namespace PythonBinding.Tests.Gui
{
///
/// Tests the Python.xshd syntax mode information.
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/RunPythonCommandTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTestFixture.cs
similarity index 98%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/RunPythonCommandTestFixture.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTestFixture.cs
index 1e5cf87015..97a148f5f5 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/RunPythonCommandTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTestFixture.cs
@@ -13,7 +13,7 @@ using ICSharpCode.SharpDevelop.Gui;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
-namespace PythonBinding.Tests
+namespace PythonBinding.Tests.Gui
{
///
/// Tests that the RunPythonCommand class runs the Python console
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ClassWithBaseClassTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ClassWithBaseClassTestFixture.cs
index df26c3a68d..58d3c03080 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ClassWithBaseClassTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ClassWithBaseClassTestFixture.cs
@@ -52,6 +52,5 @@ namespace PythonBinding.Tests.Parsing
}
Assert.IsNotNull(matchedBaseType);
}
-
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassNestedInsideMethodTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassNestedInsideMethodTestFixture.cs
new file mode 100644
index 0000000000..5d479b83da
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassNestedInsideMethodTestFixture.cs
@@ -0,0 +1,59 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.TextEditor.Document;
+using NUnit.Framework;
+using PythonBinding.Tests;
+
+namespace PythonBinding.Tests.Parsing
+{
+ [TestFixture]
+ public class ParseClassNestedInsideMethodTestFixture
+ {
+ ICompilationUnit compilationUnit;
+ IClass c;
+
+ [SetUp]
+ public void SetUpFixture()
+ {
+ string python =
+ "class MyClass:\r\n" +
+ " def firstMethod(self):\r\n" +
+ " class NestedClass:\r\n" +
+ " def firstNestedClassMethod(self):\r\n" +
+ " pass\r\n" +
+ "\r\n" +
+ " def secondMethod(self):\r\n" +
+ " pass\r\n" +
+ "\r\n";
+
+ DefaultProjectContent projectContent = new DefaultProjectContent();
+ PythonParser parser = new PythonParser();
+ compilationUnit = parser.Parse(projectContent, @"C:\test.py", python);
+ if (compilationUnit.Classes.Count > 0) {
+ c = compilationUnit.Classes[0];
+ }
+ }
+
+ [Test]
+ public void CompilationUnitHasOneClass()
+ {
+ Assert.AreEqual(1, compilationUnit.Classes.Count);
+ }
+
+ [Test]
+ public void MyClassHasTwoMethods()
+ {
+ Assert.AreEqual(2, c.Methods.Count);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassTestFixture.cs
new file mode 100644
index 0000000000..76415f2318
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassTestFixture.cs
@@ -0,0 +1,52 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.SharpDevelop.Dom;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Parsing
+{
+ [TestFixture]
+ public class ParseTestClassTestFixture
+ {
+ ICompilationUnit compilationUnit;
+ IClass c;
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ string python =
+ "import unittest\r\n" +
+ "\r\n" +
+ "class simpleTest(unittest.TestCase):\r\n" +
+ " def testSuccess(self):\r\n" +
+ " assert True\r\n" +
+ "\r\n" +
+ " def testFailure(self):\r\n" +
+ " assert False\r\n" +
+ "\r\n";
+
+ DefaultProjectContent projectContent = new DefaultProjectContent();
+ PythonParser parser = new PythonParser();
+ compilationUnit = parser.Parse(projectContent, @"C:\test.py", python);
+ if (compilationUnit.Classes.Count > 0) {
+ c = compilationUnit.Classes[0];
+ }
+ }
+
+ [Test]
+ public void SimpleTestFirstBaseTypeIsUnitTestTestCase()
+ {
+ IReturnType baseType = c.BaseTypes[0];
+ string actualBaseTypeName = baseType.FullyQualifiedName;
+ string expectedBaseTypeName = "unittest.TestCase";
+ Assert.AreEqual(expectedBaseTypeName, actualBaseTypeName);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassWithBaseClassTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassWithBaseClassTestFixture.cs
new file mode 100644
index 0000000000..2fe65b4a3b
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassWithBaseClassTestFixture.cs
@@ -0,0 +1,89 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.SharpDevelop.Dom;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Parsing
+{
+ [TestFixture]
+ public class ParseTestClassWithBaseClassTestFixture
+ {
+ ICompilationUnit compilationUnit;
+ IClass c;
+ DefaultProjectContent projectContent;
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ string python =
+ "import unittest\r\n" +
+ "\r\n" +
+ "class BaseTest(unittest.TestCase):\r\n" +
+ " def testSuccess(self):\r\n" +
+ " assert True\r\n" +
+ "\r\n" +
+ "class DerivedTest(BaseTest):\r\n" +
+ " pass\r\n" +
+ "\r\n";
+
+ projectContent = new DefaultProjectContent();
+ PythonParser parser = new PythonParser();
+ string fileName = @"C:\test.py";
+ compilationUnit = parser.Parse(projectContent, fileName, python);
+ projectContent.UpdateCompilationUnit(null, compilationUnit, fileName);
+ if (compilationUnit.Classes.Count > 1) {
+ c = compilationUnit.Classes[1];
+ }
+ }
+
+ [Test]
+ public void DerivedTestFirstBaseTypeIsBaseTestTestCase()
+ {
+ IReturnType baseType = c.BaseTypes[0];
+ string actualBaseTypeName = baseType.FullyQualifiedName;
+ string expectedBaseTypeName = "test.BaseTest";
+ Assert.AreEqual(expectedBaseTypeName, actualBaseTypeName);
+ }
+
+ [Test]
+ public void DerivedTestBaseClassNameIsBaseTest()
+ {
+ IClass baseClass = c.BaseClass;
+ string actualName = baseClass.FullyQualifiedName;
+ string expectedName = "test.BaseTest";
+ Assert.AreEqual(expectedName, actualName);
+ }
+
+ [Test]
+ public void ProjectContentGetClassReturnsBaseTest()
+ {
+ IClass c = projectContent.GetClass("test.BaseTest", 0);
+ Assert.AreEqual("test.BaseTest", c.FullyQualifiedName);
+ }
+
+ [Test]
+ public void CompilationUnitUsingScopeNamespaceNameIsNamespaceTakenFromFileName()
+ {
+ string expectedNamespace = "test";
+ Assert.AreEqual(expectedNamespace, compilationUnit.UsingScope.NamespaceName);
+ }
+
+ [Test]
+ public void DerivedTestBaseClassHasTestCaseBaseClass()
+ {
+ IReturnType baseType = c.BaseTypes[0];
+ IClass baseClass = baseType.GetUnderlyingClass();
+ IReturnType baseBaseType = baseClass.BaseTypes[0];
+ string actualBaseTypeName = baseBaseType.FullyQualifiedName;
+ string expectedBaseTypeName = "unittest.TestCase";
+ Assert.AreEqual(expectedBaseTypeName, actualBaseTypeName);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
index 69ef73d933..a872c44704 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
@@ -79,11 +79,7 @@
-
-
-
-
@@ -104,6 +100,8 @@
+
+
@@ -199,7 +197,6 @@
-
@@ -342,12 +339,19 @@
-
-
+
+
+
+
+
+
+
+
+
@@ -364,12 +368,11 @@
-
-
-
-
-
-
+
+
+
+
+
@@ -416,9 +419,22 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -426,7 +442,6 @@
-
@@ -437,8 +452,9 @@
+
+
-
@@ -447,12 +463,12 @@
-
+
@@ -463,6 +479,7 @@
+
PythonBinding.addin
@@ -472,11 +489,13 @@
+
+
@@ -504,6 +523,10 @@
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}
ICSharpCode.Core
+
+ {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}
+ ICSharpCode.Core.WinForms
+
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}
ICSharpCode.SharpDevelop.Dom
@@ -512,6 +535,14 @@
{8035765F-D51F-4A0C-A746-2FD100E19419}
ICSharpCode.SharpDevelop.Widgets
+
+ {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}
+ UnitTesting.Tests
+
+
+ {1F261725-6318-4434-A1B1-6C70CE4CD324}
+ UnitTesting
+
{0162E499-42D0-409B-AA25-EED21F75336B}
AvalonEdit.AddIn
@@ -529,6 +560,10 @@
+
+
+
+
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/CreateNewPythonProjectTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/CreateNewPythonProjectTestFixture.cs
similarity index 100%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/CreateNewPythonProjectTestFixture.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/CreateNewPythonProjectTestFixture.cs
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/ProjectBindingTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/ProjectBindingTestFixture.cs
similarity index 100%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/ProjectBindingTestFixture.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/ProjectBindingTestFixture.cs
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguagePropertiesTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/PythonLanguagePropertiesTests.cs
similarity index 100%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguagePropertiesTests.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/PythonLanguagePropertiesTests.cs
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleFromSystemImportEverythingFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleFromSystemImportEverythingFixture.cs
index 09f4654490..a73cc401d6 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleFromSystemImportEverythingFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleFromSystemImportEverythingFixture.cs
@@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleWriteLineTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleWriteLineTestFixture.cs
index 9cea39b099..d02815eb21 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleWriteLineTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleWriteLineTestFixture.cs
@@ -12,6 +12,7 @@ using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooTextBoxFromSystemWindowsFormsImportedAsFooTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooTextBoxFromSystemWindowsFormsImportedAsFooTestFixture.cs
index 1ffbca464d..108ba743e3 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooTextBoxFromSystemWindowsFormsImportedAsFooTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooTextBoxFromSystemWindowsFormsImportedAsFooTestFixture.cs
@@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalClassInstanceTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalClassInstanceTestFixture.cs
index 0db59b8a0c..9f5c872712 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalClassInstanceTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalClassInstanceTestFixture.cs
@@ -12,6 +12,7 @@ using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
@@ -27,7 +28,7 @@ namespace PythonBinding.Tests.Resolver
public class ResolveLocalClassInstanceTestFixture
{
PythonResolver resolver;
- MockProjectContent mockProjectContent;
+ PythonBinding.Tests.Utils.MockProjectContent mockProjectContent;
LocalResolveResult resolveResult;
MockClass testClass;
ICompilationUnit compilationUnit;
@@ -37,7 +38,7 @@ namespace PythonBinding.Tests.Resolver
{
resolver = new PythonResolver();
- mockProjectContent = new MockProjectContent();
+ mockProjectContent = new PythonBinding.Tests.Utils.MockProjectContent();
testClass = new MockClass(mockProjectContent, "Test.Test1");
mockProjectContent.ClassesInProjectContent.Add(testClass);
mockProjectContent.ClassToReturnFromGetClass = testClass;
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemConsoleTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemConsoleTestFixture.cs
index 626bb6455b..0e014b791c 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemConsoleTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemConsoleTestFixture.cs
@@ -12,6 +12,7 @@ using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
@@ -23,7 +24,7 @@ namespace PythonBinding.Tests.Resolver
public class ResolveSystemConsoleTestFixture
{
PythonResolver resolver;
- MockProjectContent mockProjectContent;
+ PythonBinding.Tests.Utils.MockProjectContent mockProjectContent;
ResolveResult resolveResult;
MockClass testClass;
ICompilationUnit compilationUnit;
@@ -34,7 +35,7 @@ namespace PythonBinding.Tests.Resolver
public void SetUpFixture()
{
resolver = new PythonResolver();
- mockProjectContent = new MockProjectContent();
+ mockProjectContent = new PythonBinding.Tests.Utils.MockProjectContent();
systemConsoleClass = new MockClass(mockProjectContent, "System.Console");
mockProjectContent.ClassToReturnFromGetClass = systemConsoleClass;
@@ -106,7 +107,7 @@ namespace PythonBinding.Tests.Resolver
protected virtual ICompilationUnit CreateCompilationUnit(IProjectContent projectContent)
{
ICompilationUnit compilationUnit = new DefaultCompilationUnit(projectContent);
- testClass = new MockClass(compilationUnit, "Test");
+ testClass = new MockClass(projectContent, "Test");
compilationUnit.Classes.Add(testClass);
return compilationUnit;
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceWithMissingImportTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceWithMissingImportTestFixture.cs
index bb7a50a2f1..7a30fb97a4 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceWithMissingImportTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceWithMissingImportTestFixture.cs
@@ -11,6 +11,7 @@ using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture.cs
index 2f5d3448ff..6fe5b03465 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture.cs
@@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture.cs
index 3157cd7283..304ad0fe38 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture.cs
@@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreatePythonTestRunnerTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreatePythonTestRunnerTestFixture.cs
new file mode 100644
index 0000000000..09846b1aa3
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreatePythonTestRunnerTestFixture.cs
@@ -0,0 +1,52 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.Core;
+using ICSharpCode.PythonBinding;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class CreatePythonTestRunnerTestFixture
+ {
+ PythonTestFramework testFramework;
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ if (!PropertyService.Initialized) {
+ PropertyService.InitializeService(String.Empty, String.Empty, String.Empty);
+ }
+ }
+
+ [SetUp]
+ public void Init()
+ {
+ testFramework = new PythonTestFramework();
+ }
+
+ [Test]
+ public void PythonTestFrameworkCreateTestRunnerReturnsPythonTestRunner()
+ {
+ Assert.IsInstanceOf(typeof(PythonTestRunner), testFramework.CreateTestRunner());
+ }
+
+ [Test]
+ public void PythonTestFrameworkCreateTestDebuggerReturnsPythonTestDebugger()
+ {
+ Assert.IsInstanceOf(typeof(PythonTestDebugger), testFramework.CreateTestDebugger());
+ }
+
+ [Test]
+ public void PythonTestFrameworkIsBuildNeededBeforeTestRunReturnsFalse()
+ {
+ Assert.IsFalse(testFramework.IsBuildNeededBeforeTestRun);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.cs
new file mode 100644
index 0000000000..a0f36b8026
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.cs
@@ -0,0 +1,41 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.IO;
+using System.Text;
+using ICSharpCode.PythonBinding;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class CreateTextWriterFromCreateTextWriterInfoTestFixture
+ {
+ TextWriter textWriter;
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ string fileName = Path.GetTempFileName();
+ CreateTextWriterInfo info = new CreateTextWriterInfo(fileName, Encoding.UTF8, false);
+ textWriter = info.CreateTextWriter();
+ }
+
+ [TestFixtureTearDown]
+ public void TearDownFixture()
+ {
+ textWriter.Dispose();
+ }
+
+ [Test]
+ public void CreatedTextWriterEncodingIsUtf8()
+ {
+ Assert.AreEqual(Encoding.UTF8, textWriter.Encoding);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs
new file mode 100644
index 0000000000..3c8e19c2f1
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs
@@ -0,0 +1,57 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Text;
+using ICSharpCode.PythonBinding;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class CreateTextWriterInfoEqualsTestFixture
+ {
+ [Test]
+ public void CreateTextWriterInfosAreEqualWhenFileNameAndEncodingAndAppendAreEqual()
+ {
+ CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
+ CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
+ Assert.AreEqual(lhs, rhs);
+ }
+
+ [Test]
+ public void CreateTextWriterInfosAreNotEqualWhenFileNamesAreDifferent()
+ {
+ CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
+ CreateTextWriterInfo rhs = new CreateTextWriterInfo("different-filename.txt", Encoding.UTF8, true);
+ Assert.AreNotEqual(lhs, rhs);
+ }
+
+ [Test]
+ public void CreateTextWriterInfosAreNotEqualWhenEncodingsAreDifferent()
+ {
+ CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
+ CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.ASCII, true);
+ Assert.AreNotEqual(lhs, rhs);
+ }
+
+ [Test]
+ public void CreateTextWriterInfosAreNotEqualWhenAppendIsDifferent()
+ {
+ CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
+ CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, false);
+ Assert.AreNotEqual(lhs, rhs);
+ }
+
+ [Test]
+ public void CreateTextWriterInfoEqualsReturnsFalseWhenNullPassedAsParameter()
+ {
+ CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
+ Assert.IsFalse(lhs.Equals(null));
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonConsoleApplicationTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonConsoleApplicationTestFixture.cs
new file mode 100644
index 0000000000..be81d28ebd
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonConsoleApplicationTestFixture.cs
@@ -0,0 +1,95 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Diagnostics;
+using ICSharpCode.Core;
+using ICSharpCode.PythonBinding;
+using NUnit.Framework;
+using PythonBinding.Tests.Utils;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class PythonConsoleApplicationTestFixture
+ {
+ PythonConsoleApplication app;
+ AddInOptions options;
+
+ [SetUp]
+ public void Init()
+ {
+ options = new AddInOptions(new Properties());
+ options.PythonFileName = @"C:\IronPython\ipy.exe";
+ app = new PythonConsoleApplication(options);
+ }
+
+ [Test]
+ public void FileNameIsPythonFileNameFromAddInOptions()
+ {
+ string expectedFileName = @"C:\IronPython\ipy.exe";
+ Assert.AreEqual(expectedFileName, app.FileName);
+ }
+
+ [Test]
+ public void GetArgumentsReturnsDebugOptionWhenDebugIsTrue()
+ {
+ app.Debug = true;
+ string expectedCommandLine = "-X:Debug";
+
+ Assert.AreEqual(expectedCommandLine, app.GetArguments());
+ }
+
+ [Test]
+ public void GetArgumentsReturnsQuotedPythonScriptFileName()
+ {
+ app.PythonScriptFileName = @"d:\projects\my ipy\test.py";
+ string expectedCommandLine = "\"d:\\projects\\my ipy\\test.py\"";
+
+ Assert.AreEqual(expectedCommandLine, app.GetArguments());
+ }
+
+ [Test]
+ public void GetArgumentsReturnsQuotedPythonScriptFileNameAndItsCommandLineArguments()
+ {
+ app.Debug = true;
+ app.PythonScriptFileName = @"d:\projects\my ipy\test.py";
+ app.PythonScriptCommandLineArguments = "@responseFile.txt -def";
+ string expectedCommandLine =
+ "-X:Debug \"d:\\projects\\my ipy\\test.py\" @responseFile.txt -def";
+
+ Assert.AreEqual(expectedCommandLine, app.GetArguments());
+ }
+
+ [Test]
+ public void GetProcessStartInfoHasFileNameThatEqualsIronPythonConsoleApplicationExeFileName()
+ {
+ ProcessStartInfo startInfo = app.GetProcessStartInfo();
+ string expectedFileName = @"C:\IronPython\ipy.exe";
+
+ Assert.AreEqual(expectedFileName, startInfo.FileName);
+ }
+
+ [Test]
+ public void GetProcessStartInfoHasDebugFlagSetInArguments()
+ {
+ app.Debug = true;
+ ProcessStartInfo startInfo = app.GetProcessStartInfo();
+ string expectedCommandLine = "-X:Debug";
+
+ Assert.AreEqual(expectedCommandLine, startInfo.Arguments);
+ }
+
+ [Test]
+ public void GetProcessStartInfoHasWorkingDirectoryIfSet()
+ {
+ app.WorkingDirectory = @"d:\temp";
+ ProcessStartInfo startInfo = app.GetProcessStartInfo();
+ Assert.AreEqual(@"d:\temp", startInfo.WorkingDirectory);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonStandardLibraryPathTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonStandardLibraryPathTests.cs
new file mode 100644
index 0000000000..53835dd60f
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonStandardLibraryPathTests.cs
@@ -0,0 +1,82 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using ICSharpCode.PythonBinding;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class PythonStandardLibraryPathTests
+ {
+ [Test]
+ public void PathsPropertyReturnsPython26LibDirectory()
+ {
+ PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\python26\lib");
+ string[] expectedPaths = new string[] { @"c:\python26\lib" };
+ Assert.AreEqual(expectedPaths, path.Directories);
+ }
+
+ [Test]
+ public void HasPathReturnsTrueForNonEmptyPathString()
+ {
+ PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\python26\lib");
+ Assert.IsTrue(path.HasPath);
+ }
+
+ [Test]
+ public void HasPathReturnsFalseForEmptyPathString()
+ {
+ PythonStandardLibraryPath path = new PythonStandardLibraryPath(String.Empty);
+ Assert.IsFalse(path.HasPath);
+ }
+
+ [Test]
+ public void DirectoryPropertyReturnsPython26LibDirectoryAndPython26LibTkDirectory()
+ {
+ PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\python26\lib;c:\python26\lib\lib-tk");
+ string[] expectedPaths = new string[] { @"c:\python26\lib", @"c:\python26\lib\lib-tk" };
+ Assert.AreEqual(expectedPaths, path.Directories);
+ }
+
+ [Test]
+ public void DirectoryPropertyReturnsPython26LibDirectoryAndPython26LibTkDirectorySetInPathProperty()
+ {
+ PythonStandardLibraryPath path = new PythonStandardLibraryPath(String.Empty);
+ path.Path = @"c:\python26\lib;c:\python26\lib\lib-tk";
+ string[] expectedPaths = new string[] { @"c:\python26\lib", @"c:\python26\lib\lib-tk" };
+ Assert.AreEqual(expectedPaths, path.Directories);
+ }
+
+ [Test]
+ public void DirectoriesAreClearedWhenPathIsSetToDifferentValue()
+ {
+ PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\temp");
+ path.Path = @"c:\python26\lib;c:\python26\lib\lib-tk";
+ string[] expectedPaths = new string[] { @"c:\python26\lib", @"c:\python26\lib\lib-tk" };
+ Assert.AreEqual(expectedPaths, path.Directories);
+ }
+
+ [Test]
+ public void EmptyDirectoryInPathNotAddedToDirectories()
+ {
+ PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\temp;;c:\python\lib");
+ string[] expectedPaths = new string[] { @"c:\temp", @"c:\python\lib" };
+ Assert.AreEqual(expectedPaths, path.Directories);
+ }
+
+ [Test]
+ public void DirectoryWithJustWhitespaceIsNotAddedToPath()
+ {
+ PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\temp; ;c:\python\lib");
+ string[] expectedPaths = new string[] { @"c:\temp", @"c:\python\lib" };
+ Assert.AreEqual(expectedPaths, path.Directories);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestDebuggerRunsSelectedTestMethodTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestDebuggerRunsSelectedTestMethodTestFixture.cs
new file mode 100644
index 0000000000..23a00b7809
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestDebuggerRunsSelectedTestMethodTestFixture.cs
@@ -0,0 +1,156 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using ICSharpCode.Core;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.UnitTesting;
+using NUnit.Framework;
+using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class PythonTestDebuggerRunsSelectedTestMethodTestFixture
+ {
+ MockDebuggerService debuggerService;
+ UnitTesting.Tests.Utils.MockDebugger debugger;
+ MockMessageService messageService;
+ MockCSharpProject project;
+ PythonTestDebugger testDebugger;
+ MockTestResultsMonitor testResultsMonitor;
+ SelectedTests selectedTests;
+ MockMethod methodToTest;
+ AddInOptions options;
+ MockPythonFileService fileService;
+ StringBuilder responseFileText;
+ StringWriter responseFileStringWriter;
+ PythonStandardLibraryPath standardLibraryPath;
+
+ [SetUp]
+ public void Init()
+ {
+ CreateTestDebugger();
+ CreateTestMethod();
+ }
+
+ void CreateTestDebugger()
+ {
+ debuggerService = new MockDebuggerService();
+ debugger = debuggerService.MockDebugger;
+ messageService = new MockMessageService();
+ testResultsMonitor = new MockTestResultsMonitor();
+ options = new AddInOptions(new Properties());
+ options.PythonFileName = @"c:\ironpython\ipy.exe";
+ standardLibraryPath = new PythonStandardLibraryPath(@"c:\python\lib");
+ fileService = new MockPythonFileService();
+ testDebugger = new PythonTestDebugger(debuggerService, messageService, testResultsMonitor, options, standardLibraryPath, fileService);
+ }
+
+ void CreateTestMethod()
+ {
+ project = new MockCSharpProject();
+ MockClass c = new MockClass("MyNamespace.MyTestClass");
+ methodToTest = new MockMethod(c, "MyTestMethod");
+ }
+
+ void RunTestsOnSelectedTestMethod()
+ {
+ fileService.SetTempFileName(@"d:\temp\tmp66.tmp");
+ CreateTemporaryResponseFileWriter();
+
+ selectedTests = new SelectedTests(project, null, null, methodToTest);
+ testDebugger.Start(selectedTests);
+ }
+
+ void CreateTemporaryResponseFileWriter()
+ {
+ responseFileText = new StringBuilder();
+ responseFileStringWriter = new StringWriter(responseFileText);
+ fileService.SetTextWriter(responseFileStringWriter);
+ }
+
+ [Test]
+ public void TestDebuggerProcessFileNameIsIronPythonConsoleExeTakenFromAddInOptions()
+ {
+ RunTestsOnSelectedTestMethod();
+
+ string expectedFileName = @"c:\ironpython\ipy.exe";
+ Assert.AreEqual(expectedFileName, debugger.ProcessStartInfo.FileName);
+ }
+
+ [Test]
+ public void DisposingTestRunnerDeletesTemporaryResponseFile()
+ {
+ fileService.FileNameDeleted = null;
+ RunTestsOnSelectedTestMethod();
+ testDebugger.Dispose();
+
+ string expectedFileName = @"d:\temp\tmp66.tmp";
+ Assert.AreEqual(expectedFileName, fileService.FileNameDeleted);
+ }
+
+ [Test]
+ public void DisposingTestRunnerDisposesTestResultsMonitor()
+ {
+ RunTestsOnSelectedTestMethod();
+ testDebugger.Dispose();
+ Assert.IsTrue(testResultsMonitor.IsDisposeMethodCalled);
+ }
+
+ [Test]
+ public void CommandLineArgumentHasSharpDevelopTestPythonScriptAndResponseFileName()
+ {
+ AddIn addin = AddInPathHelper.CreateDummyPythonAddInInsideAddInTree();
+ addin.FileName = @"c:\sharpdevelop\addins\pythonbinding\pythonbinding.addin";
+
+ RunTestsOnSelectedTestMethod();
+
+ string expectedCommandLine =
+ "-X:Debug " +
+ "\"c:\\sharpdevelop\\addins\\pythonbinding\\TestRunner\\sdtest.py\" " +
+ "\"@d:\\temp\\tmp66.tmp\"";
+
+ Assert.AreEqual(expectedCommandLine, debugger.ProcessStartInfo.Arguments);
+ }
+
+ [Test]
+ public void PythonTestResultReturnedFromTestFinishedEvent()
+ {
+ TestResult testResult = null;
+ testDebugger.TestFinished += delegate(object source, TestFinishedEventArgs e) {
+ testResult = e.Result;
+ };
+ TestResult testResultToFire = new TestResult("test");
+ testResultsMonitor.FireTestFinishedEvent(testResultToFire);
+
+ Assert.IsInstanceOf(typeof(PythonTestResult), testResult);
+ }
+
+ [Test]
+ public void ResponseFileTextContainsPythonLibraryPathFromPythonStandardLibraryPathObjectIfNotDefinedInAddInOptions()
+ {
+ standardLibraryPath.Path = @"c:\python\lib;c:\python\lib\lib-tk";
+ options.PythonLibraryPath = String.Empty;
+ testResultsMonitor.FileName = @"c:\temp\test-results.txt";
+ RunTestsOnSelectedTestMethod();
+
+ string expectedText =
+ "/p:\"c:\\python\\lib\"\r\n" +
+ "/p:\"c:\\python\\lib\\lib-tk\"\r\n" +
+ "/r:\"c:\\temp\\test-results.txt\"\r\n" +
+ "MyNamespace.MyTestClass.MyTestMethod\r\n";
+
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestClassTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestClassTests.cs
new file mode 100644
index 0000000000..994e1a7cc9
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestClassTests.cs
@@ -0,0 +1,82 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.SharpDevelop.Dom;
+using NUnit.Framework;
+using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class PythonTestFrameworkIsTestClassTests
+ {
+ PythonTestFramework testFramework;
+
+ [SetUp]
+ public void Init()
+ {
+ testFramework = new PythonTestFramework();
+ }
+
+ [Test]
+ public void CreateClassWithUnitTestTestCaseBaseTypeReturnsClassWithFirstBaseTypeEqualToTestCase()
+ {
+ IClass c = MockClass.CreateClassWithBaseType("unittest.TestCase");
+ string name = c.BaseTypes[0].FullyQualifiedName;
+ string expectedName = "unittest.TestCase";
+ Assert.AreEqual(expectedName, name);
+ }
+
+ [Test]
+ public void IsTestClassReturnsTrueWhenClassFirstBaseTypeIsUnitTestTestCase()
+ {
+ MockClass c = MockClass.CreateClassWithBaseType("unittest.TestCase");
+ Assert.IsTrue(testFramework.IsTestClass(c));
+ }
+
+ [Test]
+ public void IsTestClassReturnsFalseWhenClassHasNoBaseTypes()
+ {
+ MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
+ Assert.IsFalse(testFramework.IsTestClass(c));
+ }
+
+ [Test]
+ public void IsTestClassReturnsFalseForNull()
+ {
+ Assert.IsFalse(testFramework.IsTestClass(null));
+ }
+
+ [Test]
+ public void IsTestClassReturnsFalseWhenFirstBaseTypeIsSystemWindowsFormsForm()
+ {
+ MockClass c = MockClass.CreateClassWithBaseType("System.Windows.Forms.Form");
+ Assert.IsFalse(testFramework.IsTestClass(c));
+ }
+
+ [Test]
+ public void IsTestClassReturnsTrueWhenDerivedClassHasBaseClassDerivedFromTestCase()
+ {
+ MockClass baseClass = MockClass.CreateClassWithBaseType("unittest.TestCase");
+ MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
+ DefaultReturnType returnType = new DefaultReturnType(baseClass);
+ c.BaseTypes.Add(returnType);
+
+ Assert.IsTrue(testFramework.IsTestClass(c));
+ }
+
+ [Test]
+ public void IsTestClassReturnsTrueWhenClassFirstBaseTypeIsUnitTest2TestCase()
+ {
+ MockClass c = MockClass.CreateClassWithBaseType("unittest2.TestCase");
+ Assert.IsTrue(testFramework.IsTestClass(c));
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestMethodTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestMethodTests.cs
new file mode 100644
index 0000000000..1ec715060d
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestMethodTests.cs
@@ -0,0 +1,49 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.PythonBinding;
+using NUnit.Framework;
+using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class PythonTestFrameworkIsTestMethodTests
+ {
+ PythonTestFramework testFramework;
+
+ [SetUp]
+ public void Init()
+ {
+ testFramework = new PythonTestFramework();
+ }
+
+ [Test]
+ public void IsTestMethodReturnsTrueForMethodThatStartsWithTest()
+ {
+ MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
+ MockMethod method = new MockMethod(c, "testRunThis");
+ Assert.IsTrue(testFramework.IsTestMethod(method));
+ }
+
+ [Test]
+ public void IsTestMethodReturnsFalseForNull()
+ {
+ Assert.IsFalse(testFramework.IsTestMethod(null));
+ }
+
+ [Test]
+ public void IsTestMethodReturnsFalseForMethodThatDoesNotStartWithTest()
+ {
+ MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
+ MockMethod method = new MockMethod(c, "RunThis");
+ Assert.IsFalse(testFramework.IsTestMethod(method));
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestProjectTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestProjectTests.cs
new file mode 100644
index 0000000000..f6a0a979ae
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestProjectTests.cs
@@ -0,0 +1,66 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.SharpDevelop.Internal.Templates;
+using ICSharpCode.SharpDevelop.Project;
+using NUnit.Framework;
+using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class PythonTestFrameworkIsTestProjectTests
+ {
+ PythonTestFramework testFramework;
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ MSBuildEngineHelper.InitMSBuildEngine();
+ }
+
+ [SetUp]
+ public void Init()
+ {
+ testFramework = new PythonTestFramework();
+ }
+
+ [Test]
+ public void IsTestProjectReturnsFalseForNull()
+ {
+ Assert.IsFalse(testFramework.IsTestProject(null));
+ }
+
+ [Test]
+ public void IsTestProjectReturnsTrueForPythonProject()
+ {
+ ProjectCreateInformation createInfo = new ProjectCreateInformation();
+ createInfo.Solution = new Solution();
+ createInfo.OutputProjectFileName = @"C:\projects\test.pyproj";
+ PythonProject project = new PythonProject(createInfo);
+
+ Assert.IsTrue(testFramework.IsTestProject(project));
+ }
+
+ [Test]
+ public void IsTestProjectReturnsFalseForNonPythonProject()
+ {
+ MockProject project = new MockProject();
+ Assert.IsFalse(testFramework.IsTestProject(project));
+ }
+
+ [Test]
+ public void IsTestProjectReturnsFalseForNullPythonProject()
+ {
+ PythonProject project = null;
+ Assert.IsFalse(testFramework.IsTestProject(project));
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultFailureTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultFailureTestFixture.cs
new file mode 100644
index 0000000000..24770b8d89
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultFailureTestFixture.cs
@@ -0,0 +1,90 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.UnitTesting;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class PythonTestResultFailureTestFixture
+ {
+ PythonTestResult pythonTestResult;
+ string stackTraceText;
+
+ [SetUp]
+ public void Init()
+ {
+ TestResult testResult = new TestResult("MyTest");
+ testResult.ResultType = TestResultType.Failure;
+ testResult.Message = "test failed";
+
+ stackTraceText =
+ "Traceback (most recent call last):\r\n" +
+ " File \"d:\\temp\\test\\PyTests\\Tests\\MyClassTest.py\", line 16, in testAssertEquals\r\n" +
+ " self.assertEqual(10, 15, 'wrong size after resize')\r\n" +
+ "AssertionError: wrong size after resize";
+
+ testResult.StackTrace = stackTraceText;
+ pythonTestResult = new PythonTestResult(testResult);
+ }
+
+ [Test]
+ public void TestResultNameIsMyTest()
+ {
+ Assert.AreEqual("MyTest", pythonTestResult.Name);
+ }
+
+ [Test]
+ public void TestResultTypeIsFailure()
+ {
+ Assert.AreEqual(TestResultType.Failure, pythonTestResult.ResultType);
+ }
+
+ [Test]
+ public void TestResultMessageIsTestFailed()
+ {
+ Assert.AreEqual("test failed", pythonTestResult.Message);
+ }
+
+ [Test]
+ public void PythonTestResultHasStackTraceFromOriginalTestResult()
+ {
+ Assert.AreEqual(stackTraceText, pythonTestResult.StackTrace);
+ }
+
+ [Test]
+ public void StackTraceFilePositionHasExpectedFileName()
+ {
+ string expectedFileName = "d:\\temp\\test\\PyTests\\Tests\\MyClassTest.py";
+ Assert.AreEqual(expectedFileName, pythonTestResult.StackTraceFilePosition.FileName);
+ }
+
+ [Test]
+ public void StackTraceFilePositionLineIs16()
+ {
+ Assert.AreEqual(16, pythonTestResult.StackTraceFilePosition.Line);
+ }
+
+ [Test]
+ public void StackTraceFilePositionColumnIsOne()
+ {
+ Assert.AreEqual(1, pythonTestResult.StackTraceFilePosition.Column);
+ }
+
+ [Test]
+ public void ChangingStackTraceToEmptyStringSetsStackTraceFilePositionToEmpty()
+ {
+ pythonTestResult.StackTraceFilePosition = new FilePosition("test.cs", 10, 2);
+ pythonTestResult.StackTrace = String.Empty;
+ Assert.IsTrue(pythonTestResult.StackTraceFilePosition.IsEmpty);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultStackTraceLineNumberOverflowTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultStackTraceLineNumberOverflowTestFixture.cs
new file mode 100644
index 0000000000..3dcfd3dd04
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultStackTraceLineNumberOverflowTestFixture.cs
@@ -0,0 +1,44 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.UnitTesting;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class PythonTestResultLineNumberOverflowTestFixture
+ {
+ PythonTestResult pythonTestResult;
+ string stackTraceText;
+
+ [SetUp]
+ public void Init()
+ {
+ TestResult testResult = new TestResult("MyTest");
+ testResult.ResultType = TestResultType.Failure;
+ testResult.Message = "test failed";
+
+ stackTraceText =
+ "Traceback (most recent call last):\r\n" +
+ " File \"d:\\temp\\test\\PyTests\\Tests\\MyClassTest.py\", line 4294967296, in testAssertEquals\r\n" +
+ " self.assertEqual(10, 15, 'wrong size after resize')\r\n" +
+ "AssertionError: wrong size after resize";
+
+ testResult.StackTrace = stackTraceText;
+ pythonTestResult = new PythonTestResult(testResult);
+ }
+
+ [Test]
+ public void StackTraceFilePositionIsEmpty()
+ {
+ Assert.IsTrue(pythonTestResult.StackTraceFilePosition.IsEmpty);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerResponseFileTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerResponseFileTestFixture.cs
new file mode 100644
index 0000000000..57b1ff8486
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerResponseFileTestFixture.cs
@@ -0,0 +1,206 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.IO;
+using System.Text;
+using ICSharpCode.Core.Services;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Project;
+using ICSharpCode.UnitTesting;
+using NUnit.Framework;
+using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class PythonTestRunnerResponseFileTestFixture
+ {
+ PythonTestRunnerResponseFile responseFile;
+ StringBuilder responseFileText;
+ StringWriter writer;
+
+ [SetUp]
+ public void Init()
+ {
+ responseFileText = new StringBuilder();
+ writer = new StringWriter(responseFileText);
+ responseFile = new PythonTestRunnerResponseFile(writer);
+ }
+
+ [Test]
+ public void WriteTestAddsTestNameToResponseFile()
+ {
+ responseFile.WriteTest("MyTests");
+
+ Assert.AreEqual("MyTests\r\n", responseFileText.ToString());
+ }
+
+ [Test]
+ public void WritePathAddsQuotedSysPathCommandLineArgument()
+ {
+ responseFile.WritePath(@"c:\mytests");
+
+ string expectedText = "/p:\"c:\\mytests\"\r\n";
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ [Test]
+ public void WriteResultsFileNameAddsQuotedResultsFileNameCommandLineArgument()
+ {
+ responseFile.WriteResultsFileName(@"c:\temp\tmp66.tmp");
+
+ string expectedText = "/r:\"c:\\temp\\tmp66.tmp\"\r\n";
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ [Test]
+ public void DisposeMethodDisposesTextWriterPassedInConstructor()
+ {
+ responseFile.Dispose();
+ Assert.Throws(delegate { writer.Write("test"); });
+ }
+
+ [Test]
+ public void WriteTestsWritesSelectedTestMethodNameWhenMethodSelected()
+ {
+ MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes();
+ method.FullyQualifiedName = "MyNamespace.MyTests.MyTestMethod";
+ SelectedTests tests = new SelectedTests(new MockCSharpProject(), null, null, method);
+
+ responseFile.WriteTests(tests);
+
+ string expectedText = "MyNamespace.MyTests.MyTestMethod\r\n";
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ [Test]
+ public void WriteTestsWritesSelectedTestClassNameWhenOnlyClassSelected()
+ {
+ MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
+ c.FullyQualifiedName = "MyNamespace.MyTests";
+ SelectedTests tests = new SelectedTests(new MockCSharpProject(), null, c, null);
+
+ responseFile.WriteTests(tests);
+
+ string expectedText = "MyNamespace.MyTests\r\n";
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ [Test]
+ public void WriteTestsWritesSelectedTestNamespaceWhenOnlyNamespaceSelected()
+ {
+ SelectedTests tests = new SelectedTests(new MockCSharpProject(), "MyNamespace", null, null);
+ responseFile.WriteTests(tests);
+
+ string expectedText = "MyNamespace\r\n";
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ [Test]
+ public void WriteTestsWritesNamespacesForAllFilesInProjectWhenOnlyProjectSelected()
+ {
+ MockCSharpProject project = new MockCSharpProject();
+
+ FileProjectItem item = new FileProjectItem(project, ItemType.Compile);
+ item.FileName = @"c:\projects\mytests\nonTestClass.py";
+ ProjectService.AddProjectItem(project, item);
+
+ item = new FileProjectItem(project, ItemType.Compile);
+ item.FileName = @"c:\projects\mytests\TestClass.py";
+ ProjectService.AddProjectItem(project, item);
+
+ SelectedTests tests = new SelectedTests(project);
+
+ responseFile.WriteTests(tests);
+
+ string expectedText =
+ "nonTestClass\r\n" +
+ "TestClass\r\n";
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ [Test]
+ public void WriteTestsWritesNothingToResponseFileWhenMethodAndClassAndNamespaceAndProjectIsNull()
+ {
+ SelectedTests tests = new SelectedTests(null);
+ responseFile.WriteTests(tests);
+ Assert.AreEqual(String.Empty, responseFileText.ToString());
+ }
+
+ [Test]
+ public void WriteTestsDoesNotThrowNullReferenceExceptionWhenNonFileProjectItemInProject()
+ {
+ MockCSharpProject project = new MockCSharpProject();
+ WebReferenceUrl webRef = new WebReferenceUrl(project);
+ webRef.Include = "test";
+ ProjectService.AddProjectItem(project, webRef);
+
+ FileProjectItem item = new FileProjectItem(project, ItemType.Compile);
+ item.FileName = @"c:\projects\mytests\myTests.py";
+ ProjectService.AddProjectItem(project, item);
+
+ SelectedTests tests = new SelectedTests(project);
+ responseFile.WriteTests(tests);
+
+ string expectedText = "myTests\r\n";
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ [Test]
+ public void WriteTestsWritesDirectoriesForReferencedProjectsToSysPathCommandLineArguments()
+ {
+ // Have to initialize the workbench since ProjectReferenceProjectItem has a dependency on
+ // WorkbenchSingleton.
+ InitializeWorkbench();
+
+ MockCSharpProject referencedProject = new MockCSharpProject();
+ referencedProject.FileName = @"c:\projects\pyproject\pyproject.pyproj";
+
+ MockCSharpProject unitTestProject = new MockCSharpProject();
+ ProjectReferenceProjectItem projectRef = new ProjectReferenceProjectItem(unitTestProject, referencedProject);
+ projectRef.FileName = @"c:\projects\pyproject\pyproject.pyproj";
+ ProjectService.AddProjectItem(unitTestProject, projectRef);
+
+ MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes();
+ method.FullyQualifiedName = "MyNamespace.MyTests.MyTestMethod";
+
+ SelectedTests tests = new SelectedTests(unitTestProject, null, null, method);
+ responseFile.WriteTests(tests);
+
+ string expectedText =
+ "/p:\"c:\\projects\\pyproject\"\r\n" +
+ "MyNamespace.MyTests.MyTestMethod\r\n";
+
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ void InitializeWorkbench()
+ {
+ string addInXml =
+ "\r\n" +
+ "\r\n" +
+ " \r\n" +
+ "\r\n" +
+ "\r\n " +
+ "";
+ AddIn addin = AddIn.Load(new StringReader(addInXml));
+ addin.Enabled = true;
+ AddInTree.InsertAddIn(addin);
+ if (!PropertyService.Initialized) {
+ PropertyService.InitializeService(String.Empty, String.Empty, String.Empty);
+ }
+ DummyServiceManager serviceManager = new DummyServiceManager();
+ ServiceManager.Instance = serviceManager;
+ WorkbenchSingleton.InitializeWorkbench(new MockWorkbench(), null);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerRunsSelectedTestMethodTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerRunsSelectedTestMethodTestFixture.cs
new file mode 100644
index 0000000000..38fce06d8d
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerRunsSelectedTestMethodTestFixture.cs
@@ -0,0 +1,225 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using ICSharpCode.Core;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.UnitTesting;
+using NUnit.Framework;
+using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
+
+namespace PythonBinding.Tests.Testing
+{
+ [TestFixture]
+ public class PythonTestRunnerRunsSelectedTestMethodTestFixture
+ {
+ MockCSharpProject project;
+ PythonTestRunner testRunner;
+ MockProcessRunner processRunner;
+ MockTestResultsMonitor testResultsMonitor;
+ SelectedTests selectedTests;
+ MockMethod methodToTest;
+ AddInOptions options;
+ MockPythonFileService fileService;
+ StringBuilder responseFileText;
+ StringWriter responseFileStringWriter;
+ PythonStandardLibraryPath standardLibraryPath;
+
+ [SetUp]
+ public void Init()
+ {
+ CreateTestRunner();
+ CreateTestMethod();
+ }
+
+ void CreateTestRunner()
+ {
+ processRunner = new MockProcessRunner();
+ testResultsMonitor = new MockTestResultsMonitor();
+ options = new AddInOptions(new Properties());
+ options.PythonFileName = @"c:\ironpython\ipy.exe";
+ fileService = new MockPythonFileService();
+ standardLibraryPath = new PythonStandardLibraryPath(@"c:\python\lib");
+
+ testRunner = new PythonTestRunner(processRunner, testResultsMonitor, options, standardLibraryPath, fileService);
+ }
+
+ void CreateTestMethod()
+ {
+ project = new MockCSharpProject();
+ MockClass c = new MockClass("MyNamespace.MyTestClass");
+ methodToTest = new MockMethod(c, "MyTestMethod");
+ }
+
+ void RunTestsOnSelectedTestMethod()
+ {
+ fileService.SetTempFileName(@"d:\temp\tmp66.tmp");
+ CreateTemporaryResponseFileWriter();
+
+ selectedTests = new SelectedTests(project, null, null, methodToTest);
+ testRunner.Start(selectedTests);
+ }
+
+ void CreateTemporaryResponseFileWriter()
+ {
+ responseFileText = new StringBuilder();
+ responseFileStringWriter = new StringWriter(responseFileText);
+ fileService.SetTextWriter(responseFileStringWriter);
+ }
+
+ [Test]
+ public void TestRunnerProcessFileNameIsIronPythonConsoleExeTakenFromAddInOptions()
+ {
+ RunTestsOnSelectedTestMethod();
+
+ string expectedFileName = @"c:\ironpython\ipy.exe";
+ Assert.AreEqual(expectedFileName, processRunner.CommandPassedToStartMethod);
+ }
+
+ [Test]
+ public void CommandLineArgumentHasSharpDevelopTestPythonScriptAndResponseFileName()
+ {
+ AddIn addin = AddInPathHelper.CreateDummyPythonAddInInsideAddInTree();
+ addin.FileName = @"c:\sharpdevelop\addins\pythonbinding\pythonbinding.addin";
+
+ RunTestsOnSelectedTestMethod();
+
+ string expectedCommandLine =
+ "\"c:\\sharpdevelop\\addins\\pythonbinding\\TestRunner\\sdtest.py\" " +
+ "\"@d:\\temp\\tmp66.tmp\"";
+
+ Assert.AreEqual(expectedCommandLine, processRunner.CommandArgumentsPassedToStartMethod);
+ }
+
+ [Test]
+ public void ResponseFileCreatedUsingTempFileName()
+ {
+ RunTestsOnSelectedTestMethod();
+
+ Assert.AreEqual(@"d:\temp\tmp66.tmp", fileService.CreateTextWriterInfoPassedToCreateTextWriter.FileName);
+ }
+
+ [Test]
+ public void ResponseFileCreatedWithUtf8Encoding()
+ {
+ RunTestsOnSelectedTestMethod();
+
+ Assert.AreEqual(Encoding.UTF8, fileService.CreateTextWriterInfoPassedToCreateTextWriter.Encoding);
+ }
+
+ [Test]
+ public void ResponseFileCreatedWithAppendSetToFalse()
+ {
+ RunTestsOnSelectedTestMethod();
+
+ Assert.IsFalse(fileService.CreateTextWriterInfoPassedToCreateTextWriter.Append);
+ }
+
+ [Test]
+ public void DisposingTestRunnerDeletesTemporaryResponseFile()
+ {
+ fileService.FileNameDeleted = null;
+ RunTestsOnSelectedTestMethod();
+ testRunner.Dispose();
+
+ string expectedFileName = @"d:\temp\tmp66.tmp";
+ Assert.AreEqual(expectedFileName, fileService.FileNameDeleted);
+ }
+
+ [Test]
+ public void DisposingTestRunnerDisposesTestResultsMonitor()
+ {
+ RunTestsOnSelectedTestMethod();
+ testRunner.Dispose();
+ Assert.IsTrue(testResultsMonitor.IsDisposeMethodCalled);
+ }
+
+ [Test]
+ public void ResponseFileTextContainsPythonLibraryPathAndTestResultsFileNameAndFullyQualifiedTestMethod()
+ {
+ standardLibraryPath.Path = String.Empty;
+ options.PythonLibraryPath = @"c:\python26\lib";
+ testResultsMonitor.FileName = @"c:\temp\test-results.txt";
+ RunTestsOnSelectedTestMethod();
+
+ string expectedText =
+ "/p:\"c:\\python26\\lib\"\r\n" +
+ "/r:\"c:\\temp\\test-results.txt\"\r\n" +
+ "MyNamespace.MyTestClass.MyTestMethod\r\n";
+
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ [Test]
+ public void ResponseFileTextDoesNotContainPythonLibraryPathIfItIsAnEmptyString()
+ {
+ options.PythonLibraryPath = String.Empty;
+ standardLibraryPath.Path = String.Empty;
+ testResultsMonitor.FileName = @"c:\temp\test-results.txt";
+ RunTestsOnSelectedTestMethod();
+
+ string expectedText =
+ "/r:\"c:\\temp\\test-results.txt\"\r\n" +
+ "MyNamespace.MyTestClass.MyTestMethod\r\n";
+
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ [Test]
+ public void ResponseFileTextContainsPythonLibraryPathFromPythonStandardLibraryPathObjectIfNotDefinedInAddInOptions()
+ {
+ standardLibraryPath.Path = @"c:\python\lib";
+ options.PythonLibraryPath = String.Empty;
+ testResultsMonitor.FileName = @"c:\temp\test-results.txt";
+ RunTestsOnSelectedTestMethod();
+
+ string expectedText =
+ "/p:\"c:\\python\\lib\"\r\n" +
+ "/r:\"c:\\temp\\test-results.txt\"\r\n" +
+ "MyNamespace.MyTestClass.MyTestMethod\r\n";
+
+ Assert.AreEqual(expectedText, responseFileText.ToString());
+ }
+
+ [Test]
+ public void ResponseFileTextWriterDisposedAfterTestsRun()
+ {
+ RunTestsOnSelectedTestMethod();
+ Assert.Throws(delegate { responseFileStringWriter.Write("test"); });
+ }
+
+ [Test]
+ public void ProcessRunnerWorkingDirectoryIsDirectoryContainingProject()
+ {
+ RunTestsOnSelectedTestMethod();
+
+ string expectedDirectory = @"c:\projects\MyTests";
+ string actualDirectory = processRunner.WorkingDirectory;
+
+ Assert.AreEqual(expectedDirectory, actualDirectory);
+ }
+
+ [Test]
+ public void PythonTestResultReturnedFromTestFinishedEvent()
+ {
+ TestResult testResult = null;
+ testRunner.TestFinished += delegate(object source, TestFinishedEventArgs e) {
+ testResult = e.Result;
+ };
+ TestResult testResultToFire = new TestResult("test");
+ testResultsMonitor.FireTestFinishedEvent(testResultToFire);
+
+ Assert.IsInstanceOf(typeof(PythonTestResult), testResult);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/AddInPathHelper.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/AddInPathHelper.cs
new file mode 100644
index 0000000000..3b2722db3c
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/AddInPathHelper.cs
@@ -0,0 +1,60 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.IO;
+using ICSharpCode.Core;
+
+namespace PythonBinding.Tests.Utils
+{
+ public static class AddInPathHelper
+ {
+ public static AddIn CreateDummyPythonAddInInsideAddInTree()
+ {
+ RemoveOldAddIn();
+ AddIn addin = CreateAddIn();
+ AddInTree.InsertAddIn(addin);
+ return addin;
+ }
+
+ static void RemoveOldAddIn()
+ {
+ AddIn oldAddin = FindOldAddIn();
+ if (oldAddin != null) {
+ AddInTree.RemoveAddIn(oldAddin);
+ }
+ }
+
+ static AddIn FindOldAddIn()
+ {
+ foreach (AddIn addin in AddInTree.AddIns) {
+ if (addin.Manifest.PrimaryIdentity == "ICSharpCode.PythonBinding") {
+ return addin;
+ }
+ }
+ return null;
+ }
+
+ static AddIn CreateAddIn()
+ {
+ string xml = GetAddInXml();
+ AddIn addin = AddIn.Load(new StringReader(xml));
+ addin.FileName = @"C:\SharpDevelop\AddIns\PythonBinding\PythonBinding.addin";
+ return addin;
+ }
+
+ static string GetAddInXml()
+ {
+ return
+ "\r\n" +
+ " \r\n" +
+ " \r\n" +
+ " \r\n" +
+ "";
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedAddInOptions.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedAddInOptions.cs
deleted file mode 100644
index 00f3dee1ec..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedAddInOptions.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using ICSharpCode.Core;
-using ICSharpCode.PythonBinding;
-
-namespace PythonBinding.Tests.Utils
-{
- ///
- /// Overrides the AddInOptions GetAddInPath method to return
- /// some dummy data used for testing.
- ///
- public class DerivedAddInOptions : AddInOptions
- {
- string addInPath = String.Empty;
- string addInPathRequested = String.Empty;
-
- public DerivedAddInOptions(Properties properties) : base(properties)
- {
- }
-
- ///
- /// Gets the addin path string passed to the GetAddInPath method.
- ///
- public string AddInPathRequested {
- get { return addInPathRequested; }
- }
-
- ///
- /// Gets or sets the addin path that should be returned from the
- /// GetAddInPath method.
- ///
- public string AddInPath {
- get { return addInPath; }
- set { addInPath = value; }
- }
-
- ///
- /// Returns our dummy AddInPath.
- ///
- protected override string GetAddInPath(string addIn)
- {
- addInPathRequested = addIn;
- return addInPath;
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedPythonDesignerLoader.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedPythonDesignerLoader.cs
index 9847bb2e27..66a14d1bbe 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedPythonDesignerLoader.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedPythonDesignerLoader.cs
@@ -35,7 +35,6 @@ namespace PythonBinding.Tests.Utils
protected override void OnEndLoad(bool successful, ICollection errors)
{
- System.Console.WriteLine("DesignerLoader.OnEndLoad: successful: " + successful);
if (errors != null) {
foreach (object o in errors) {
Exception ex = o as Exception;
@@ -49,22 +48,17 @@ namespace PythonBinding.Tests.Utils
protected override void OnBeginLoad()
{
- System.Console.WriteLine("DesignerLoader.OnBeginLoad");
base.OnBeginLoad();
}
protected override void Initialize()
{
- System.Console.WriteLine("DesignerLoader.Initialize");
base.Initialize();
}
protected override void PerformLoad(IDesignerSerializationManager manager)
{
- System.Console.WriteLine("DesignerLoader.PerformLoad Before");
base.PerformLoad(manager);
- System.Console.WriteLine("DesignerLoader.PerformLoad After");
}
-
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummyServiceManager.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummyServiceManager.cs
new file mode 100644
index 0000000000..a63456cfc9
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummyServiceManager.cs
@@ -0,0 +1,32 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Windows.Forms;
+using ICSharpCode.Core.Services;
+using ICSharpCode.Core.WinForms;
+
+namespace PythonBinding.Tests.Utils
+{
+ public class DummyServiceManager : ServiceManager
+ {
+ WinFormsMessageService messageService = new WinFormsMessageService();
+
+ public DummyServiceManager()
+ {
+ }
+
+ public override IMessageService MessageService {
+ get { return messageService; }
+ }
+
+ public override object GetService(Type serviceType)
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummySynchronizeInvoke.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummySynchronizeInvoke.cs
new file mode 100644
index 0000000000..07a4dbf4fc
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummySynchronizeInvoke.cs
@@ -0,0 +1,38 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.ComponentModel;
+
+namespace PythonBinding.Tests.Utils
+{
+ public class DummySynchronizeInvoke : ISynchronizeInvoke
+ {
+ public DummySynchronizeInvoke()
+ {
+ }
+
+ public bool InvokeRequired {
+ get { return false; }
+ }
+
+ public IAsyncResult BeginInvoke(Delegate method, object[] args)
+ {
+ return null;
+ }
+
+ public object EndInvoke(IAsyncResult result)
+ {
+ return null;
+ }
+
+ public object Invoke(Delegate method, object[] args)
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockClass.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockClass.cs
deleted file mode 100644
index f3dce124e0..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockClass.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using ICSharpCode.SharpDevelop.Dom;
-
-namespace PythonBinding.Tests.Utils
-{
- ///
- /// Mock implementation of the IClass interface
- ///
- public class MockClass : DefaultClass
- {
- // derive from real DefaultClass. The resolver is free to access any information from the class,
- // and I don't want to have to adjust the mock whenever something in SharpDevelop.Dom changes.
- public MockClass(ICompilationUnit cu, string name)
- : base(cu, name)
- {
- }
-
- public MockClass(IProjectContent pc, string name)
- : base(new DefaultCompilationUnit(pc), name)
- {
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockDesignerLoaderHost.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockDesignerLoaderHost.cs
index 4c3ccf4f85..d50bc05ed6 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockDesignerLoaderHost.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockDesignerLoaderHost.cs
@@ -86,7 +86,6 @@ namespace PythonBinding.Tests.Utils
public void EndLoad(string baseClassName, bool successful, ICollection errorCollection)
{
- System.Console.WriteLine("DesignerLoaderHost.EndLoad");
}
public void Reload()
@@ -133,13 +132,11 @@ namespace PythonBinding.Tests.Utils
public Type GetType(string typeName)
{
- System.Console.WriteLine("DesignerLoaderHost.GetType: " + typeName);
return typeResolutionService.GetType(typeName);
}
public void AddService(Type serviceType, object serviceInstance)
{
- System.Console.WriteLine("DesignerLoaderHost.AddService: " + serviceType.Name + " IsNull: " + (serviceInstance == null));
serviceContainer.AddService(serviceType, serviceInstance);
}
@@ -165,7 +162,6 @@ namespace PythonBinding.Tests.Utils
public object GetService(Type serviceType)
{
- System.Console.WriteLine("DesignerLoaderHost.GetService: " + serviceType.Name);
return serviceContainer.GetService(serviceType);
}
@@ -203,7 +199,7 @@ namespace PythonBinding.Tests.Utils
TransactionOpened(this, e);
}
}
-
+
protected virtual void OnTransactionOpening(EventArgs e)
{
if (TransactionOpening != null) {
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockMethod.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockMethod.cs
deleted file mode 100644
index 6e4bd60dcd..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockMethod.cs
+++ /dev/null
@@ -1,297 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using ICSharpCode.SharpDevelop.Dom;
-
-namespace PythonBinding.Tests.Utils
-{
- ///
- /// Mock IMethod implementation.
- ///
- public class MockMethod : IMethod
- {
- public MockMethod()
- {
- }
-
- public DomRegion BodyRegion { get; set; }
-
- public IList TypeParameters {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsConstructor {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsOperator {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IList HandlesClauses {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IList Parameters {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsExtensionMethod {
- get {
- throw new NotImplementedException();
- }
- }
-
- public string FullyQualifiedName {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IReturnType DeclaringTypeReference {
- get {
- throw new NotImplementedException();
- }
- set {
- throw new NotImplementedException();
- }
- }
-
- public IMember GenericMember {
- get {
- throw new NotImplementedException();
- }
- }
-
- public DomRegion Region {
- get {
- throw new NotImplementedException();
- }
- }
-
- public string Name {
- get {
- throw new NotImplementedException();
- }
- }
-
- public string Namespace {
- get {
- throw new NotImplementedException();
- }
- }
-
- public string DotNetName {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IReturnType ReturnType {
- get {
- throw new NotImplementedException();
- }
- set {
- throw new NotImplementedException();
- }
- }
-
- public IList InterfaceImplementations {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IClass DeclaringType {
- get {
- throw new NotImplementedException();
- }
- }
-
- public ModifierEnum Modifiers {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IList Attributes {
- get {
- throw new NotImplementedException();
- }
- }
-
- public string Documentation {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsAbstract {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsSealed {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsStatic {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsConst {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsVirtual {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsPublic {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsProtected {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsPrivate {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsInternal {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsReadonly {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsProtectedAndInternal {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsProtectedOrInternal {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsOverride {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsOverridable {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsNew {
- get {
- throw new NotImplementedException();
- }
- }
-
- public bool IsSynthetic {
- get {
- throw new NotImplementedException();
- }
- }
-
- public object UserData {
- get {
- throw new NotImplementedException();
- }
- set {
- throw new NotImplementedException();
- }
- }
-
- public bool IsFrozen {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IMember CreateSpecializedMember()
- {
- throw new NotImplementedException();
- }
-
- public bool IsAccessible(IClass callingClass, bool isClassInInheritanceTree)
- {
- throw new NotImplementedException();
- }
-
- public void Freeze()
- {
- throw new NotImplementedException();
- }
-
- public int CompareTo(object obj)
- {
- throw new NotImplementedException();
- }
-
- public object Clone()
- {
- throw new NotImplementedException();
- }
-
- public ICompilationUnit CompilationUnit {
- get {
- throw new NotImplementedException();
- }
- }
-
- public IProjectContent ProjectContent {
- get {
- throw new NotImplementedException();
- }
- }
-
- public EntityType EntityType {
- get { return EntityType.Method; }
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockProject.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockProject.cs
index 2f539513a0..2eda8dc834 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockProject.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockProject.cs
@@ -292,7 +292,7 @@ namespace PythonBinding.Tests.Utils
throw new NotImplementedException();
}
- public void StartBuild(ThreadSafeServiceContainer serviceContainer, ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink)
+ public void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink)
{
throw new NotImplementedException();
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockPythonFileService.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockPythonFileService.cs
new file mode 100644
index 0000000000..27a1998081
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockPythonFileService.cs
@@ -0,0 +1,58 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.IO;
+using System.Text;
+using ICSharpCode.PythonBinding;
+
+namespace PythonBinding.Tests.Utils
+{
+ public class MockPythonFileService : IPythonFileService
+ {
+ CreateTextWriterInfo createTextWriterInfoPassedToCreateTextWriter;
+ string tempFileName;
+ TextWriter textWriter;
+ string fileNameDeleted;
+
+ public void SetTempFileName(string fileName)
+ {
+ this.tempFileName = fileName;
+ }
+
+ public string GetTempFileName()
+ {
+ return tempFileName;
+ }
+
+ public void SetTextWriter(TextWriter writer)
+ {
+ this.textWriter = writer;
+ }
+
+ public TextWriter CreateTextWriter(CreateTextWriterInfo textWriterInfo)
+ {
+ createTextWriterInfoPassedToCreateTextWriter = textWriterInfo;
+ return textWriter;
+ }
+
+ public CreateTextWriterInfo CreateTextWriterInfoPassedToCreateTextWriter {
+ get { return createTextWriterInfoPassedToCreateTextWriter; }
+ set { createTextWriterInfoPassedToCreateTextWriter = value; }
+ }
+
+ public void DeleteFile(string fileName)
+ {
+ fileNameDeleted = fileName;
+ }
+
+ public string FileNameDeleted {
+ get { return fileNameDeleted; }
+ set { fileNameDeleted = value; }
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockTypeResolutionService.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockTypeResolutionService.cs
index cf9ffde229..d52e52cf7b 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockTypeResolutionService.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockTypeResolutionService.cs
@@ -43,7 +43,6 @@ namespace PythonBinding.Tests.Utils
public Type GetType(string name)
{
- System.Console.WriteLine("TypeResolutionService.GetType: " + name);
lastTypeNameResolved = name;
if (name == "Form") {
return typeof(Form);
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs
index 6310d8b40f..a461e47415 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs
@@ -19,6 +19,9 @@ namespace PythonBinding.Tests.Utils
///
public class MockWorkbench : IWorkbench
{
+ DummySynchronizeInvoke synchronizeInvoke = new DummySynchronizeInvoke();
+ Form form = new Form();
+
public event EventHandler ActiveWorkbenchWindowChanged { add {} remove {} }
public event EventHandler ActiveViewContentChanged { add {} remove {} }
public event EventHandler ActiveContentChanged { add {} remove {} }
@@ -26,11 +29,11 @@ namespace PythonBinding.Tests.Utils
public event ViewContentEventHandler ViewClosed { add {} remove {} }
public IWin32Window MainWin32Window {
- get { return null; }
+ get { return form; }
}
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject {
- get { return null; }
+ get { return synchronizeInvoke; }
}
public System.Windows.Window MainWindow {
@@ -90,12 +93,8 @@ namespace PythonBinding.Tests.Utils
}
public IWorkbenchLayout WorkbenchLayout {
- get {
- throw new NotImplementedException();
- }
- set {
- throw new NotImplementedException();
- }
+ get { return null; }
+ set { }
}
public bool IsActiveWindow {
@@ -106,7 +105,6 @@ namespace PythonBinding.Tests.Utils
public void Initialize()
{
- throw new NotImplementedException();
}
public void ShowView(IViewContent content)
@@ -156,7 +154,6 @@ namespace PythonBinding.Tests.Utils
public void SetMemento(Properties memento)
{
- throw new NotImplementedException();
}
public bool FullScreen {
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbenchWindow.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbenchWindow.cs
index e9bc14bd9f..4687833673 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbenchWindow.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbenchWindow.cs
@@ -90,7 +90,7 @@ namespace PythonBinding.Tests.Utils
}
}
- public System.Windows.Media.Imaging.BitmapSource Icon {
+ public System.Windows.Media.ImageSource Icon {
get {
throw new NotImplementedException();
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBindingAddInFile.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/PythonBindingAddInFile.cs
similarity index 96%
rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBindingAddInFile.cs
rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/PythonBindingAddInFile.cs
index bedd439175..c41cc5fc74 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBindingAddInFile.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/PythonBindingAddInFile.cs
@@ -10,7 +10,7 @@ using System.IO;
using System.Reflection;
using System.Xml;
-namespace PythonBinding.Tests
+namespace PythonBinding.Tests.Utils
{
///
/// Utility class that reads the PythonBinding.addin file
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/AddInPathHelperTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/AddInPathHelperTestFixture.cs
new file mode 100644
index 0000000000..ceeb152e46
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/AddInPathHelperTestFixture.cs
@@ -0,0 +1,50 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.Core;
+using NUnit.Framework;
+using PythonBinding.Tests.Utils;
+
+namespace PythonBinding.Tests.Utils.Tests
+{
+ [TestFixture]
+ public class AddInPathHelperTestFixture
+ {
+ AddIn pythonAddIn;
+
+ [SetUp]
+ public void Init()
+ {
+ pythonAddIn = AddInPathHelper.CreateDummyPythonAddInInsideAddInTree();
+ }
+
+ [Test]
+ public void AddInFileNameIsCDriveSharpDevelopAddInsPythonBindingPythonBindingAddIn()
+ {
+ string expectedFileName = @"C:\SharpDevelop\AddIns\PythonBinding\PythonBinding.addin";
+ Assert.AreEqual(expectedFileName, pythonAddIn.FileName);
+ }
+
+ [Test]
+ public void StringParserAddInPathIsCDriveSharpDevelopAddInsPythonBindingForPythonBindingAddIn()
+ {
+ string directory = StringParser.Parse("${addinpath:ICSharpCode.PythonBinding}");
+ string expectedDirectory = @"C:\SharpDevelop\AddIns\PythonBinding";
+ Assert.AreEqual(expectedDirectory, directory);
+ }
+
+ [Test]
+ public void ChangingAddInFileNameReturnsExpectedFileNameFromStringParserAddInPath()
+ {
+ pythonAddIn.FileName = @"c:\def\pythonbinding.addin";
+ string expectedDirectory = @"c:\def";
+ string actualDirectory = StringParser.Parse("${addinpath:ICSharpCode.PythonBinding}");
+ Assert.AreEqual(expectedDirectory, actualDirectory);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockProjectContentTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockProjectContentTests.cs
index f3e04c8f35..bd3b3e4339 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockProjectContentTests.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockProjectContentTests.cs
@@ -11,19 +11,20 @@ using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
+using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Utils.Tests
{
[TestFixture]
public class MockProjectContentTests
{
- MockProjectContent projectContent;
+ PythonBinding.Tests.Utils.MockProjectContent projectContent;
List items;
[SetUp]
public void Init()
{
- projectContent = new MockProjectContent();
+ projectContent = new PythonBinding.Tests.Utils.MockProjectContent();
items = new List();
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockPythonFileServiceTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockPythonFileServiceTestFixture.cs
new file mode 100644
index 0000000000..0b068bd50a
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockPythonFileServiceTestFixture.cs
@@ -0,0 +1,65 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.IO;
+using System.Text;
+using ICSharpCode.PythonBinding;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Utils.Tests
+{
+ [TestFixture]
+ public class MockPythonFileServiceTestFixture
+ {
+ MockPythonFileService fileService;
+
+ [SetUp]
+ public void Init()
+ {
+ fileService = new MockPythonFileService();
+ }
+
+ [Test]
+ public void GetTempFileNameReturnsReturnsTemporaryFileName()
+ {
+ string expectedFileName = @"c:\temp\tmp1.tmp";
+ fileService.SetTempFileName(expectedFileName);
+ string tempFileName = fileService.GetTempFileName();
+ Assert.AreEqual(expectedFileName, tempFileName);
+ }
+
+ [Test]
+ public void TextWriterReturnedFromCreateTextWriter()
+ {
+ using (StringWriter stringWriter = new StringWriter(new StringBuilder())) {
+ fileService.SetTextWriter(stringWriter);
+ CreateTextWriterInfo info = new CreateTextWriterInfo(@"test.tmp", Encoding.UTF8, true);
+ Assert.AreEqual(stringWriter, fileService.CreateTextWriter(info));
+ }
+ }
+
+ [Test]
+ public void CreateTextWriterInfoIsSavedWhenCreateTextWriterMethodIsCalled()
+ {
+ fileService.CreateTextWriterInfoPassedToCreateTextWriter = null;
+ CreateTextWriterInfo info = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true);
+ fileService.CreateTextWriter(info);
+ Assert.AreEqual(info, fileService.CreateTextWriterInfoPassedToCreateTextWriter);
+ }
+
+ [Test]
+ public void DeleteFileSavesFileNameDeleted()
+ {
+ fileService.FileNameDeleted = null;
+ string expectedFileName = @"c:\temp\tmp66.tmp";
+ fileService.DeleteFile(expectedFileName);
+
+ Assert.AreEqual(expectedFileName, fileService.FileNameDeleted);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs
index 807b2dec0e..7cda0da62c 100644
--- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs
+++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs
@@ -101,17 +101,16 @@ namespace VBNetBinding
return base.GetDefaultItemType(fileName);
}
- public override void StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink)
+ public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink)
{
if (this.MinimumSolutionVersion == Solution.SolutionVersionVS2005) {
MSBuildEngine.StartBuild(this,
- buildServices,
options,
feedbackSink,
MSBuildEngine.AdditionalTargetFiles.Concat(
new [] { Path.Combine(MSBuildEngine.SharpDevelopBinPath, "SharpDevelop.CheckMSBuild35Features.targets") }));
} else {
- base.StartBuild(buildServices, options, feedbackSink);
+ base.StartBuild(options, feedbackSink);
}
}
diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs
index 54112c2b9a..0ceb9d43a0 100644
--- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs
+++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs
@@ -14,7 +14,6 @@ using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.VB;
using ICSharpCode.SharpDevelop.Editor;
-using ICSharpCode.TextEditor.Actions;
namespace VBNetBinding
{
diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj b/src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj
index 1720404192..6d715896d4 100644
--- a/src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj
+++ b/src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj
@@ -79,11 +79,6 @@
-
- {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}
- ICSharpCode.TextEditor
- False
-
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}
NRefactory
diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbenchWindow.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbenchWindow.cs
index 3ca745594c..0940a5bfa8 100644
--- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbenchWindow.cs
+++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbenchWindow.cs
@@ -39,7 +39,7 @@ namespace WixBinding.Tests.Utils
}
}
- public System.Windows.Media.Imaging.BitmapSource Icon {
+ public System.Windows.Media.ImageSource Icon {
get {
throw new NotImplementedException();
}
diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
index 2fef80ef74..388199984f 100644
--- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
+++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
@@ -263,12 +263,15 @@ namespace ICSharpCode.XamlBinding
return emptyList;
if (lastElement.LocalName.EndsWith(".", StringComparison.OrdinalIgnoreCase) || context.PressedKey == '.') {
+ if (rt == null)
+ return list;
+
string key = string.IsNullOrEmpty(lastElement.Prefix) ? "" : lastElement.Prefix + ":";
-
+
if (context.ParentElement.LocalName.StartsWith(lastElement.LocalName.TrimEnd('.'), StringComparison.OrdinalIgnoreCase)) {
AddAttributes(rt, list, includeEvents);
AddAttachedProperties(rt.GetUnderlyingClass(), list, key, lastElement.Name.Trim('.'));
- } else if (rt != null && rt.GetUnderlyingClass() != null)
+ } else
AddAttachedProperties(rt.GetUnderlyingClass(), list, key, lastElement.Name.Trim('.'));
} else {
if (rt == null) {
@@ -1283,6 +1286,9 @@ namespace ICSharpCode.XamlBinding
public static void AddAttachedProperties(IClass c, List result, string key, string prefix)
{
+ if (c == null)
+ return;
+
var attachedProperties = c.Fields.Where(f => f.IsAttached(true, false));
int prefixLength = (prefix.Length > 0) ? prefix.Length + 1 : 0;
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
index 967cd4788b..8c8d10176a 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
+++ b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
@@ -183,14 +183,12 @@
-
-
@@ -248,15 +246,7 @@
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/ObjectGraphPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/ObjectGraphPad.cs
index 59578ca350..93bc02e9b7 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/ObjectGraphPad.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/ObjectGraphPad.cs
@@ -49,7 +49,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{
// BUG: if pad window is undocked and floats standalone, IsVisible == false (so pad won't refresh)
// REQUEST: need to refresh when pad becomes visible -> VisibleChanged event?
- if (!this.IsVisible)
+ if (!objectGraphControl.IsVisible)
{
return;
}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Commands/VisualizerDescriptors.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Commands/VisualizerDescriptors.cs
index 7893dfd990..ffbfefaf63 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Commands/VisualizerDescriptors.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Commands/VisualizerDescriptors.cs
@@ -31,7 +31,7 @@ namespace Debugger.AddIn.Visualizers
public static ReadOnlyCollection GetAllDescriptors()
{
if (allDescriptors == null) {
- allDescriptors = new List(CreateAllDescriptors()).AsReadOnly();
+ allDescriptors = CreateAllDescriptors().ToList().AsReadOnly();
}
return allDescriptors;
}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/BoxDotFormatter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/BoxDotFormatter.cs
deleted file mode 100644
index f37562f41b..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/BoxDotFormatter.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Text;
-using System.Windows;
-
-namespace Debugger.AddIn.Visualizers.Graph.Layout
-{
- ///
- /// that treats node as a atomic "box". Edges go from box to box.
- ///
- public class BoxDotFormatter : DotFormatter
- {
- public BoxDotFormatter(PositionedGraph posGraph) : base(posGraph)
- {
- }
-
- protected override void appendPosNode(PositionedGraphNode node, StringBuilder builder)
- {
- string nodeName = genId.GetNextId().ToString();
- nodeNames[node] = nodeName;
-
- Rect neatoInput = transform.NodeToNeatoInput(node);
-
- string dotFormatNode =
- string.Format(this.neatoDoubleFormatter,
- "{0} [pos=\"{1},{2}!\" width=\"{3}\" height=\"{4}\"];",
- nodeName, neatoInput.Location.X, neatoInput.Location.Y, neatoInput.Width, neatoInput.Height);
- builder.AppendLine(dotFormatNode);
- }
-
- protected override void appendPosEdge(PositionedEdge edge, StringBuilder builder)
- {
- string sourceNodeName = nodeNames[edge.Source.ContainingNode];
- string targetNodeName = nodeNames[edge.Target];
-
- builder.AppendLine(string.Format("{0} -> {1}", sourceNodeName, targetNodeName));
- }
- }
-}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/DotFormatter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/DotFormatter.cs
deleted file mode 100644
index 7c22473b17..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/DotFormatter.cs
+++ /dev/null
@@ -1,183 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Text;
-using System.Linq;
-using System.Windows;
-
-namespace Debugger.AddIn.Visualizers.Graph.Layout
-{
- ///
- /// Converts
- /// Gets Graphviz's dot format string for wrapped positioned graph.
- ///
- public string OutputGraphInDotFormat()
- {
- StringBuilder dotStringBuilder = new StringBuilder(getGraphHeader());
-
- foreach (PositionedGraphNode posNode in this.posGraph.Nodes)
- {
- appendPosNode(posNode, dotStringBuilder);
- }
- foreach (PositionedEdge posEdge in this.posGraph.Edges)
- {
- appendPosEdge(posEdge, dotStringBuilder);
- }
-
- dotStringBuilder.AppendLine(getGraphFooter());
- return dotStringBuilder.ToString();
- }
-
- private bool validateSplinePoints(PositionedEdge edge)
- {
- // must have correct number of points: one start point and 3 points per bezier segment
- return ((edge.SplinePoints.Count - 1) % 3) == 0;
- }
-
- ///
- /// Parses edge positions (from Graphviz's plain format) and sets these positions to underlying positioned graph.
- ///
- /// Graph with positions in Graphviz's plain format
- /// with edge positions filled.
- public PositionedGraph ParseEdgePositions(string dotGraphString)
- {
- using (StringReader reader = new System.IO.StringReader(dotGraphString))
- {
- skipAfterPattern(reader, "node " + nodeNames[posGraph.Nodes.First()] + " ");
- Point neatoFirstNodePos = readPoint(reader);
- PositionedGraphNode firstNode = posGraph.Nodes.First();
- Point firstNodePosOur = transform.AsNeato(firstNode.Center);
- // determine how Neato shifted the nodes
- transform.NeatoShiftX = neatoFirstNodePos.X - firstNodePosOur.X;
- transform.NeatoShiftY = neatoFirstNodePos.Y - firstNodePosOur.Y;
-
- // assume that edges on output are in the same order as posGraph.Edges (!)
- foreach (PositionedEdge posEdge in posGraph.Edges)
- {
- skipAfterPattern(reader, "edge ");
-
- readWord(reader); // source node name
- readWord(reader); // target node name
-
- int splinePointCount = readInt(reader);
- for (int i = 0; i < splinePointCount; i++)
- {
- Point edgePoint = readPoint(reader);
- edgePoint = transform.FromNeatoOutput(edgePoint);
- posEdge.SplinePoints.Add(edgePoint);
- }
-
- bool edgeOk = validateSplinePoints(posEdge);
- if (!edgeOk)
- throw new DebuggerVisualizerException("Parsed edge invalid");
- }
- }
- // return original graph with filled edge positions
- return this.posGraph;
- }
-
- private Point readPoint(TextReader reader)
- {
- double x = readDouble(reader);
- double y = readDouble(reader);
-
- return new Point(x, y);
- }
-
- private double readDouble(TextReader reader)
- {
- return double.Parse(readWord(reader), this.neatoDoubleFormatter.DoubleCulture);
- }
-
- private int readInt(TextReader reader)
- {
- return int.Parse(readWord(reader));
- }
-
- private string readWord(TextReader reader)
- {
- StringBuilder word = new StringBuilder();
- int ch = ' ';
- while ((ch = reader.Read()) != ' ')
- {
- if (ch == -1 || ch == '\n' || ch == '\t')
- break;
-
- word.Append((char)ch);
- }
- return word.ToString();
- }
-
- private bool skipAfterPattern(StringReader reader, string pattern)
- {
- int ch = -1;
- int pIndex = 0;
- int pTarget = pattern.Length;
- while ((ch = reader.Read()) != -1)
- {
- if (ch == pattern[pIndex])
- {
- pIndex++;
- if (pIndex == pTarget)
- return true;
- }
- else
- {
- pIndex = 0;
- }
- }
- return false;
- }
- }
-}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/IdGenerator.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/IdGenerator.cs
deleted file mode 100644
index 77eb424c28..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/IdGenerator.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace Debugger.AddIn.Visualizers.Graph.Layout
-{
- ///
- /// Generates sequential ids, usefull for node and edge ids.
- ///
- public class IdGenerator
- {
- int currentId = 0;
-
- public IdGenerator()
- {
- }
-
- public int GetNextId()
- {
- return currentId++;
- }
- }
-}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoDoubleFormatter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoDoubleFormatter.cs
deleted file mode 100644
index 01a7064ce2..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoDoubleFormatter.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Globalization;
-
-namespace Debugger.AddIn.Visualizers.Graph.Layout
-{
- ///
- /// When used as IFormatProvider in string.Format, formats doubles to be suitable for Neato.
- ///
- public class NeatoDoubleFormatter : IFormatProvider, ICustomFormatter
- {
- private CultureInfo doubleCulture = CultureInfo.GetCultureInfo("en-US");
- ///
- /// CultureInfo used for formatting and parsing doubles (en-US).
- ///
- public CultureInfo DoubleCulture
- {
- get { return this.doubleCulture; }
- }
-
- public object GetFormat(Type formatType)
- {
- if (formatType == typeof(ICustomFormatter))
- return this;
- else
- return null;
- }
-
- public string Format(string format, object arg, IFormatProvider formatProvider)
- {
- return string.Format(doubleCulture, "{0:0.000}", arg);
- }
- }
-}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoEdgeRouter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoEdgeRouter.cs
deleted file mode 100644
index 7482282a08..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoEdgeRouter.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Text;
-using System.Linq;
-using System.Windows;
-
-namespace Debugger.AddIn.Visualizers.Graph.Layout
-{
- ///
- /// Given with positions of nodes, calculates positions of edges.
- ///
- public class NeatoEdgeRouter
- {
- public NeatoEdgeRouter()
- {
- }
-
- ///
- /// Given with node positions, calculates edge positions.
- ///
- /// , the nodes must have positions filled.
- /// with preserved node positions and calculated edge positions.
- public PositionedGraph CalculateEdges(PositionedGraph graphWithNodesPositioned)
- {
- DotFormatter dotFormatter = new BoxDotFormatter(graphWithNodesPositioned);
-
- // convert PosGraph to .dot string
- string dotGraphString = dotFormatter.OutputGraphInDotFormat();
-
- // pass to neato.exe and wait for output
- string dotGraphStringWithPositions = NeatoProcess.Start().CalculatePositions(dotGraphString);
-
- // parse edge positions from neato's plain output format
- PositionedGraph result = dotFormatter.ParseEdgePositions(dotGraphStringWithPositions);
-
- return result;
- }
- }
-}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoPositionTransform.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoPositionTransform.cs
deleted file mode 100644
index 2bf6fd1efd..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoPositionTransform.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows;
-
-namespace Debugger.AddIn.Visualizers.Graph.Layout
-{
- ///
- /// Transforms positions to and from Neato.
- ///
- public class NeatoPositionTransform
- {
- private Rect graphBoundingRect;
-
- // So that Neato works with smaller numbers. Always > 1
- double ourInputScale = 40;
- // Neato itself scales input by this constant. Always > 1, 1 for plain output, 72 for .dot output
- double neatoOutputScale = 1;
-
- public NeatoPositionTransform(Rect graphBoundingRectangle)
- {
- graphBoundingRect = graphBoundingRectangle;
- }
-
- ///
- /// X shift, in Neato coords.
- ///
- public double NeatoShiftX { get; set; }
- ///
- /// Y shift, in Neato coords.
- ///
- public double NeatoShiftY { get; set; }
-
- public Point ToNeatoInput(Point ourPoint)
- {
- // invert Y axis, as Neato expects this
- return new Point(ourPoint.X / ourInputScale, (graphBoundingRect.Bottom - ourPoint.Y) / ourInputScale);
- }
-
- public System.Windows.Point FromNeatoOutput(Point neatoPoint)
- {
- // Neato multiplies coords by 72 and adds arbitrary shift (which has to be parsed)
- double ourX = (neatoPoint.X - NeatoShiftX) / neatoOutputScale * ourInputScale;
- double ourYInverted = (neatoPoint.Y - NeatoShiftY) / neatoOutputScale * ourInputScale;
- // invert back - our Y axis grows down
- return new Point(ourX, graphBoundingRect.Bottom - ourYInverted);
- }
-
- ///
- /// Transform points as Neato would transform it if Neato used no shift
- ///
- ///
- ///
- public System.Windows.Point AsNeato(Point ourPoint)
- {
-
- return new Point(ourPoint.X * neatoOutputScale / ourInputScale, (graphBoundingRect.Bottom - ourPoint.Y) * neatoOutputScale / ourInputScale);
- }
-
- public Rect NodeToNeatoInput(PositionedGraphNode node)
- {
- // don't transform size
- return new Rect(ToNeatoInput(node.Center),
- new Size(node.Width / ourInputScale, node.Height / ourInputScale));
- }
- }
-}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoProcess.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoProcess.cs
deleted file mode 100644
index d1d750b570..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoProcess.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.IO;
-using System.Text;
-
-namespace Debugger.AddIn.Visualizers.Graph.Layout
-{
- ///
- /// Encapsulates Neato.exe.
- ///
- public class NeatoProcess
- {
- private System.Diagnostics.Process neatoProcess;
-
- ///
- /// Starts neato.exe
- ///
- public static NeatoProcess Start()
- {
- System.Diagnostics.Process neatoProcess = new System.Diagnostics.Process();
- neatoProcess.StartInfo.FileName = getNeatoExePath();
- neatoProcess.StartInfo.RedirectStandardInput = true;
- neatoProcess.StartInfo.RedirectStandardError = true;
- neatoProcess.StartInfo.RedirectStandardOutput = true;
- neatoProcess.StartInfo.UseShellExecute = false;
- neatoProcess.StartInfo.CreateNoWindow = true;
- // tell neato to use splines instead of straigt lines
- // output type = Graphviz's plain format
- neatoProcess.StartInfo.Arguments = " -Gsplines=true -Tplain";
- //p.EnableRaisingEvents = true;
- neatoProcess.Exited += delegate {
- neatoProcess.Dispose();
- };
- /*p.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) {
- };
- p.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e) {
- };*/
-
- neatoProcess.Start();
-
- return new NeatoProcess(neatoProcess);
- }
-
- /// Creates new NeatoProcess.
- /// Underlying neato.exe process
- private NeatoProcess(System.Diagnostics.Process neatoProcess)
- {
- this.neatoProcess = neatoProcess;
- }
-
- /// Gets directory where Debugger.AddIn.dll resides
- private static string getCurrentAssemblyPath()
- {
- return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
- }
-
- private static string getNeatoExePath()
- {
- return Path.Combine(getCurrentAssemblyPath(), "neato.exe");
- }
-
- ///
- /// Passes given graph to neato and reads output.
- ///
- /// Graph in Graphviz dot format.
- /// Same graph in Graphviz plain format with position information added.
- public string CalculatePositions(string dotGraph)
- {
- // write the input to neato.exe to a file for testing purposes
- /*using (var writer = new StreamWriter(Path.Combine(getCurrentAssemblyPath(), "logIn.gv")))
- {
- writer.Write(dotGraph);
- }*/
-
- neatoProcess.StandardInput.Write(dotGraph);
- neatoProcess.StandardInput.Flush();
- neatoProcess.StandardInput.Close();
-
- StringBuilder output = new StringBuilder();
- while(true)
- {
- string line = neatoProcess.StandardOutput.ReadLine();
- if (line == null)
- {
- // happens if neato.exe is killed
- throw new DebuggerVisualizerException("Problem getting layout information from neato.exe");
- }
- if (line == "stop")
- {
- break;
- }
- output.AppendLine(line);
- }
-
- return output.ToString();
- }
- }
-}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/RecordDotFormatter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/RecordDotFormatter.cs
deleted file mode 100644
index 0398743608..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/RecordDotFormatter.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Windows;
-
-namespace Debugger.AddIn.Visualizers.Graph.Layout
-{
- ///
- /// that treats nodes as records of properties.
- /// Edges start at property, end at node.
- ///
- public class RecordDotFormatter : DotFormatter
- {
- private Dictionary propertyIds = new Dictionary();
-
- public RecordDotFormatter(PositionedGraph posGraph) : base(posGraph)
- {
- }
-
- protected override string getGraphHeader()
- {
- return "digraph G { rankdir=LR; node [shape = record];";
- }
-
- protected override void appendPosNode(PositionedGraphNode node, StringBuilder builder)
- {
- string nodeName = genId.GetNextId().ToString();
- nodeNames[node] = nodeName;
-
- Rect neatoInput = transform.NodeToNeatoInput(node);
-
- StringBuilder recordLabel = new StringBuilder();
- bool first = true;
- foreach (var prop in node.Properties)
- {
- string propertyId = "f" + genId.GetNextId().ToString();
- propertyIds[prop] = propertyId;
- if (!first)
- {
- recordLabel.Append("|");
- }
- recordLabel.Append(string.Format("<{0}> l", propertyId));
- first = false;
- }
-
- string dotFormatNode =
- string.Format(this.neatoDoubleFormatter,
- "{0} [pos=\"{1},{2}!\" width=\"{3}\" height=\"{4}\" label=\"{5}\"];",
- nodeName,
- neatoInput.Location.X, neatoInput.Location.Y, neatoInput.Width, neatoInput.Height,
- recordLabel.ToString());
- builder.AppendLine(dotFormatNode);
- }
-
- protected override void appendPosEdge(PositionedEdge edge, StringBuilder builder)
- {
- string sourceNodeName = nodeNames[edge.Source.ContainingNode];
- string sourcePropertyName = propertyIds[edge.Source];
- string targetNodeName = nodeNames[edge.Target];
-
- builder.AppendLine(string.Format("{0}:{1} -> {2}", sourceNodeName, sourcePropertyName, targetNodeName));
- }
- }
-}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/NodeControlCache.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/NodeControlCache.cs
index 0734d71ed0..9e4ccffa5b 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/NodeControlCache.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/NodeControlCache.cs
@@ -13,7 +13,7 @@ using System.Linq;
namespace Debugger.AddIn.Visualizers.Graph
{
///
- /// Description of NodeControlCache.
+ /// Store to reuse s so that they don't have to be created for every drawing.
///
public class NodeControlCache
{
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphProperty.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphProperty.cs
index 26bcc7d56d..14b05bb309 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphProperty.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphProperty.cs
@@ -64,7 +64,7 @@ namespace Debugger.AddIn.Visualizers.Graph
this.IsAtomic = debuggerVal.Type.IsAtomic();
this.IsNull = debuggerVal.IsNull;
- // null and complex properties evaluate to empty string
+ // null and complex properties will show empty string
this.Value = debuggerVal.IsNull || (!this.IsAtomic) ? string.Empty : debuggerVal.InvokeToString();
this.evaluateCalled = true;
}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml.cs
index c27bbf2709..3bb8dcb65c 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml.cs
@@ -109,7 +109,7 @@ namespace Debugger.AddIn.Visualizers.Graph
this.graphDrawer.ClearCanvas();
return;
}
- if (debuggerService.IsProcessRunning) // TODO "Process not paused" exception still occurs
+ if (debuggerService.IsProcessRunning) // "Process not paused" exception still occurs
{
showErrorMessage("Cannot inspect when the process is running.");
return;
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/TreeModel/NestedNodeType.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/TreeModel/NestedNodeType.cs
deleted file mode 100644
index 1b40ea5eca..0000000000
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/TreeModel/NestedNodeType.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace Debugger.AddIn.Visualizers.Graph
-{
- ///
- /// Description of NestedNodeType.
- ///
- /*public enum NestedNodeType
- {
- ThisNode,
- BaseClassNode,
- NonPublicInstanceMembersNode,
- StaticMembersNode,
- NonPublicStaticMembersNode
- }*/
-}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/GridVisualizer/ValueProviders/EnumerableValuesProvider.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/GridVisualizer/ValueProviders/EnumerableValuesProvider.cs
index a9ba69de0a..74dfae8fba 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/GridVisualizer/ValueProviders/EnumerableValuesProvider.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/GridVisualizer/ValueProviders/EnumerableValuesProvider.cs
@@ -21,7 +21,7 @@ namespace Debugger.AddIn.Visualizers.GridVisualizer
///
/// Provides s for debugee objects implementing IEnumerable.
///
- public class EnumerableValuesProvider : GridValuesProvider
+ /*public class EnumerableValuesProvider : GridValuesProvider
{
public EnumerableValuesProvider(Expression targetObject, DebugType iEnumerableType, DebugType itemType)
:base(targetObject, iEnumerableType, itemType)
@@ -50,5 +50,5 @@ namespace Debugger.AddIn.Visualizers.GridVisualizer
yield return ObjectValue.Create(currentValue, index++, this.memberFromNameMap);
}
}
- }
+ }*/
}
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
index 29ed8bc75d..4f7e7d5935 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj
@@ -146,12 +146,16 @@
+
+
+ SharpDevelopCompletionWindow.cs
+
{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs
index 343f8567ff..8b30bc13ed 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs
@@ -133,6 +133,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
codeEditor.PrimaryTextEditor.SyntaxHighlighting =
HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(file.FileName));
+ if (!file.IsUntitled) {
+ codeEditor.PrimaryTextEditor.IsReadOnly = (File.GetAttributes(file.FileName) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly;
+ }
+
codeEditor.Load(stream);
// we set the file name after loading because this will place the fold markers etc.
codeEditor.FileName = FileName.Create(file.FileName);
@@ -177,6 +181,10 @@ namespace ICSharpCode.AvalonEdit.AddIn
StatusBarService.SetCaretPosition(this.Column, this.Line, this.Column);
}
+ public override bool IsReadOnly {
+ get { return codeEditor.PrimaryTextEditor.IsReadOnly; }
+ }
+
#region Bookmark Handling
void BookmarksAttach()
{
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs
index a9906ae182..e256860267 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs
@@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Windows.Threading;
+using ICSharpCode.AvalonEdit.AddIn.Options;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
@@ -26,6 +27,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
///
DispatcherTimer delayTimer;
const int delayMilliseconds = 800;
+ ///
+ /// Delays the Resolve check so that it does not get called too often when user holds an arrow.
+ ///
DispatcherTimer delayMoveTimer;
const int delayMoveMilliseconds = 100;
@@ -50,11 +54,18 @@ namespace ICSharpCode.AvalonEdit.AddIn
this.delayMoveTimer.Tick += TimerMoveTick;
this.editorView.TextArea.Caret.PositionChanged += CaretPositionChanged;
}
+
+ public void ClearHighlight()
+ {
+ this.highlightRenderer.ClearHighlight();
+ }
void TimerTick(object sender, EventArgs e)
{
+ if (!CodeEditorOptions.Instance.HighlightSymbol)
+ return;
+
this.delayTimer.Stop();
- LoggingService.Info("tick");
// almost the same as DebuggerService.HandleToolTipRequest
var referencesToBeHighlighted = GetReferencesInCurrentFile(this.lastResolveResult);
this.highlightRenderer.SetHighlight(referencesToBeHighlighted);
@@ -62,7 +73,9 @@ namespace ICSharpCode.AvalonEdit.AddIn
void TimerMoveTick(object sender, EventArgs e)
{
- LoggingService.Debug("move");
+ if (!CodeEditorOptions.Instance.HighlightSymbol)
+ return;
+
this.delayMoveTimer.Stop();
this.delayTimer.Stop();
var resolveResult = GetExpressionUnderCaret();
@@ -120,6 +133,13 @@ namespace ICSharpCode.AvalonEdit.AddIn
///
bool SameResolveResult(ResolveResult resolveResult, ResolveResult resolveResult2)
{
+ /*if (resolveResult == null && resolveResult2 == null)
+ return true;
+ if (resolveResult == null && resolveResult2 != null)
+ return false;
+ if (resolveResult != null && resolveResult2 == null)
+ return false;*/
+ // TODO determine if 2 ResolveResults refer to the same symbol
return false;
}
}
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
index 81b3bc977b..05f43f274c 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
@@ -305,6 +305,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
secondaryTextEditor.SetBinding(TextEditor.DocumentProperty,
new Binding(TextEditor.DocumentProperty.Name) { Source = primaryTextEditor });
+ secondaryTextEditor.SetBinding(TextEditor.IsReadOnlyProperty,
+ new Binding(TextEditor.IsReadOnlyProperty.Name) { Source = primaryTextEditor });
secondaryTextEditor.SyntaxHighlighting = primaryTextEditor.SyntaxHighlighting;
gridSplitter = new GridSplitter {
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
index 671f4ee23a..e02b91f5cd 100755
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs
@@ -72,6 +72,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
HighlightBrackets(null, e);
else if (e.PropertyName == "EnableFolding")
UpdateParseInformation();
+ else if (e.PropertyName == "HighlightSymbol")
+ this.caretReferencesRenderer.ClearHighlight();
}
#region CaretPositionChanged - Bracket Highlighting
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs
index d96485e379..c046ac1b94 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs
@@ -135,6 +135,19 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options
}
}
+ bool highlightSymbol = true;
+
+ [DefaultValue(true)]
+ public bool HighlightSymbol {
+ get { return highlightSymbol; }
+ set {
+ if (highlightSymbol != value) {
+ highlightSymbol = value;
+ OnPropertyChanged("HighlightSymbol");
+ }
+ }
+ }
+
bool useSmartIndentation = true;
[DefaultValue(true)]
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml
index 556b22ccec..29c7198180 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml
@@ -21,6 +21,9 @@
+
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs
index c942314f7f..0be18946de 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs
@@ -11,10 +11,10 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
-
using ICSharpCode.AvalonEdit.CodeCompletion;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
+using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
@@ -24,7 +24,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
///
/// The code completion window.
///
- public class SharpDevelopCompletionWindow : CompletionWindow, ICompletionListWindow
+ public partial class SharpDevelopCompletionWindow : CompletionWindow, ICompletionListWindow
{
public ICompletionItem SelectedItem {
get {
@@ -73,7 +73,13 @@ namespace ICSharpCode.AvalonEdit.AddIn
throw new ArgumentNullException("editor");
if (itemList == null)
throw new ArgumentNullException("itemList");
- this.Style = ICSharpCode.Core.Presentation.GlobalStyles.WindowStyle;
+
+ if (!itemList.ContainsAllAvailableItems) {
+ // If more items are available (Ctrl+Space wasn't pressed), show this hint
+ this.EmptyText = StringParser.Parse("${res:ICSharpCode.AvalonEdit.AddIn.SharpDevelopCompletionWindow.EmptyText}");
+ }
+
+ InitializeComponent();
this.Editor = editor;
this.itemList = itemList;
ICompletionItem suggestedItem = itemList.SuggestedItem;
@@ -86,6 +92,17 @@ namespace ICSharpCode.AvalonEdit.AddIn
this.StartOffset -= itemList.PreselectionLength;
}
+ public static readonly DependencyProperty EmptyTextProperty =
+ DependencyProperty.Register("EmptyText", typeof(string), typeof(SharpDevelopCompletionWindow),
+ new FrameworkPropertyMetadata());
+ ///
+ /// The text thats is displayed when the is empty.
+ ///
+ public string EmptyText {
+ get { return (string)GetValue(EmptyTextProperty); }
+ set { SetValue(EmptyTextProperty, value); }
+ }
+
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.xaml
new file mode 100644
index 0000000000..4f70ddee9e
--- /dev/null
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.xaml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/StringToVisibilityConverter.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/StringToVisibilityConverter.cs
new file mode 100644
index 0000000000..dd52cf2334
--- /dev/null
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/StringToVisibilityConverter.cs
@@ -0,0 +1,29 @@
+//
+//
+//
+//
+// $Revision: $
+//
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace ICSharpCode.AvalonEdit.AddIn
+{
+ [ValueConversion(typeof(string), typeof(Visibility))]
+ public class StringToVisibilityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (!(value is string))
+ return value == null ? Visibility.Collapsed : Visibility.Visible;
+ return string.IsNullOrEmpty((string)value) ? Visibility.Collapsed : Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return null;
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/themes/generic.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/themes/generic.xaml
index 6721aaa770..da1d6020e4 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/themes/generic.xaml
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/themes/generic.xaml
@@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ICSharpCode.AvalonEdit.AddIn"
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
+ xmlns:core="http://icsharpcode.net/sharpdevelop/core"
>
-
-
-
-