62 changed files with 1886 additions and 1838 deletions
@ -0,0 +1,16 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace ICSharpCode.PythonBinding |
||||||
|
{ |
||||||
|
public interface ILock : IDisposable |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
@ -1,24 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// The interface that a pad descriptor should implement.
|
|
||||||
/// Note that the actual PadDescriptor class does not
|
|
||||||
/// have an interface.
|
|
||||||
/// </summary>
|
|
||||||
public interface IPadDescriptor |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Brings the pad to the front of the IDE.
|
|
||||||
/// </summary>
|
|
||||||
void BringPadToFront(); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,16 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.PythonBinding |
||||||
|
{ |
||||||
|
public interface IPythonConsole |
||||||
|
{ |
||||||
|
void SendLine(string text); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.PythonBinding |
||||||
|
{ |
||||||
|
public interface IPythonConsolePad |
||||||
|
{ |
||||||
|
void BringToFront(); |
||||||
|
IConsoleTextEditor ConsoleTextEditor { get; } |
||||||
|
IPythonConsole PythonConsole { get; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
|
||||||
|
namespace ICSharpCode.PythonBinding |
||||||
|
{ |
||||||
|
public interface IPythonWorkbench |
||||||
|
{ |
||||||
|
IPythonConsolePad GetPythonConsolePad(); |
||||||
|
IViewContent ActiveViewContent { get; } |
||||||
|
} |
||||||
|
} |
@ -1,33 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Implements the IPadDescriptor interface and
|
|
||||||
/// wraps access to the actual PadDescriptor for the
|
|
||||||
/// Output Window pad.
|
|
||||||
/// </summary>
|
|
||||||
public class PythonOutputWindowPadDescriptor : IPadDescriptor |
|
||||||
{ |
|
||||||
PadDescriptor pad; |
|
||||||
|
|
||||||
public PythonOutputWindowPadDescriptor() |
|
||||||
{ |
|
||||||
pad = WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)); |
|
||||||
} |
|
||||||
|
|
||||||
public void BringPadToFront() |
|
||||||
{ |
|
||||||
pad.BringPadToFront(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.SharpDevelop; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
|
||||||
|
namespace ICSharpCode.PythonBinding |
||||||
|
{ |
||||||
|
public class PythonWorkbench : IPythonWorkbench |
||||||
|
{ |
||||||
|
IWorkbench workbench; |
||||||
|
|
||||||
|
public PythonWorkbench() |
||||||
|
{ |
||||||
|
workbench = WorkbenchSingleton.Workbench; |
||||||
|
} |
||||||
|
|
||||||
|
public IViewContent ActiveViewContent { |
||||||
|
get { return workbench.ActiveViewContent; } |
||||||
|
} |
||||||
|
|
||||||
|
public IPythonConsolePad GetPythonConsolePad() |
||||||
|
{ |
||||||
|
PadDescriptor padDescriptor = workbench.GetPad(typeof(PythonConsolePad)); |
||||||
|
return padDescriptor.PadContent as IPythonConsolePad; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.Core; |
||||||
|
using ICSharpCode.SharpDevelop.Editor; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
|
||||||
|
namespace ICSharpCode.PythonBinding |
||||||
|
{ |
||||||
|
public class SendLineToPythonConsoleCommand : AbstractCommand |
||||||
|
{ |
||||||
|
IPythonWorkbench workbench; |
||||||
|
IPythonConsolePad consolePad; |
||||||
|
PythonTextEditorViewContent textEditorView; |
||||||
|
ITextEditor activeTextEditor; |
||||||
|
IPythonConsole pythonConsole; |
||||||
|
string lineFromActiveTextEditor; |
||||||
|
|
||||||
|
public SendLineToPythonConsoleCommand() |
||||||
|
: this(new PythonWorkbench()) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public SendLineToPythonConsoleCommand(IPythonWorkbench workbench) |
||||||
|
{ |
||||||
|
this.workbench = workbench; |
||||||
|
|
||||||
|
textEditorView = new PythonTextEditorViewContent(workbench); |
||||||
|
activeTextEditor = textEditorView.TextEditor; |
||||||
|
} |
||||||
|
|
||||||
|
public override void Run() |
||||||
|
{ |
||||||
|
GetLineFromActiveTextEditor(); |
||||||
|
GetPythonConsolePad(); |
||||||
|
ShowPythonConsolePad(); |
||||||
|
AppendLineToPythonConsole(); |
||||||
|
} |
||||||
|
|
||||||
|
void GetLineFromActiveTextEditor() |
||||||
|
{ |
||||||
|
int lineNumber = activeTextEditor.Caret.Line; |
||||||
|
IDocumentLine documentLine = activeTextEditor.Document.GetLine(lineNumber); |
||||||
|
lineFromActiveTextEditor = documentLine.Text; |
||||||
|
} |
||||||
|
|
||||||
|
void GetPythonConsolePad() |
||||||
|
{ |
||||||
|
consolePad = workbench.GetPythonConsolePad(); |
||||||
|
} |
||||||
|
|
||||||
|
void ShowPythonConsolePad() |
||||||
|
{ |
||||||
|
consolePad.BringToFront(); |
||||||
|
} |
||||||
|
|
||||||
|
void AppendLineToPythonConsole() |
||||||
|
{ |
||||||
|
GetPythonConsole(); |
||||||
|
pythonConsole.SendLine(lineFromActiveTextEditor); |
||||||
|
} |
||||||
|
|
||||||
|
void GetPythonConsole() |
||||||
|
{ |
||||||
|
pythonConsole = consolePad.PythonConsole; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Threading; |
||||||
|
|
||||||
|
namespace ICSharpCode.PythonBinding |
||||||
|
{ |
||||||
|
public class StringListLock : ILock |
||||||
|
{ |
||||||
|
List<string> lines; |
||||||
|
|
||||||
|
public StringListLock(List<string> lines) |
||||||
|
{ |
||||||
|
this.lines = lines; |
||||||
|
Lock(); |
||||||
|
} |
||||||
|
|
||||||
|
void Lock() |
||||||
|
{ |
||||||
|
Monitor.Enter(lines); |
||||||
|
} |
||||||
|
|
||||||
|
public void Dispose() |
||||||
|
{ |
||||||
|
Unlock(); |
||||||
|
} |
||||||
|
|
||||||
|
void Unlock() |
||||||
|
{ |
||||||
|
Monitor.Exit(lines); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,117 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.AvalonEdit; |
||||||
|
|
||||||
|
namespace ICSharpCode.PythonBinding |
||||||
|
{ |
||||||
|
public class ThreadSafePythonConsoleTextEditor : IConsoleTextEditor |
||||||
|
{ |
||||||
|
delegate string GetLineInvoker(int index); |
||||||
|
|
||||||
|
IConsoleTextEditor consoleTextEditor; |
||||||
|
IControlDispatcher dispatcher; |
||||||
|
|
||||||
|
public ThreadSafePythonConsoleTextEditor(TextEditor textEditor) |
||||||
|
: this(new PythonConsoleTextEditor(textEditor), new ControlDispatcher(textEditor)) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public ThreadSafePythonConsoleTextEditor(IConsoleTextEditor consoleTextEditor, IControlDispatcher dispatcher) |
||||||
|
{ |
||||||
|
this.consoleTextEditor = consoleTextEditor; |
||||||
|
this.dispatcher = dispatcher; |
||||||
|
} |
||||||
|
|
||||||
|
public event ConsoleTextEditorKeyEventHandler PreviewKeyDown { |
||||||
|
add { consoleTextEditor.PreviewKeyDown += value; } |
||||||
|
remove { consoleTextEditor.PreviewKeyDown -= value; } |
||||||
|
} |
||||||
|
|
||||||
|
public void Dispose() |
||||||
|
{ |
||||||
|
consoleTextEditor.Dispose(); |
||||||
|
} |
||||||
|
|
||||||
|
public int Column { |
||||||
|
get { return consoleTextEditor.Column; } |
||||||
|
set { consoleTextEditor.Column = value; } |
||||||
|
} |
||||||
|
|
||||||
|
public int SelectionLength { |
||||||
|
get { return consoleTextEditor.SelectionLength; } |
||||||
|
} |
||||||
|
|
||||||
|
public int SelectionStart { |
||||||
|
get { return consoleTextEditor.SelectionStart; } |
||||||
|
} |
||||||
|
|
||||||
|
public int Line { |
||||||
|
get { return consoleTextEditor.Line; } |
||||||
|
set { consoleTextEditor.Line = value; } |
||||||
|
} |
||||||
|
|
||||||
|
public int TotalLines { |
||||||
|
get { return consoleTextEditor.TotalLines; } |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsCompletionWindowDisplayed { |
||||||
|
get { return consoleTextEditor.IsCompletionWindowDisplayed; } |
||||||
|
} |
||||||
|
|
||||||
|
public void Write(string text) |
||||||
|
{ |
||||||
|
if (dispatcher.CheckAccess()) { |
||||||
|
consoleTextEditor.Write(text); |
||||||
|
} else { |
||||||
|
Action<string> action = Write; |
||||||
|
dispatcher.Invoke(action, text); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void Replace(int index, int length, string text) |
||||||
|
{ |
||||||
|
if (dispatcher.CheckAccess()) { |
||||||
|
consoleTextEditor.Replace(index, length, text); |
||||||
|
} else { |
||||||
|
Action<int, int, string> action = Replace; |
||||||
|
dispatcher.Invoke(action, index, length, text); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string GetLine(int index) |
||||||
|
{ |
||||||
|
if (dispatcher.CheckAccess()) { |
||||||
|
return consoleTextEditor.GetLine(index); |
||||||
|
} else { |
||||||
|
GetLineInvoker invoker = new GetLineInvoker(GetLine); |
||||||
|
return (string)dispatcher.Invoke(invoker, index); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void ShowCompletionWindow(PythonConsoleCompletionDataProvider completionDataProvider) |
||||||
|
{ |
||||||
|
if (dispatcher.CheckAccess()) { |
||||||
|
consoleTextEditor.ShowCompletionWindow(completionDataProvider); |
||||||
|
} else { |
||||||
|
Action<PythonConsoleCompletionDataProvider> action = ShowCompletionWindow; |
||||||
|
dispatcher.Invoke(action, completionDataProvider); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void MakeCurrentContentReadOnly() |
||||||
|
{ |
||||||
|
if (dispatcher.CheckAccess()) { |
||||||
|
consoleTextEditor.MakeCurrentContentReadOnly(); |
||||||
|
} else { |
||||||
|
Action action = MakeCurrentContentReadOnly; |
||||||
|
dispatcher.Invoke(action); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,806 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.IO; |
|
||||||
using System.Reflection; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using NUnit.Framework; |
|
||||||
using PythonBinding.Tests.Utils; |
|
||||||
|
|
||||||
namespace PythonBinding.Tests.Configuration |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Basic PythonBinding.addin file tests.
|
|
||||||
/// </summary>
|
|
||||||
[TestFixture] |
|
||||||
public class AddInFileTestFixture |
|
||||||
{ |
|
||||||
AddIn addin; |
|
||||||
Codon fileFilterCodon; |
|
||||||
Codon pythonMenuCodon; |
|
||||||
Codon pythonRunMenuItemCodon; |
|
||||||
Codon pythonWithoutDebuggerRunMenuItemCodon; |
|
||||||
Codon pythonStopMenuItemCodon; |
|
||||||
Codon fileTemplatesCodon; |
|
||||||
Codon optionsPanelCodon; |
|
||||||
Codon parserCodon; |
|
||||||
Runtime pythonBindingRuntime; |
|
||||||
Codon additionalMSBuildPropertiesCodon; |
|
||||||
Codon projectBindingCodon; |
|
||||||
Codon projectFileFilterCodon; |
|
||||||
Codon codeCompletionBindingCodon; |
|
||||||
Codon applicationSettingsOptionsCodon; |
|
||||||
Codon buildEventsCodon; |
|
||||||
Codon compilingOptionsCodon; |
|
||||||
Codon debugOptionsCodon; |
|
||||||
AddInReference formsDesignerAddInRef; |
|
||||||
Runtime formsDesignerRuntime; |
|
||||||
Codon displayBindingCodon; |
|
||||||
Codon convertCodeCodon; |
|
||||||
Codon pythonFileIconCodon; |
|
||||||
Codon pythonProjectIconCodon; |
|
||||||
Codon convertCSharpProjectCodon; |
|
||||||
Codon convertVBNetProjectCodon; |
|
||||||
Codon formattingStrategyCodon; |
|
||||||
Runtime sharpdevelopRuntime; |
|
||||||
Runtime ironpythonModulesRuntime; |
|
||||||
Runtime unitTestingRuntime; |
|
||||||
Codon testFrameworkCodon; |
|
||||||
Codon languageBindingCodon; |
|
||||||
|
|
||||||
[TestFixtureSetUp] |
|
||||||
public void SetupFixture() |
|
||||||
{ |
|
||||||
using (TextReader reader = PythonBindingAddInFile.ReadAddInFile()) { |
|
||||||
addin = AddIn.Load(reader, String.Empty); |
|
||||||
|
|
||||||
fileFilterCodon = GetCodon("/SharpDevelop/Workbench/FileFilter", "Python"); |
|
||||||
pythonMenuCodon = GetCodon("/SharpDevelop/Workbench/MainMenu", "Python"); |
|
||||||
displayBindingCodon = GetCodon("/SharpDevelop/Workbench/DisplayBindings", "PythonDisplayBinding"); |
|
||||||
|
|
||||||
const string runMenuExtensionPath = "/SharpDevelop/Workbench/MainMenu/Python"; |
|
||||||
pythonRunMenuItemCodon = GetCodon(runMenuExtensionPath, "Run"); |
|
||||||
pythonWithoutDebuggerRunMenuItemCodon = GetCodon(runMenuExtensionPath, "RunWithoutDebugger"); |
|
||||||
pythonStopMenuItemCodon = GetCodon(runMenuExtensionPath, "Stop"); |
|
||||||
|
|
||||||
fileTemplatesCodon = GetCodon("/SharpDevelop/BackendBindings/Templates", "Python"); |
|
||||||
optionsPanelCodon = GetCodon("/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions", "PythonOptionsPanel"); |
|
||||||
parserCodon = GetCodon("/Workspace/Parser", "Python"); |
|
||||||
additionalMSBuildPropertiesCodon = GetCodon("/SharpDevelop/MSBuildEngine/AdditionalProperties", "PythonBinPath"); |
|
||||||
projectBindingCodon = GetCodon("/SharpDevelop/Workbench/ProjectBindings", "Python"); |
|
||||||
projectFileFilterCodon = GetCodon("/SharpDevelop/Workbench/Combine/FileFilter", "PythonProject"); |
|
||||||
codeCompletionBindingCodon = GetCodon("/AddIns/DefaultTextEditor/CodeCompletion", "Python"); |
|
||||||
applicationSettingsOptionsCodon = GetCodon("/SharpDevelop/BackendBindings/ProjectOptions/Python", "Application"); |
|
||||||
buildEventsCodon = GetCodon("/SharpDevelop/BackendBindings/ProjectOptions/Python", "BuildEvents"); |
|
||||||
compilingOptionsCodon = GetCodon("/SharpDevelop/BackendBindings/ProjectOptions/Python", "CompilingOptions"); |
|
||||||
debugOptionsCodon = GetCodon("/SharpDevelop/BackendBindings/ProjectOptions/Python", "DebugOptions"); |
|
||||||
convertCodeCodon = GetCodon("/SharpDevelop/Workbench/MainMenu/Tools/ConvertCode", "ConvertToPython"); |
|
||||||
pythonFileIconCodon = GetCodon("/Workspace/Icons", "PythonFileIcon"); |
|
||||||
pythonProjectIconCodon = GetCodon("/Workspace/Icons", "PythonProjectIcon"); |
|
||||||
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"); |
|
||||||
languageBindingCodon = GetCodon("/SharpDevelop/Workbench/LanguageBindings", "Python"); |
|
||||||
|
|
||||||
// Get the PythonBinding runtime.
|
|
||||||
foreach (Runtime runtime in addin.Runtimes) { |
|
||||||
if (runtime.Assembly == "PythonBinding.dll") { |
|
||||||
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; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// Get the forms designer dependency.
|
|
||||||
foreach (AddInReference addInRef in addin.Manifest.Dependencies) { |
|
||||||
if (addInRef.Name == "ICSharpCode.FormsDesigner") { |
|
||||||
formsDesignerAddInRef = addInRef; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void AddInName() |
|
||||||
{ |
|
||||||
Assert.AreEqual(addin.Name, "Python Binding"); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ManifestId() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding", addin.Manifest.PrimaryIdentity); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void FormsDesignerAddInIsDependency() |
|
||||||
{ |
|
||||||
Assert.IsNotNull(formsDesignerAddInRef); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void FormsDesignerRuntimeExists() |
|
||||||
{ |
|
||||||
Assert.IsNotNull(formsDesignerRuntime); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
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() |
|
||||||
{ |
|
||||||
Assert.IsNotNull(fileFilterCodon); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void FileFilterExtension() |
|
||||||
{ |
|
||||||
Assert.AreEqual("*.py", fileFilterCodon["extensions"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void FileFilterInsertBefore() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Resources", fileFilterCodon.InsertBefore); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void FileFilterInsertAfter() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Icons", fileFilterCodon.InsertAfter); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonMenuName() |
|
||||||
{ |
|
||||||
Assert.AreEqual("&Python", pythonMenuCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonMenuCodon() |
|
||||||
{ |
|
||||||
Assert.AreEqual("MenuItem", pythonMenuCodon.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonMenuCodonType() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Menu", pythonMenuCodon["type"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonMenuInsertBefore() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Tools", pythonMenuCodon.InsertBefore); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonMenuInsertAfter() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Search", pythonMenuCodon.InsertAfter); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonMenuConditionExists() |
|
||||||
{ |
|
||||||
Assert.AreEqual(1, pythonMenuCodon.Conditions.Length); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonMenuConditionName() |
|
||||||
{ |
|
||||||
ICondition condition = pythonMenuCodon.Conditions[0]; |
|
||||||
Assert.AreEqual("ActiveContentExtension", condition.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonMenuConditionActiveExtension() |
|
||||||
{ |
|
||||||
Condition condition = pythonMenuCodon.Conditions[0] as Condition; |
|
||||||
Assert.AreEqual(".py", condition["activeextension"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonStopMenuItemLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("${res:XML.MainMenu.DebugMenu.Stop}", pythonStopMenuItemCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonStopMenuItemIsMenuItem() |
|
||||||
{ |
|
||||||
Assert.AreEqual("MenuItem", pythonStopMenuItemCodon.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonStopMenuItemClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand", pythonStopMenuItemCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonStopMenuItemIcon() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Icons.16x16.StopProcess", pythonStopMenuItemCodon["icon"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunMenuItemLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("${res:XML.MainMenu.RunMenu.Run}", pythonRunMenuItemCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunMenuItemIsMenuItem() |
|
||||||
{ |
|
||||||
Assert.AreEqual("MenuItem", pythonRunMenuItemCodon.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunMenuItemClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.RunDebugPythonCommand", pythonRunMenuItemCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunMenuItemShortcut() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Control|Shift|R", pythonRunMenuItemCodon["shortcut"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunMenuItemIcon() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Icons.16x16.RunProgramIcon", pythonRunMenuItemCodon["icon"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunMenuHasSingleCondition() |
|
||||||
{ |
|
||||||
Assert.AreEqual(1, pythonRunMenuItemCodon.Conditions.Length); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunMenuConditionName() |
|
||||||
{ |
|
||||||
Condition condition = pythonRunMenuItemCodon.Conditions[0] as Condition; |
|
||||||
Assert.IsNotNull("IsProcessRunning", condition.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunMenuConditionIsDebuggingProperty() |
|
||||||
{ |
|
||||||
Condition condition = pythonRunMenuItemCodon.Conditions[0] as Condition; |
|
||||||
Assert.AreEqual("False", condition["isdebugging"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunMenuConditionIsProcessRunningProperty() |
|
||||||
{ |
|
||||||
Condition condition = pythonRunMenuItemCodon.Conditions[0] as Condition; |
|
||||||
Assert.AreEqual("False", condition["isprocessrunning"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunMenuConditionAction() |
|
||||||
{ |
|
||||||
ICondition condition = pythonRunMenuItemCodon.Conditions[0]; |
|
||||||
Assert.AreEqual(ConditionFailedAction.Disable, condition.Action); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonStopMenuHasSingleCondition() |
|
||||||
{ |
|
||||||
Assert.AreEqual(1, pythonStopMenuItemCodon.Conditions.Length); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonStopMenuConditionName() |
|
||||||
{ |
|
||||||
Condition condition = pythonStopMenuItemCodon.Conditions[0] as Condition; |
|
||||||
Assert.IsNotNull("IsProcessRunning", condition.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonStopMenuConditionIsDebuggingProperty() |
|
||||||
{ |
|
||||||
Condition condition = pythonStopMenuItemCodon.Conditions[0] as Condition; |
|
||||||
Assert.AreEqual("True", condition["isdebugging"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonStopMenuConditionAction() |
|
||||||
{ |
|
||||||
ICondition condition = pythonStopMenuItemCodon.Conditions[0]; |
|
||||||
Assert.AreEqual(ConditionFailedAction.Disable, condition.Action); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void FileTemplatesCodonType() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Directory", fileTemplatesCodon.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void FileTemplatesFolder() |
|
||||||
{ |
|
||||||
Assert.AreEqual("./Templates", fileTemplatesCodon["path"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void OptionsPanelCodonIsDialogPanel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("OptionPanel", optionsPanelCodon.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void OptionsPanelLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Python", optionsPanelCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void OptionsPanelClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.PythonOptionsPanel", optionsPanelCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void SupportedParserExtensions() |
|
||||||
{ |
|
||||||
Assert.AreEqual(".py", parserCodon["supportedextensions"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ParserClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.PythonParser", parserCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ParserProjectFileExtensions() |
|
||||||
{ |
|
||||||
Assert.AreEqual(".pyproj", parserCodon["projectfileextension"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonBinPath() |
|
||||||
{ |
|
||||||
Assert.AreEqual("${AddInPath:ICSharpCode.PythonBinding}", additionalMSBuildPropertiesCodon["text"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ProjectBindingSupportedExtensions() |
|
||||||
{ |
|
||||||
Assert.AreEqual(".py", projectBindingCodon["supportedextensions"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ProjectBindingGuid() |
|
||||||
{ |
|
||||||
Assert.AreEqual("{FD48973F-F585-4F70-812B-4D0503B36CE9}", projectBindingCodon["guid"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ProjectBindingProjectFileExtension() |
|
||||||
{ |
|
||||||
Assert.AreEqual(".pyproj", projectBindingCodon["projectfileextension"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ProjectBindingClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.PythonProjectBinding", projectBindingCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ProjectFileFilterExtensions() |
|
||||||
{ |
|
||||||
Assert.AreEqual("*.pyproj", projectFileFilterCodon["extensions"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ProjectFileFilterClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.SharpDevelop.Project.LoadProject", projectFileFilterCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ProjectFileFilterInsertBefore() |
|
||||||
{ |
|
||||||
Assert.AreEqual("AllFiles", projectFileFilterCodon.InsertBefore); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void CodeCompletionBindingCodonName() |
|
||||||
{ |
|
||||||
Assert.AreEqual("CodeCompletionBinding", codeCompletionBindingCodon.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void CodeCompletionBindingFileExtensions() |
|
||||||
{ |
|
||||||
Assert.AreEqual(".py", codeCompletionBindingCodon["extensions"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void CodeCompletionBindingClassName() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.PythonCodeCompletionBinding", codeCompletionBindingCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ApplicationSettingsCodonClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.ApplicationSettingsPanel", applicationSettingsOptionsCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ApplicationSettingsCodonLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("${res:Dialog.ProjectOptions.ApplicationSettings}", applicationSettingsOptionsCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void BuildEventsCodonClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.SharpDevelop.Gui.OptionPanels.BuildEvents", buildEventsCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void BuildEventsCodonLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("${res:Dialog.ProjectOptions.BuildEvents}", buildEventsCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void CompilingOptionsCodonClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.CompilingOptionsPanel", compilingOptionsCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void CompilingOptionsCodonLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("${res:Dialog.ProjectOptions.BuildOptions}", compilingOptionsCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void DebugOptionsCodonClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.SharpDevelop.Gui.OptionPanels.DebugOptions", debugOptionsCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void DebugOptionsCodonLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("${res:Dialog.ProjectOptions.DebugOptions}", debugOptionsCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonDisplayBindingExists() |
|
||||||
{ |
|
||||||
Assert.IsNotNull(displayBindingCodon); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonDisplayBindingIsSecondary() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Secondary", displayBindingCodon["type"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonDisplayBindingFileNamePattern() |
|
||||||
{ |
|
||||||
Assert.AreEqual(@"\.py$", displayBindingCodon["fileNamePattern"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonDisplayBindingLanguagePattern() |
|
||||||
{ |
|
||||||
Assert.AreEqual(@"^Python$", displayBindingCodon["languagePattern"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonDisplayBindingClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.PythonFormsDesignerDisplayBinding", displayBindingCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertCodeCodonExists() |
|
||||||
{ |
|
||||||
Assert.IsNotNull(convertCodeCodon); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertCodeCodonIsMenuItem() |
|
||||||
{ |
|
||||||
Assert.AreEqual("MenuItem", convertCodeCodon.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertCodeCodonInsertedAfterCSharp() |
|
||||||
{ |
|
||||||
Assert.AreEqual("CSharp", convertCodeCodon.InsertAfter); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertCodeCodonInsertedBeforeVBNet() |
|
||||||
{ |
|
||||||
Assert.AreEqual("VBNet", convertCodeCodon.InsertBefore); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertCodeCodonLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Python", convertCodeCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertCodeCodonClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.ConvertToPythonMenuCommand", convertCodeCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertCodeMenuConditionAction() |
|
||||||
{ |
|
||||||
ICondition condition = convertCodeCodon.Conditions[0]; |
|
||||||
Assert.AreEqual(ConditionFailedAction.Disable, condition.Action); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertCodeMenuConditionName() |
|
||||||
{ |
|
||||||
ICondition condition = convertCodeCodon.Conditions[0]; |
|
||||||
Assert.AreEqual("ActiveContentExtension Or ActiveContentExtension", condition.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertCodeMenuConditionIsOrCondition() |
|
||||||
{ |
|
||||||
OrCondition orCondition = convertCodeCodon.Conditions[0] as OrCondition; |
|
||||||
Assert.IsNotNull(orCondition); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertCodeMenuConditionActiveExtension() |
|
||||||
{ |
|
||||||
OrCondition orCondition = convertCodeCodon.Conditions[0] as OrCondition; |
|
||||||
|
|
||||||
// Use reflection to get the ICondition associated with the not
|
|
||||||
// condition.
|
|
||||||
Type type = orCondition.GetType(); |
|
||||||
FieldInfo fieldInfo = type.GetField("conditions", BindingFlags.NonPublic | BindingFlags.Instance); |
|
||||||
ICondition[] conditions = fieldInfo.GetValue(orCondition) as ICondition[]; |
|
||||||
|
|
||||||
Condition csharpCondition = conditions[0] as Condition; |
|
||||||
Condition vbnetCondition = conditions[1] as Condition; |
|
||||||
|
|
||||||
Assert.AreEqual(2, conditions.Length); |
|
||||||
Assert.AreEqual(".cs", csharpCondition["activeextension"]); |
|
||||||
Assert.AreEqual(".vb", vbnetCondition["activeextension"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonFileIconCodonExists() |
|
||||||
{ |
|
||||||
Assert.IsNotNull(pythonFileIconCodon); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonFileIconCodonExtensions() |
|
||||||
{ |
|
||||||
Assert.AreEqual(".py", pythonFileIconCodon["extensions"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonFileIconCodonResource() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Python.ProjectBrowser.File", pythonFileIconCodon["resource"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonProjectIconCodonExists() |
|
||||||
{ |
|
||||||
Assert.IsNotNull(pythonProjectIconCodon); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonProjectIconCodonLanguage() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Python", pythonProjectIconCodon["language"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonProjectIconCodonResource() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Python.ProjectBrowser.Project", pythonProjectIconCodon["resource"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertToCSharpProjectCodonExists() |
|
||||||
{ |
|
||||||
Assert.IsNotNull(convertCSharpProjectCodon); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertToVBNetProjectCodonExists() |
|
||||||
{ |
|
||||||
Assert.IsNotNull(convertVBNetProjectCodon); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertToCSharpProjectLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("${res:ICSharpCode.PythonBinding.ConvertCSharpProjectToPythonProject}", convertCSharpProjectCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertToVBNetProjectLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("${res:ICSharpCode.PythonBinding.ConvertVBNetProjectToPythonProject}", convertVBNetProjectCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertToCSharpProjectClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.ConvertProjectToPythonProjectCommand", convertCSharpProjectCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertToVBNetProjectClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.ConvertProjectToPythonProjectCommand", convertVBNetProjectCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertToCSharpProjectConditionName() |
|
||||||
{ |
|
||||||
ICondition condition = convertCSharpProjectCodon.Conditions[0]; |
|
||||||
Assert.AreEqual("ProjectActive", condition.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertToCSharpProjectConditionActiveExtension() |
|
||||||
{ |
|
||||||
Condition condition = convertCSharpProjectCodon.Conditions[0] as Condition; |
|
||||||
Assert.AreEqual("C#", condition["activeproject"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertToVBNetProjectConditionName() |
|
||||||
{ |
|
||||||
ICondition condition = convertVBNetProjectCodon.Conditions[0]; |
|
||||||
Assert.AreEqual("ProjectActive", condition.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void ConvertToVBNetProjectConditionActiveExtension() |
|
||||||
{ |
|
||||||
Condition condition = convertVBNetProjectCodon.Conditions[0] as Condition; |
|
||||||
Assert.AreEqual("VBNet", condition["activeproject"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunWithoutDebuggerMenuItemLabel() |
|
||||||
{ |
|
||||||
Assert.AreEqual("${res:XML.MainMenu.DebugMenu.RunWithoutDebug}", pythonWithoutDebuggerRunMenuItemCodon["label"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunWithoutDebuggerMenuItemIsMenuItem() |
|
||||||
{ |
|
||||||
Assert.AreEqual("MenuItem", pythonWithoutDebuggerRunMenuItemCodon.Name); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunWithoutDebuggerMenuItemClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.RunPythonCommand", pythonWithoutDebuggerRunMenuItemCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunWithoutDebuggerMenuItemShortcut() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Control|Shift|W", pythonWithoutDebuggerRunMenuItemCodon["shortcut"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonRunWithoutDebuggerMenuItemIcon() |
|
||||||
{ |
|
||||||
Assert.AreEqual("Icons.16x16.Debug.StartWithoutDebugging", pythonWithoutDebuggerRunMenuItemCodon["icon"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonDebugRunMenuHasSingleCondition() |
|
||||||
{ |
|
||||||
Assert.AreEqual(1, pythonWithoutDebuggerRunMenuItemCodon.Conditions.Length); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void PythonDebugRunConditionIsSameAsPythonRunCondition() |
|
||||||
{ |
|
||||||
Assert.AreEqual(pythonWithoutDebuggerRunMenuItemCodon.Conditions[0], pythonRunMenuItemCodon.Conditions[0]); |
|
||||||
} |
|
||||||
|
|
||||||
[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"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void LanguageBindingCodonExists() |
|
||||||
{ |
|
||||||
Assert.IsNotNull(languageBindingCodon); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void LanguageBindingClass() |
|
||||||
{ |
|
||||||
Assert.AreEqual("ICSharpCode.PythonBinding.PythonLanguageBinding", languageBindingCodon["class"]); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void LanguageBindingFileExtensions() |
|
||||||
{ |
|
||||||
Assert.AreEqual(".py", languageBindingCodon["extensions"]); |
|
||||||
} |
|
||||||
|
|
||||||
Codon GetCodon(string name, string extensionPath) |
|
||||||
{ |
|
||||||
return AddInHelper.GetCodon(addin, name, extensionPath); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,111 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Threading; |
|
||||||
using System.Windows.Input; |
|
||||||
using ICSharpCode.AvalonEdit; |
|
||||||
using ICSharpCode.AvalonEdit.Editing; |
|
||||||
using ICSharpCode.PythonBinding; |
|
||||||
using NUnit.Framework; |
|
||||||
using PythonBinding.Tests.Utils; |
|
||||||
using PythonBinding.Tests.Utils.Tests; |
|
||||||
|
|
||||||
namespace PythonBinding.Tests.Console |
|
||||||
{ |
|
||||||
[TestFixture] |
|
||||||
public class ConsoleTextEditorThreadSafetyTestFixture |
|
||||||
{ |
|
||||||
PythonConsoleTextEditor consoleTextEditor; |
|
||||||
TextEditor avalonEditTextEditor; |
|
||||||
MockControlDispatcher dispatcher; |
|
||||||
|
|
||||||
[TestFixtureSetUp] |
|
||||||
public void SetUpFixture() |
|
||||||
{ |
|
||||||
avalonEditTextEditor = new TextEditor(); |
|
||||||
dispatcher = new MockControlDispatcher(); |
|
||||||
consoleTextEditor = new PythonConsoleTextEditor(avalonEditTextEditor, dispatcher); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IfDispatcherCheckAccessReturnsFalseWriteMethodIsInvoked() |
|
||||||
{ |
|
||||||
dispatcher.CheckAccessReturnValue = false; |
|
||||||
dispatcher.MethodInvoked = null; |
|
||||||
|
|
||||||
consoleTextEditor.Write("abc"); |
|
||||||
Assert.IsNotNull(dispatcher.MethodInvoked); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IfDispatcherCheckAccessReturnsFalseWriteMethodIsInvokedWithTextAsArg() |
|
||||||
{ |
|
||||||
dispatcher.CheckAccessReturnValue = false; |
|
||||||
dispatcher.MethodInvokedArgs = null; |
|
||||||
|
|
||||||
consoleTextEditor.Write("abc"); |
|
||||||
object[] expectedArgs = new object[] { "abc" }; |
|
||||||
Assert.AreEqual(expectedArgs, dispatcher.MethodInvokedArgs); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IfDispatcherCheckAccessReturnsFalseGetLineMethodIsInvoked() |
|
||||||
{ |
|
||||||
dispatcher.CheckAccessReturnValue = false; |
|
||||||
dispatcher.MethodInvoked = null; |
|
||||||
|
|
||||||
consoleTextEditor.GetLine(0); |
|
||||||
Assert.IsNotNull(dispatcher.MethodInvoked); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IfDispatcherCheckAccessReturnsFalseGetLineMethodIsInvokedWithLineNumberAsArg() |
|
||||||
{ |
|
||||||
dispatcher.CheckAccessReturnValue = false; |
|
||||||
dispatcher.MethodInvokedArgs = null; |
|
||||||
|
|
||||||
consoleTextEditor.GetLine(0); |
|
||||||
object[] expectedArgs = new object[] { 0 }; |
|
||||||
Assert.AreEqual(expectedArgs, dispatcher.MethodInvokedArgs); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IfDispatcherCheckAccessReturnsFalseReplaceMethodIsInvoked() |
|
||||||
{ |
|
||||||
dispatcher.CheckAccessReturnValue = false; |
|
||||||
dispatcher.MethodInvoked = null; |
|
||||||
avalonEditTextEditor.Text = "abcd"; |
|
||||||
|
|
||||||
consoleTextEditor.Replace(0, 2, "12"); |
|
||||||
Assert.IsNotNull(dispatcher.MethodInvoked); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IfDispatcherCheckAccessReturnsFalseReplaceethodIsInvokedWithThreeArgs() |
|
||||||
{ |
|
||||||
dispatcher.CheckAccessReturnValue = false; |
|
||||||
dispatcher.MethodInvokedArgs = null; |
|
||||||
avalonEditTextEditor.Text = "abcd"; |
|
||||||
|
|
||||||
consoleTextEditor.Replace(0, 2, "12"); |
|
||||||
object[] expectedArgs = new object[] { 0, 2, "12" }; |
|
||||||
Assert.AreEqual(expectedArgs, dispatcher.MethodInvokedArgs); |
|
||||||
} |
|
||||||
|
|
||||||
[Test] |
|
||||||
public void IfDispatcherCheckAccessReturnsFalseMakeCurrentContentReadOnlyIsInvoked() |
|
||||||
{ |
|
||||||
dispatcher.CheckAccessReturnValue = false; |
|
||||||
dispatcher.MethodInvoked = null; |
|
||||||
|
|
||||||
consoleTextEditor.MakeCurrentContentReadOnly(); |
|
||||||
Assert.IsNotNull(dispatcher.MethodInvoked); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,174 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using ICSharpCode.NRefactory; |
||||||
|
using ICSharpCode.PythonBinding; |
||||||
|
using Microsoft.Scripting.Hosting.Shell; |
||||||
|
using NUnit.Framework; |
||||||
|
using PythonBinding.Tests.Utils; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Console |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class PythonConsoleSendLineTests : PythonConsoleTestsBase |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void SendLine_NoUnreadLines_AddsLineToUnreadLines() |
||||||
|
{ |
||||||
|
SendLineToConsole("test"); |
||||||
|
string[] unreadLines = TestablePythonConsole.GetUnreadLines(); |
||||||
|
|
||||||
|
string[] expectedUnreadlines = new string[] {"test"}; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedUnreadlines, unreadLines); |
||||||
|
} |
||||||
|
|
||||||
|
void SendLineToConsole(string text) |
||||||
|
{ |
||||||
|
base.CreatePythonConsole(); |
||||||
|
WritePrompt(); |
||||||
|
TestablePythonConsole.SendLine(text); |
||||||
|
} |
||||||
|
|
||||||
|
void WritePrompt() |
||||||
|
{ |
||||||
|
TestablePythonConsole.Write(">>> ", Style.Prompt); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SendLine_NoUnreadLines_CreatesLockForPreviousLines() |
||||||
|
{ |
||||||
|
SendLineToConsole("test"); |
||||||
|
List<string> lines = TestablePythonConsole.LockCreated.Lines; |
||||||
|
List<string> expectedLines = TestablePythonConsole.GetUnreadLinesList(); |
||||||
|
|
||||||
|
Assert.AreEqual(expectedLines, lines); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SendLine_NoUnreadLines_LockForPreviousLinesIsDisposed() |
||||||
|
{ |
||||||
|
SendLineToConsole("test"); |
||||||
|
bool disposed = TestablePythonConsole.LockCreated.IsDisposed; |
||||||
|
|
||||||
|
Assert.IsTrue(disposed); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SendLine_NoUnreadLines_LineNotAddedBeforeLockCreated() |
||||||
|
{ |
||||||
|
SendLineToConsole("test"); |
||||||
|
int count = TestablePythonConsole.LockCreated.UnreadLineCountWhenLockCreated; |
||||||
|
int expectedCount = 0; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedCount, count); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SendLine_NoUnreadLines_LineAddedBeforeLockDisposed() |
||||||
|
{ |
||||||
|
SendLineToConsole("test"); |
||||||
|
int count = TestablePythonConsole.LockCreated.UnreadLineCountWhenLockDisposed; |
||||||
|
int expectedCount = 1; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedCount, count); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SendLine_NoUnreadLines_LineReceivedEventIsFired() |
||||||
|
{ |
||||||
|
SendLineToConsole("test"); |
||||||
|
bool fired = TestablePythonConsole.IsLineReceivedEventFired; |
||||||
|
Assert.IsTrue(fired); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SendLine_NoUnreadLines_LineReceivedEventAfterLineAddedToUnreadLines() |
||||||
|
{ |
||||||
|
SendLineToConsole("test"); |
||||||
|
int count = TestablePythonConsole.UnreadLineCountWhenLineReceivedEventFired; |
||||||
|
int expectedCount = 1; |
||||||
|
Assert.AreEqual(expectedCount, count); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SendLine_NoUnreadLines_LineWrittenToConsoleTextEditor() |
||||||
|
{ |
||||||
|
SendLineToConsole("test"); |
||||||
|
string text = MockConsoleTextEditor.TextPassedToWrite; |
||||||
|
string expectedTextWritten = "test\r\n"; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedTextWritten, text); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SendLine_TwoLinesInConsoleTextEditorCursorOnFirstLine_CursorMovedToEndOfLastLineBeforeTextWritten() |
||||||
|
{ |
||||||
|
base.CreatePythonConsole(); |
||||||
|
WritePrompt(); |
||||||
|
MockConsoleTextEditor.Text = |
||||||
|
">>> first\r\n" + |
||||||
|
">>> second\r\n" + |
||||||
|
">>> "; |
||||||
|
|
||||||
|
MockConsoleTextEditor.Line = 0; |
||||||
|
MockConsoleTextEditor.Column = 0; |
||||||
|
TestablePythonConsole.SendLine("test"); |
||||||
|
|
||||||
|
int expectedLine = 2; |
||||||
|
int expectedColumn = 4; |
||||||
|
Location expectedLocation = new Location(expectedColumn, expectedLine); |
||||||
|
|
||||||
|
Location location = MockConsoleTextEditor.CursorLocationWhenWriteTextCalled; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedLocation, location); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SendLine_NoUnreadLines_NoTextWrittenToConsoleTextEditorBeforeFirstPromptIsWritten() |
||||||
|
{ |
||||||
|
base.CreatePythonConsole(); |
||||||
|
TestablePythonConsole.SendLine("test"); |
||||||
|
string text = MockConsoleTextEditor.TextPassedToWrite; |
||||||
|
|
||||||
|
Assert.IsNull(text); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Write_SendLineCalledButNoPromptWritten_WritesOutSavedSendLineText() |
||||||
|
{ |
||||||
|
base.CreatePythonConsole(); |
||||||
|
TestablePythonConsole.SendLine("test"); |
||||||
|
|
||||||
|
TestablePythonConsole.Write(">>> ", Style.Prompt); |
||||||
|
string text = MockConsoleTextEditor.Text; |
||||||
|
|
||||||
|
string expectedText = |
||||||
|
">>> test\r\n"; |
||||||
|
Assert.AreEqual(expectedText, text); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Write_CalledTwiceAfterSendLineCalledButNoPromptWritten_WritesOutSavedSendLineTextOnlyOnce() |
||||||
|
{ |
||||||
|
base.CreatePythonConsole(); |
||||||
|
TestablePythonConsole.SendLine("test"); |
||||||
|
|
||||||
|
TestablePythonConsole.Write(">>> ", Style.Prompt); |
||||||
|
TestablePythonConsole.Write(">>> ", Style.Prompt); |
||||||
|
|
||||||
|
string text = MockConsoleTextEditor.Text; |
||||||
|
|
||||||
|
string expectedText = |
||||||
|
">>> test\r\n" + |
||||||
|
">>> "; |
||||||
|
Assert.AreEqual(expectedText, text); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.PythonBinding; |
||||||
|
using PythonBinding.Tests.Utils; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Console |
||||||
|
{ |
||||||
|
public class PythonConsoleTestsBase |
||||||
|
{ |
||||||
|
public MockConsoleTextEditor MockConsoleTextEditor; |
||||||
|
public TestablePythonConsole TestablePythonConsole; |
||||||
|
|
||||||
|
public void CreatePythonConsole() |
||||||
|
{ |
||||||
|
TestablePythonConsole = new TestablePythonConsole(); |
||||||
|
MockConsoleTextEditor = TestablePythonConsole.MockConsoleTextEditor; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,328 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Threading; |
||||||
|
using System.Windows.Input; |
||||||
|
using ICSharpCode.AvalonEdit; |
||||||
|
using ICSharpCode.AvalonEdit.Editing; |
||||||
|
using ICSharpCode.PythonBinding; |
||||||
|
using NUnit.Framework; |
||||||
|
using PythonBinding.Tests.Utils; |
||||||
|
using PythonBinding.Tests.Utils.Tests; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Console |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class ThreadSafePythonConsoleTextEditorTests |
||||||
|
{ |
||||||
|
ThreadSafePythonConsoleTextEditor threadSafeConsoleTextEditor; |
||||||
|
TextEditor avalonEditTextEditor; |
||||||
|
MockControlDispatcher dispatcher; |
||||||
|
MockConsoleTextEditor fakeConsoleTextEditor; |
||||||
|
ConsoleTextEditorKeyEventArgs actualKeyEventArgs; |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
avalonEditTextEditor = new TextEditor(); |
||||||
|
dispatcher = new MockControlDispatcher(); |
||||||
|
dispatcher.CheckAccessReturnValue = true; |
||||||
|
|
||||||
|
fakeConsoleTextEditor = new MockConsoleTextEditor(); |
||||||
|
threadSafeConsoleTextEditor = new ThreadSafePythonConsoleTextEditor(fakeConsoleTextEditor, dispatcher); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void PreviewKeyDown_PreviewKeyDownFiresInWrappedNonThreadSafeConsoleTextEditor_CausesPreviewKeyDownEventToFireInThreadSafeConsoleTextEditor() |
||||||
|
{ |
||||||
|
threadSafeConsoleTextEditor.PreviewKeyDown += ThreadSafeConsoleTextEditorPreviewKeyDown; |
||||||
|
MockConsoleTextEditorKeyEventArgs expectedKeyEventArgs = new MockConsoleTextEditorKeyEventArgs(Key.OemPeriod); |
||||||
|
fakeConsoleTextEditor.RaisePreviewKeyDownEvent(expectedKeyEventArgs); |
||||||
|
|
||||||
|
Assert.AreEqual(expectedKeyEventArgs, actualKeyEventArgs); |
||||||
|
} |
||||||
|
|
||||||
|
void ThreadSafeConsoleTextEditorPreviewKeyDown(object source, ConsoleTextEditorKeyEventArgs e) |
||||||
|
{ |
||||||
|
actualKeyEventArgs = e; |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void PreviewKeyDown_PreviewKeyDownFiresInWrappedNonThreadSafeConsoleTextEditorAfterEventHandlerRemoved_DoesNotFirePreviewKeyDownEventinThreadSafeConsoleTextEditor() |
||||||
|
{ |
||||||
|
actualKeyEventArgs = null; |
||||||
|
threadSafeConsoleTextEditor.PreviewKeyDown += ThreadSafeConsoleTextEditorPreviewKeyDown; |
||||||
|
threadSafeConsoleTextEditor.PreviewKeyDown -= ThreadSafeConsoleTextEditorPreviewKeyDown; |
||||||
|
MockConsoleTextEditorKeyEventArgs expectedKeyEventArgs = new MockConsoleTextEditorKeyEventArgs(Key.OemPeriod); |
||||||
|
fakeConsoleTextEditor.RaisePreviewKeyDownEvent(expectedKeyEventArgs); |
||||||
|
|
||||||
|
Assert.IsNull(actualKeyEventArgs); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Dispose_WrappedNonThreadSafeConsoleTextEditor_DisposesWrappedNonThreadSafeConsoleTextEditor() |
||||||
|
{ |
||||||
|
threadSafeConsoleTextEditor.Dispose(); |
||||||
|
bool disposed = fakeConsoleTextEditor.IsDisposed; |
||||||
|
Assert.IsTrue(disposed); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Column_WrappedConsoleTextEditorColumnIsThree_ReturnsThree() |
||||||
|
{ |
||||||
|
fakeConsoleTextEditor.Column = 3; |
||||||
|
int column = threadSafeConsoleTextEditor.Column; |
||||||
|
int expectedColumn = 3; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedColumn, column); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Column_SettingColumnToFour_SetsWrappedConsoleTextEditorColumnToFour() |
||||||
|
{ |
||||||
|
threadSafeConsoleTextEditor.Column = 4; |
||||||
|
int column = fakeConsoleTextEditor.Column; |
||||||
|
int expectedColumn = 4; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedColumn, column); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SelectionStart_WrappedConsoleTextEditorSelectionStartIsThree_ReturnsThree() |
||||||
|
{ |
||||||
|
fakeConsoleTextEditor.SelectionStart = 3; |
||||||
|
int index = threadSafeConsoleTextEditor.SelectionStart; |
||||||
|
int expectedIndex = 3; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedIndex, index); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SelectionLength_WrappedConsoleTextEditorSelectionLengthIsThree_ReturnsThree() |
||||||
|
{ |
||||||
|
fakeConsoleTextEditor.SelectionLength = 3; |
||||||
|
int length = threadSafeConsoleTextEditor.SelectionLength; |
||||||
|
int expectedLength = 3; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedLength, length); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Line_WrappedConsoleTextEditorLineIsTwo_ReturnsTwo() |
||||||
|
{ |
||||||
|
fakeConsoleTextEditor.Line = 2; |
||||||
|
int line = threadSafeConsoleTextEditor.Line; |
||||||
|
int expectedLine = 2; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedLine, line); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Line_SettingLineToOne_SetsWrappedConsoleTextEditorLineToOne() |
||||||
|
{ |
||||||
|
threadSafeConsoleTextEditor.Line = 1; |
||||||
|
int line = fakeConsoleTextEditor.Line; |
||||||
|
int expectedLine = 1; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedLine, line); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void TotalLines_WrappedConsoleTextEditorTotalLinesIsOne_ReturnsOne() |
||||||
|
{ |
||||||
|
fakeConsoleTextEditor.TotalLines = 1; |
||||||
|
int total = threadSafeConsoleTextEditor.TotalLines; |
||||||
|
int expectedTotal = 1; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedTotal, total); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void IsCompletionWindowDisplayed_WrappedConsoleTextEditorIsCompletionWindowDisplayedIsTrue_ReturnsTrue() |
||||||
|
{ |
||||||
|
fakeConsoleTextEditor.IsCompletionWindowDisplayed = true; |
||||||
|
bool result = threadSafeConsoleTextEditor.IsCompletionWindowDisplayed; |
||||||
|
|
||||||
|
Assert.IsTrue(result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void MakeCurrentContentReadOnly_WrappedConsoleTextEditor_CallsWrappedConsoleTextEditorMethod() |
||||||
|
{ |
||||||
|
threadSafeConsoleTextEditor.MakeCurrentContentReadOnly(); |
||||||
|
Assert.IsTrue(fakeConsoleTextEditor.IsMakeCurrentContentReadOnlyCalled); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ShowCompletionWindow_WrappedConsoleTextEditor_CallsWrappedConsoleTextEditorMethod() |
||||||
|
{ |
||||||
|
PythonConsoleCompletionDataProvider expectedProvider = new PythonConsoleCompletionDataProvider(null); |
||||||
|
threadSafeConsoleTextEditor.ShowCompletionWindow(expectedProvider); |
||||||
|
|
||||||
|
PythonConsoleCompletionDataProvider provider = fakeConsoleTextEditor.CompletionProviderPassedToShowCompletionWindow; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedProvider, provider); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Write_WrappedConsoleTextEditor_WritesTextToWrappedConsoleTextEditor() |
||||||
|
{ |
||||||
|
threadSafeConsoleTextEditor.Write("abc"); |
||||||
|
string text = fakeConsoleTextEditor.TextPassedToWrite; |
||||||
|
string expectedText = "abc"; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedText, text); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetLine_GetFirstLine_GetsFirstLineFromWrappedConsoleTextEditor() |
||||||
|
{ |
||||||
|
fakeConsoleTextEditor.LineBuilder.Append("abc\r\n"); |
||||||
|
string line = threadSafeConsoleTextEditor.GetLine(0); |
||||||
|
string expectedText = "abc\r\n"; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedText, line); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Replace_WrappedConsoleTextEditor_ReplacementTextPassedToWrappedConsoleTextEditor() |
||||||
|
{ |
||||||
|
fakeConsoleTextEditor.LineBuilder.Append("abc\r\n"); |
||||||
|
threadSafeConsoleTextEditor.Replace(1, 2, "ddd"); |
||||||
|
|
||||||
|
string replacementText = fakeConsoleTextEditor.TextPassedToReplace; |
||||||
|
string expectedText = "ddd"; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedText, replacementText); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Replace_WrappedConsoleTextEditor_ReplacementIndexPassedToWrappedConsoleTextEditor() |
||||||
|
{ |
||||||
|
fakeConsoleTextEditor.LineBuilder.Append("abc\r\n"); |
||||||
|
int expectedIndex = 1; |
||||||
|
threadSafeConsoleTextEditor.Replace(expectedIndex, 2, "ddd"); |
||||||
|
|
||||||
|
int index = fakeConsoleTextEditor.IndexPassedToReplace; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedIndex, index); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Replace_WrappedConsoleTextEditor_ReplacementLengthPassedToWrappedConsoleTextEditor() |
||||||
|
{ |
||||||
|
fakeConsoleTextEditor.LineBuilder.Append("abc\r\n"); |
||||||
|
int expectedLength = 2; |
||||||
|
threadSafeConsoleTextEditor.Replace(1, expectedLength, "ddd"); |
||||||
|
|
||||||
|
int length = fakeConsoleTextEditor.LengthPassedToReplace; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedLength, length); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Write_DispatcherCheckAccessReturnsFalse_MethodIsInvoked() |
||||||
|
{ |
||||||
|
dispatcher.CheckAccessReturnValue = false; |
||||||
|
dispatcher.MethodInvoked = null; |
||||||
|
|
||||||
|
threadSafeConsoleTextEditor.Write("abc"); |
||||||
|
Assert.IsNotNull(dispatcher.MethodInvoked); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Write_DispatcherCheckAccessReturnsFalse_MethodIsInvokedWithTextAsArg() |
||||||
|
{ |
||||||
|
dispatcher.CheckAccessReturnValue = false; |
||||||
|
dispatcher.MethodInvokedArgs = null; |
||||||
|
|
||||||
|
threadSafeConsoleTextEditor.Write("abc"); |
||||||
|
object[] expectedArgs = new object[] { "abc" }; |
||||||
|
Assert.AreEqual(expectedArgs, dispatcher.MethodInvokedArgs); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetLine_DispatcherCheckAccessReturnsFalse_MethodIsInvoked() |
||||||
|
{ |
||||||
|
dispatcher.CheckAccessReturnValue = false; |
||||||
|
dispatcher.MethodInvoked = null; |
||||||
|
|
||||||
|
threadSafeConsoleTextEditor.GetLine(0); |
||||||
|
Assert.IsNotNull(dispatcher.MethodInvoked); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetLine_DispatcherCheckAccessReturnsFalse_MethodIsInvokedWithLineNumberAsArg() |
||||||
|
{ |
||||||
|
dispatcher.CheckAccessReturnValue = false; |
||||||
|
dispatcher.MethodInvokedArgs = null; |
||||||
|
|
||||||
|
threadSafeConsoleTextEditor.GetLine(0); |
||||||
|
object[] expectedArgs = new object[] { 0 }; |
||||||
|
Assert.AreEqual(expectedArgs, dispatcher.MethodInvokedArgs); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Replace_DispatcherCheckAccessReturnsFalse_MethodIsInvoked() |
||||||
|
{ |
||||||
|
dispatcher.CheckAccessReturnValue = false; |
||||||
|
dispatcher.MethodInvoked = null; |
||||||
|
fakeConsoleTextEditor.Text = "abcd"; |
||||||
|
|
||||||
|
threadSafeConsoleTextEditor.Replace(0, 2, "12"); |
||||||
|
Assert.IsNotNull(dispatcher.MethodInvoked); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Replace_DispatcherCheckAccessReturnsFalse_MethodIsInvokedWithThreeArgs() |
||||||
|
{ |
||||||
|
dispatcher.CheckAccessReturnValue = false; |
||||||
|
dispatcher.MethodInvokedArgs = null; |
||||||
|
fakeConsoleTextEditor.Text = "abcd"; |
||||||
|
|
||||||
|
threadSafeConsoleTextEditor.Replace(0, 2, "12"); |
||||||
|
object[] expectedArgs = new object[] { 0, 2, "12" }; |
||||||
|
Assert.AreEqual(expectedArgs, dispatcher.MethodInvokedArgs); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void MakeCurrentContentReadOnly_DispatcherCheckAccessReturnsFalse_MethodIsInvoked() |
||||||
|
{ |
||||||
|
dispatcher.CheckAccessReturnValue = false; |
||||||
|
dispatcher.MethodInvoked = null; |
||||||
|
|
||||||
|
threadSafeConsoleTextEditor.MakeCurrentContentReadOnly(); |
||||||
|
Assert.IsNotNull(dispatcher.MethodInvoked); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ShowCompletionWindow_DispatcherCheckAccessReturnsFalse_MethodIsInvoked() |
||||||
|
{ |
||||||
|
dispatcher.CheckAccessReturnValue = false; |
||||||
|
dispatcher.MethodInvoked = null; |
||||||
|
|
||||||
|
PythonConsoleCompletionDataProvider provider = new PythonConsoleCompletionDataProvider(null); |
||||||
|
threadSafeConsoleTextEditor.ShowCompletionWindow(provider); |
||||||
|
Assert.IsNotNull(dispatcher.MethodInvoked); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ShowCompletionWindow_DispatcherCheckAccessReturnsFalse_MethodIsInvokedWithDataProviderPassedToMethod() |
||||||
|
{ |
||||||
|
dispatcher.CheckAccessReturnValue = false; |
||||||
|
dispatcher.MethodInvoked = null; |
||||||
|
|
||||||
|
PythonConsoleCompletionDataProvider provider = new PythonConsoleCompletionDataProvider(null); |
||||||
|
threadSafeConsoleTextEditor.ShowCompletionWindow(provider); |
||||||
|
object[] expectedArgs = new object[] { provider }; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedArgs, dispatcher.MethodInvokedArgs); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,93 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.PythonBinding; |
||||||
|
using NUnit.Framework; |
||||||
|
using PythonBinding.Tests.Utils; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Gui |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class SendLineToPythonConsoleCommandTests |
||||||
|
{ |
||||||
|
SendLineToPythonConsoleCommand sendLineToConsoleCommand; |
||||||
|
MockConsoleTextEditor fakeConsoleTextEditor; |
||||||
|
MockTextEditor fakeTextEditor; |
||||||
|
MockWorkbench workbench; |
||||||
|
MockPythonConsole fakeConsole; |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Run_SingleLineInTextEditor_FirstLineSentToPythonConsole() |
||||||
|
{ |
||||||
|
CreateSendLineToConsoleCommand(); |
||||||
|
AddSingleLineToTextEditor("print 'hello'"); |
||||||
|
sendLineToConsoleCommand.Run(); |
||||||
|
|
||||||
|
string text = fakeConsole.TextPassedToSendLine; |
||||||
|
|
||||||
|
string expectedText = "print 'hello'"; |
||||||
|
Assert.AreEqual(expectedText, text); |
||||||
|
} |
||||||
|
|
||||||
|
void CreateSendLineToConsoleCommand() |
||||||
|
{ |
||||||
|
workbench = MockWorkbench.CreateWorkbenchWithOneViewContent("test.py"); |
||||||
|
fakeConsoleTextEditor = workbench.MockPythonConsolePad.MockConsoleTextEditor; |
||||||
|
fakeConsole = workbench.MockPythonConsolePad.MockPythonConsole; |
||||||
|
fakeTextEditor = workbench.ActiveMockEditableViewContent.MockTextEditor; |
||||||
|
sendLineToConsoleCommand = new SendLineToPythonConsoleCommand(workbench); |
||||||
|
} |
||||||
|
|
||||||
|
void AddSingleLineToTextEditor(string line) |
||||||
|
{ |
||||||
|
fakeTextEditor.Document.Text = line; |
||||||
|
fakeTextEditor.Caret.Line = 1; |
||||||
|
|
||||||
|
SetTextToReturnFromTextEditorGetLine(line); |
||||||
|
} |
||||||
|
|
||||||
|
void SetTextToReturnFromTextEditorGetLine(string line) |
||||||
|
{ |
||||||
|
FakeDocumentLine documentLine = new FakeDocumentLine(); |
||||||
|
documentLine.Text = line; |
||||||
|
fakeTextEditor.FakeDocument.DocumentLineToReturnFromGetLine = documentLine; |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Run_TwoLinesInTextEditorCursorOnFirstLine_FirstLineSentToPythonConsole() |
||||||
|
{ |
||||||
|
CreateSendLineToConsoleCommand(); |
||||||
|
|
||||||
|
fakeTextEditor.Document.Text = |
||||||
|
"print 'hello'\r\n" + |
||||||
|
"print 'world'\r\n"; |
||||||
|
|
||||||
|
fakeTextEditor.Caret.Line = 1; |
||||||
|
|
||||||
|
SetTextToReturnFromTextEditorGetLine("print 'hello'"); |
||||||
|
|
||||||
|
sendLineToConsoleCommand.Run(); |
||||||
|
string text = fakeConsole.TextPassedToSendLine; |
||||||
|
|
||||||
|
string expectedText = "print 'hello'"; |
||||||
|
Assert.AreEqual(expectedText, text); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Run_SingleLineInTextEditor_PythonConsolePadBroughtToFront() |
||||||
|
{ |
||||||
|
CreateSendLineToConsoleCommand(); |
||||||
|
AddSingleLineToTextEditor("print 'hello'"); |
||||||
|
|
||||||
|
sendLineToConsoleCommand.Run(); |
||||||
|
|
||||||
|
bool broughtToFront = workbench.MockPythonConsolePad.BringToFrontCalled; |
||||||
|
Assert.IsTrue(broughtToFront); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.SharpDevelop.Editor; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Utils |
||||||
|
{ |
||||||
|
public class FakeCaret : ITextEditorCaret |
||||||
|
{ |
||||||
|
public event EventHandler PositionChanged; |
||||||
|
|
||||||
|
protected virtual void OnPositionChanged(EventArgs e) |
||||||
|
{ |
||||||
|
if (PositionChanged != null) { |
||||||
|
PositionChanged(this, e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public int Offset { |
||||||
|
get { |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
set { |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public int Line { get; set; } |
||||||
|
|
||||||
|
public int Column { |
||||||
|
get { |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
set { |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ICSharpCode.NRefactory.Location Position { |
||||||
|
get { |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
set { |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,139 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
using System.Text; |
||||||
|
using ICSharpCode.NRefactory; |
||||||
|
using ICSharpCode.SharpDevelop; |
||||||
|
using ICSharpCode.SharpDevelop.Editor; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Utils |
||||||
|
{ |
||||||
|
public class FakeDocument : IDocument |
||||||
|
{ |
||||||
|
#pragma warning disable 0067
|
||||||
|
public event EventHandler<TextChangeEventArgs> Changing; |
||||||
|
public event EventHandler<TextChangeEventArgs> Changed; |
||||||
|
public event EventHandler TextChanged; |
||||||
|
#pragma warning restore 0067
|
||||||
|
|
||||||
|
public FakeDocumentLine DocumentLineToReturnFromGetLine; |
||||||
|
public int LineNumberPassedToGetLine; |
||||||
|
|
||||||
|
public string Text { get; set; } |
||||||
|
|
||||||
|
public int TotalNumberOfLines { |
||||||
|
get { |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public ITextBufferVersion Version { |
||||||
|
get { |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public int TextLength { |
||||||
|
get { |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public IDocumentLine GetLine(int lineNumber) |
||||||
|
{ |
||||||
|
LineNumberPassedToGetLine = lineNumber; |
||||||
|
return DocumentLineToReturnFromGetLine; |
||||||
|
} |
||||||
|
|
||||||
|
public IDocumentLine GetLineForOffset(int offset) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public int PositionToOffset(int line, int column) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public Location OffsetToPosition(int offset) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public void Insert(int offset, string text) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public void Remove(int offset, int length) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public void Replace(int offset, int length, string newText) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public void StartUndoableAction() |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public void EndUndoableAction() |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public IDisposable OpenUndoGroup() |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public ITextAnchor CreateAnchor(int offset) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public ITextBuffer CreateSnapshot() |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public ITextBuffer CreateSnapshot(int offset, int length) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public TextReader CreateReader() |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public TextReader CreateReader(int offset, int length) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public char GetCharAt(int offset) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public string GetText(int offset, int length) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public object GetService(Type serviceType) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.SharpDevelop.Editor; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Utils |
||||||
|
{ |
||||||
|
public class FakeDocumentLine : IDocumentLine |
||||||
|
{ |
||||||
|
public int Offset { get; set; } |
||||||
|
public int Length { get; set; } |
||||||
|
public int EndOffset { get; set; } |
||||||
|
public int TotalLength { get; set; } |
||||||
|
public int DelimiterLength { get; set; } |
||||||
|
public int LineNumber { get; set; } |
||||||
|
public string Text { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using ICSharpCode.PythonBinding; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Utils |
||||||
|
{ |
||||||
|
public class FakeLock : ILock |
||||||
|
{ |
||||||
|
public List<string> Lines; |
||||||
|
public bool IsDisposed; |
||||||
|
public int UnreadLineCountWhenLockCreated = -1; |
||||||
|
public int UnreadLineCountWhenLockDisposed = -1; |
||||||
|
|
||||||
|
public FakeLock(List<string> lines) |
||||||
|
{ |
||||||
|
this.Lines = lines; |
||||||
|
UnreadLineCountWhenLockCreated = lines.Count; |
||||||
|
} |
||||||
|
|
||||||
|
public void Dispose() |
||||||
|
{ |
||||||
|
UnreadLineCountWhenLockDisposed = Lines.Count; |
||||||
|
IsDisposed = true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,40 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Windows.Forms; |
|
||||||
using ICSharpCode.PythonBinding; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
|
|
||||||
namespace PythonBinding.Tests.Utils |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Dummy IPadDescriptor class.
|
|
||||||
/// </summary>
|
|
||||||
public class MockPadDescriptor : IPadDescriptor |
|
||||||
{ |
|
||||||
bool bringPadToFrontCalled; |
|
||||||
|
|
||||||
public MockPadDescriptor() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public void BringPadToFront() |
|
||||||
{ |
|
||||||
bringPadToFrontCalled = true; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets whether the BringPadToFront was called.
|
|
||||||
/// </summary>
|
|
||||||
public bool BringPadToFrontCalled { |
|
||||||
get { |
|
||||||
return bringPadToFrontCalled; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,22 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.PythonBinding; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Utils |
||||||
|
{ |
||||||
|
public class MockPythonConsole : IPythonConsole |
||||||
|
{ |
||||||
|
public string TextPassedToSendLine; |
||||||
|
|
||||||
|
public void SendLine(string text) |
||||||
|
{ |
||||||
|
TextPassedToSendLine = text; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.PythonBinding; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Utils |
||||||
|
{ |
||||||
|
public class MockPythonConsolePad : IPythonConsolePad |
||||||
|
{ |
||||||
|
public MockConsoleTextEditor MockConsoleTextEditor = new MockConsoleTextEditor(); |
||||||
|
public MockPythonConsole MockPythonConsole = new MockPythonConsole(); |
||||||
|
|
||||||
|
public bool BringToFrontCalled; |
||||||
|
|
||||||
|
public void BringToFront() |
||||||
|
{ |
||||||
|
BringToFrontCalled = true; |
||||||
|
} |
||||||
|
|
||||||
|
public IConsoleTextEditor ConsoleTextEditor { |
||||||
|
get { return MockConsoleTextEditor; } |
||||||
|
} |
||||||
|
|
||||||
|
public IPythonConsole PythonConsole { |
||||||
|
get { return MockPythonConsole; } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,129 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Drawing; |
|
||||||
using System.Windows.Forms; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
|
|
||||||
namespace PythonBinding.Tests.Utils |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Dummy IWorkbenchWindow class.
|
|
||||||
/// </summary>
|
|
||||||
public class MockWorkbenchWindow : IWorkbenchWindow |
|
||||||
{ |
|
||||||
IViewContent viewContent; |
|
||||||
|
|
||||||
public MockWorkbenchWindow() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public event EventHandler WindowSelected; |
|
||||||
public event EventHandler WindowDeselected; |
|
||||||
public event EventHandler TitleChanged; |
|
||||||
public event EventHandler CloseEvent; |
|
||||||
public event EventHandler ActiveViewContentChanged; |
|
||||||
|
|
||||||
public string Title { |
|
||||||
get { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
set { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsDisposed { |
|
||||||
get { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public IViewContent ActiveViewContent { |
|
||||||
get { |
|
||||||
return viewContent; |
|
||||||
} |
|
||||||
set { |
|
||||||
viewContent = value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public bool CloseWindow(bool force) |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public void SelectWindow() |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public void RedrawContent() |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public void SwitchView(int viewNumber) |
|
||||||
{ |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
public void OnWindowDeselected(EventArgs e) |
|
||||||
{ |
|
||||||
if (WindowDeselected != null) { |
|
||||||
WindowDeselected(this, e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void OnWindowSelected(EventArgs e) |
|
||||||
{ |
|
||||||
if (WindowSelected != null) { |
|
||||||
WindowSelected(this, e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public System.Windows.Media.ImageSource Icon { |
|
||||||
get { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
set { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public IList<IViewContent> ViewContents { |
|
||||||
get { |
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected virtual void OnTitleChanged(EventArgs e) |
|
||||||
{ |
|
||||||
if (TitleChanged != null) { |
|
||||||
TitleChanged(this, e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected virtual void OnCloseEvent(EventArgs e) |
|
||||||
{ |
|
||||||
if (CloseEvent != null) { |
|
||||||
CloseEvent(this, e); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected virtual void OnActiveViewContentChanged(EventArgs e) |
|
||||||
{ |
|
||||||
if (ActiveViewContentChanged != null) { |
|
||||||
ActiveViewContentChanged(this, e); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,56 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using ICSharpCode.PythonBinding; |
||||||
|
using IronPython.Hosting; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Utils |
||||||
|
{ |
||||||
|
public class TestablePythonConsole : PythonConsole |
||||||
|
{ |
||||||
|
public MockConsoleTextEditor MockConsoleTextEditor; |
||||||
|
public FakeLock LockCreated; |
||||||
|
public bool IsLineReceivedEventFired; |
||||||
|
public int UnreadLineCountWhenLineReceivedEventFired = -1; |
||||||
|
|
||||||
|
public TestablePythonConsole() |
||||||
|
: this(new MockConsoleTextEditor(), new PythonCommandLine()) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
TestablePythonConsole(IConsoleTextEditor consoleTextEditor, PythonCommandLine commandLine) |
||||||
|
: base(consoleTextEditor) |
||||||
|
{ |
||||||
|
CommandLine = commandLine; |
||||||
|
MockConsoleTextEditor = (MockConsoleTextEditor)consoleTextEditor; |
||||||
|
} |
||||||
|
|
||||||
|
public List<string> GetUnreadLinesList() |
||||||
|
{ |
||||||
|
return base.unreadLines; |
||||||
|
} |
||||||
|
|
||||||
|
public string[] GetUnreadLines() |
||||||
|
{ |
||||||
|
return base.unreadLines.ToArray(); |
||||||
|
} |
||||||
|
|
||||||
|
protected override ILock CreateLock(List<string> lines) |
||||||
|
{ |
||||||
|
LockCreated = new FakeLock(lines); |
||||||
|
return LockCreated; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void FireLineReceivedEvent() |
||||||
|
{ |
||||||
|
IsLineReceivedEventFired = true; |
||||||
|
UnreadLineCountWhenLineReceivedEventFired = LockCreated.Lines.Count; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue