diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/SendLineToPythonConsoleCommand.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/SendLineToPythonConsoleCommand.cs index 84abc0c970..196186b67d 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/SendLineToPythonConsoleCommand.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/SendLineToPythonConsoleCommand.cs @@ -4,67 +4,14 @@ using System; using ICSharpCode.Core; using ICSharpCode.Scripting; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.PythonBinding { - public class SendLineToPythonConsoleCommand : AbstractCommand - { - IScriptingWorkbench workbench; - IScriptingConsolePad consolePad; - ScriptingTextEditorViewContent textEditorView; - ITextEditor activeTextEditor; - IScriptingConsole pythonConsole; - string lineFromActiveTextEditor; - + public class SendLineToPythonConsoleCommand : SendLineToScriptingConsoleCommand + { public SendLineToPythonConsoleCommand() - : this(new PythonWorkbench()) + : base(new PythonWorkbench()) { } - - public SendLineToPythonConsoleCommand(IScriptingWorkbench workbench) - { - this.workbench = workbench; - - textEditorView = new ScriptingTextEditorViewContent(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.GetScriptingConsolePad(); - } - - void ShowPythonConsolePad() - { - consolePad.BringToFront(); - } - - void AppendLineToPythonConsole() - { - GetPythonConsole(); - pythonConsole.SendLine(lineFromActiveTextEditor); - } - - void GetPythonConsole() - { - pythonConsole = consolePad.ScriptingConsole; - } } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj index aae42c5325..c7b893611e 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj @@ -316,7 +316,6 @@ - diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/SendLineToRubyConsoleCommand.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/SendLineToRubyConsoleCommand.cs index a036cacc79..f0e0b69f2c 100644 --- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/SendLineToRubyConsoleCommand.cs +++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/SendLineToRubyConsoleCommand.cs @@ -2,69 +2,15 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.Core; using ICSharpCode.Scripting; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.RubyBinding { - public class SendLineToRubyConsoleCommand : AbstractCommand - { - IScriptingWorkbench workbench; - IScriptingConsolePad consolePad; - ScriptingTextEditorViewContent textEditorView; - ITextEditor activeTextEditor; - IScriptingConsole RubyConsole; - string lineFromActiveTextEditor; - + public class SendLineToRubyConsoleCommand : SendLineToScriptingConsoleCommand + { public SendLineToRubyConsoleCommand() - : this(new RubyWorkbench()) + : base(new RubyWorkbench()) { } - - public SendLineToRubyConsoleCommand(IScriptingWorkbench workbench) - { - this.workbench = workbench; - - textEditorView = new ScriptingTextEditorViewContent(workbench); - activeTextEditor = textEditorView.TextEditor; - } - - public override void Run() - { - GetLineFromActiveTextEditor(); - GetRubyConsolePad(); - ShowRubyConsolePad(); - AppendLineToRubyConsole(); - } - - void GetLineFromActiveTextEditor() - { - int lineNumber = activeTextEditor.Caret.Line; - IDocumentLine documentLine = activeTextEditor.Document.GetLine(lineNumber); - lineFromActiveTextEditor = documentLine.Text; - } - - void GetRubyConsolePad() - { - consolePad = workbench.GetScriptingConsolePad(); - } - - void ShowRubyConsolePad() - { - consolePad.BringToFront(); - } - - void AppendLineToRubyConsole() - { - GetRubyConsole(); - RubyConsole.SendLine(lineFromActiveTextEditor); - } - - void GetRubyConsole() - { - RubyConsole = consolePad.ScriptingConsole; - } } } diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/SendLineToRubyConsoleCommandTests.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/SendLineToRubyConsoleCommandTests.cs deleted file mode 100644 index b11c883665..0000000000 --- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Gui/SendLineToRubyConsoleCommandTests.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.RubyBinding; -using ICSharpCode.Scripting.Tests.Utils; -using NUnit.Framework; -using RubyBinding.Tests.Utils; - -namespace RubyBinding.Tests.Gui -{ - [TestFixture] - public class SendLineToRubyConsoleCommandTests - { - SendLineToRubyConsoleCommand sendLineToConsoleCommand; - MockConsoleTextEditor fakeConsoleTextEditor; - MockTextEditor fakeTextEditor; - MockWorkbench workbench; - MockScriptingConsole fakeConsole; - - [Test] - public void Run_SingleLineInTextEditor_FirstLineSentToRubyConsole() - { - CreateSendLineToConsoleCommand(); - AddSingleLineToTextEditor("print 'hello'"); - sendLineToConsoleCommand.Run(); - - string text = fakeConsole.TextPassedToSendLine; - - string expectedText = "print 'hello'"; - Assert.AreEqual(expectedText, text); - } - - void CreateSendLineToConsoleCommand() - { - workbench = MockWorkbench.CreateWorkbenchWithOneViewContent("test.rb"); - fakeConsoleTextEditor = workbench.MockScriptingConsolePad.MockConsoleTextEditor; - fakeConsole = workbench.MockScriptingConsolePad.MockScriptingConsole; - fakeTextEditor = workbench.ActiveMockEditableViewContent.MockTextEditor; - sendLineToConsoleCommand = new SendLineToRubyConsoleCommand(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_FirstLineSentToRubyConsole() - { - 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_RubyConsolePadBroughtToFront() - { - CreateSendLineToConsoleCommand(); - AddSingleLineToTextEditor("print 'hello'"); - - sendLineToConsoleCommand.Run(); - - bool broughtToFront = workbench.MockScriptingConsolePad.BringToFrontCalled; - Assert.IsTrue(broughtToFront); - } - } -} diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj index e19dcc35a1..21a174f834 100644 --- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/RubyBinding.Tests.csproj @@ -270,7 +270,6 @@ - diff --git a/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj b/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj index 53aa562d09..161ca05d47 100644 --- a/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj +++ b/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj @@ -92,6 +92,7 @@ + diff --git a/src/AddIns/BackendBindings/Scripting/Project/Src/SendLineToScriptingConsoleCommand.cs b/src/AddIns/BackendBindings/Scripting/Project/Src/SendLineToScriptingConsoleCommand.cs new file mode 100644 index 0000000000..9be3a56c3b --- /dev/null +++ b/src/AddIns/BackendBindings/Scripting/Project/Src/SendLineToScriptingConsoleCommand.cs @@ -0,0 +1,70 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.Scripting; +using ICSharpCode.SharpDevelop.Editor; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.Scripting +{ + public class SendLineToScriptingConsoleCommand : AbstractCommand + { + IScriptingWorkbench workbench; + + IScriptingConsolePad consolePad; + ScriptingTextEditorViewContent textEditorView; + ITextEditor activeTextEditor; + IScriptingConsole pythonConsole; + string lineFromActiveTextEditor; + + public SendLineToScriptingConsoleCommand(IScriptingWorkbench workbench) + { + this.workbench = workbench; + + textEditorView = new ScriptingTextEditorViewContent(workbench); + activeTextEditor = textEditorView.TextEditor; + } + + public override void Run() + { + GetLineFromActiveTextEditor(); + GetScriptingConsolePad(); + ShowScriptingConsolePad(); + AppendLineToScriptingConsole(); + } + + void GetLineFromActiveTextEditor() + { + int lineNumber = activeTextEditor.Caret.Line; + IDocumentLine documentLine = activeTextEditor.Document.GetLine(lineNumber); + lineFromActiveTextEditor = documentLine.Text; + } + + void GetScriptingConsolePad() + { + consolePad = workbench.GetScriptingConsolePad(); + } + + void ShowScriptingConsolePad() + { + consolePad.BringToFront(); + } + + void AppendLineToScriptingConsole() + { + GetScriptingConsole(); + pythonConsole.SendLine(lineFromActiveTextEditor); + } + + void GetScriptingConsole() + { + pythonConsole = consolePad.ScriptingConsole; + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/SendLineToPythonConsoleCommandTests.cs b/src/AddIns/BackendBindings/Scripting/Test/Console/SendLineToScriptingConsoleCommandTests.cs similarity index 89% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/SendLineToPythonConsoleCommandTests.cs rename to src/AddIns/BackendBindings/Scripting/Test/Console/SendLineToScriptingConsoleCommandTests.cs index 5c0cf3f08c..8cdbcad1fd 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/SendLineToPythonConsoleCommandTests.cs +++ b/src/AddIns/BackendBindings/Scripting/Test/Console/SendLineToScriptingConsoleCommandTests.cs @@ -2,17 +2,16 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.PythonBinding; +using ICSharpCode.Scripting; using ICSharpCode.Scripting.Tests.Utils; using NUnit.Framework; -using PythonBinding.Tests.Utils; -namespace PythonBinding.Tests.Gui +namespace ICSharpCode.Scripting.Tests.Console { [TestFixture] - public class SendLineToPythonConsoleCommandTests + public class SendLineToScriptingConsoleCommandTests { - SendLineToPythonConsoleCommand sendLineToConsoleCommand; + SendLineToScriptingConsoleCommand sendLineToConsoleCommand; MockConsoleTextEditor fakeConsoleTextEditor; MockTextEditor fakeTextEditor; MockWorkbench workbench; @@ -37,7 +36,7 @@ namespace PythonBinding.Tests.Gui fakeConsoleTextEditor = workbench.MockScriptingConsolePad.MockConsoleTextEditor; fakeConsole = workbench.MockScriptingConsolePad.MockScriptingConsole; fakeTextEditor = workbench.ActiveMockEditableViewContent.MockTextEditor; - sendLineToConsoleCommand = new SendLineToPythonConsoleCommand(workbench); + sendLineToConsoleCommand = new SendLineToScriptingConsoleCommand(workbench); } void AddSingleLineToTextEditor(string line) diff --git a/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj b/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj index e685022f5c..8e5773a58d 100644 --- a/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj +++ b/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj @@ -88,6 +88,7 @@ +