12 changed files with 177 additions and 23 deletions
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// 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.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public class PackageInitializationScriptsConsole |
||||
{ |
||||
IPackageManagementConsoleHost consoleHost; |
||||
|
||||
public PackageInitializationScriptsConsole( |
||||
IPackageManagementConsoleHost consoleHost) |
||||
{ |
||||
this.consoleHost = consoleHost; |
||||
} |
||||
|
||||
public void ExecuteCommand(string command) |
||||
{ |
||||
CreateConsolePadIfConsoleHostNotRunning(); |
||||
consoleHost.ScriptingConsole.SendLine(command); |
||||
} |
||||
|
||||
void CreateConsolePadIfConsoleHostNotRunning() |
||||
{ |
||||
if (!consoleHost.IsRunning) { |
||||
CreateConsolePad(); |
||||
} |
||||
} |
||||
|
||||
protected virtual void CreateConsolePad() |
||||
{ |
||||
PadDescriptor pad = WorkbenchSingleton.Workbench.GetPad(typeof(PackageManagementConsolePad)); |
||||
PackageManagementConsolePad consolePad = pad.PadContent.Control as PackageManagementConsolePad; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
// 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.PackageManagement.Scripting; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
|
||||
namespace PackageManagement.Tests.Helpers |
||||
{ |
||||
public class TestablePackageInitializationScriptsConsole : PackageInitializationScriptsConsole |
||||
{ |
||||
public FakePackageManagementConsoleHost FakeConsoleHost; |
||||
public FakeScriptingConsole FakeScriptingConsole; |
||||
|
||||
public TestablePackageInitializationScriptsConsole() |
||||
: this(new FakePackageManagementConsoleHost()) |
||||
{ |
||||
} |
||||
|
||||
public TestablePackageInitializationScriptsConsole(FakePackageManagementConsoleHost consoleHost) |
||||
: base(consoleHost) |
||||
{ |
||||
FakeConsoleHost = consoleHost; |
||||
FakeScriptingConsole = new FakeScriptingConsole(); |
||||
FakeConsoleHost.ScriptingConsole = FakeScriptingConsole; |
||||
} |
||||
|
||||
public bool IsCreateConsolePadCalled; |
||||
|
||||
protected override void CreateConsolePad() |
||||
{ |
||||
IsCreateConsolePadCalled = true; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
// 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.PackageManagement.Scripting; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using NUnit.Framework; |
||||
using PackageManagement.Tests.Helpers; |
||||
|
||||
namespace PackageManagement.Tests.Scripting |
||||
{ |
||||
[TestFixture] |
||||
public class PackageInitializationScriptsConsoleTests |
||||
{ |
||||
TestablePackageInitializationScriptsConsole console; |
||||
FakePackageManagementConsoleHost fakeConsoleHost; |
||||
FakeScriptingConsole fakeScriptingConsole; |
||||
|
||||
void CreateConsole() |
||||
{ |
||||
console = new TestablePackageInitializationScriptsConsole(); |
||||
fakeConsoleHost = console.FakeConsoleHost; |
||||
fakeScriptingConsole = console.FakeScriptingConsole; |
||||
} |
||||
|
||||
[Test] |
||||
public void ExecuteCommand_ConsoleHostAlreadyRunning_CommandSentToScriptingConsole() |
||||
{ |
||||
CreateConsole(); |
||||
fakeConsoleHost.IsRunning = true; |
||||
console.ExecuteCommand("Test"); |
||||
|
||||
string command = fakeScriptingConsole.TextPassedToSendLine; |
||||
|
||||
Assert.AreEqual("Test", command); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExecuteCommand_ConsoleHostAlreadyRunning_ConsolePadIsNotCreated() |
||||
{ |
||||
CreateConsole(); |
||||
fakeConsoleHost.IsRunning = true; |
||||
console.ExecuteCommand("Test"); |
||||
|
||||
bool created = console.IsCreateConsolePadCalled; |
||||
|
||||
Assert.IsFalse(created); |
||||
} |
||||
|
||||
[Test] |
||||
public void ExecuteCommand_ConsoleHostNotRunning_ConsolePadIsCreated() |
||||
{ |
||||
CreateConsole(); |
||||
fakeConsoleHost.IsRunning = false; |
||||
console.ExecuteCommand("Test"); |
||||
|
||||
bool created = console.IsCreateConsolePadCalled; |
||||
|
||||
Assert.IsTrue(created); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue