Browse Source

Reset PowerShell working directory when solution is closed.

pull/15/head
Matt Ward 14 years ago
parent
commit
64a7c8ab80
  1. 1
      src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj
  2. 2
      src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementServices.cs
  3. 33
      src/AddIns/Misc/PackageManagement/Project/Src/Scripting/ResetPowerShellWorkingDirectoryOnSolutionClosed.cs
  4. 1
      src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj
  5. 59
      src/AddIns/Misc/PackageManagement/Test/Src/Scripting/ResetPowerShellWorkingDirectoryOnSolutionClosedTests.cs

1
src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj

@ -200,6 +200,7 @@ @@ -200,6 +200,7 @@
<Compile Include="Src\Scripting\PackageInitializationScriptsConsole.cs" />
<Compile Include="Src\Scripting\PackageInitializationScriptsFactory.cs" />
<Compile Include="Src\Scripting\PowerShellWorkingDirectory.cs" />
<Compile Include="Src\Scripting\ResetPowerShellWorkingDirectoryOnSolutionClosed.cs" />
<Compile Include="Src\SolutionPackageRepositoryPath.cs" />
<Compile Include="Src\PackageSourceConverter.cs" />
<Compile Include="Src\PackageSourceViewModel.cs" />

2
src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementServices.cs

@ -17,6 +17,7 @@ namespace ICSharpCode.PackageManagement @@ -17,6 +17,7 @@ namespace ICSharpCode.PackageManagement
static readonly ProjectBrowserRefresher projectBrowserRefresher;
static readonly PackageManagementOutputMessagesView outputMessagesView;
static readonly PackageInitializationScriptsRunnerForOpenedSolution packageInitializationScriptsRunner;
static readonly ResetPowerShellWorkingDirectoryOnSolutionClosed resetPowerShellWorkingDirectory;
static PackageManagementServices()
{
@ -27,6 +28,7 @@ namespace ICSharpCode.PackageManagement @@ -27,6 +28,7 @@ namespace ICSharpCode.PackageManagement
consoleHost = new PackageManagementConsoleHost(solution, registeredPackageRepositories);
projectBrowserRefresher = new ProjectBrowserRefresher(projectService, packageManagementEvents);
packageInitializationScriptsRunner = new PackageInitializationScriptsRunnerForOpenedSolution(projectService);
resetPowerShellWorkingDirectory = new ResetPowerShellWorkingDirectoryOnSolutionClosed(projectService, consoleHost);
}
public static PackageManagementOptions Options {

33
src/AddIns/Misc/PackageManagement/Project/Src/Scripting/ResetPowerShellWorkingDirectoryOnSolutionClosed.cs

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
// 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;
namespace ICSharpCode.PackageManagement.Scripting
{
public class ResetPowerShellWorkingDirectoryOnSolutionClosed
{
IPackageManagementConsoleHost consoleHost;
public ResetPowerShellWorkingDirectoryOnSolutionClosed(
IPackageManagementProjectService projectService,
IPackageManagementConsoleHost consoleHost)
{
this.consoleHost = consoleHost;
projectService.SolutionClosed += SolutionClosed;
}
void SolutionClosed(object sender, EventArgs e)
{
if (consoleHost.IsRunning) {
UpdateWorkingDirectory();
}
}
void UpdateWorkingDirectory()
{
string command = "Invoke-UpdateWorkingDirectory";
consoleHost.ScriptingConsole.SendLine(command);
}
}
}

1
src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj

@ -178,6 +178,7 @@ @@ -178,6 +178,7 @@
<Compile Include="Src\Scripting\PackageInitializationScriptsConsoleTests.cs" />
<Compile Include="Src\Scripting\PackageInitializationScriptsTests.cs" />
<Compile Include="Src\Scripting\PowerShellWorkingDirectoryTests.cs" />
<Compile Include="Src\Scripting\ResetPowerShellWorkingDirectoryOnSolutionClosedTests.cs" />
<Compile Include="Src\SolutionPackageRepositoryPathTests.cs" />
<Compile Include="Src\PackageSourceViewModelTests.cs" />
<Compile Include="Src\PackagesViewModelTests.cs" />

59
src/AddIns/Misc/PackageManagement/Test/Src/Scripting/ResetPowerShellWorkingDirectoryOnSolutionClosedTests.cs

@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
// 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.Design;
using ICSharpCode.PackageManagement.Scripting;
using ICSharpCode.Scripting.Tests.Utils;
using NUnit.Framework;
using PackageManagement.Tests.Helpers;
namespace PackageManagement.Tests.Scripting
{
[TestFixture]
public class ResetPowerShellWorkingDirectoryOnSolutionClosedTests
{
FakePackageManagementProjectService fakeProjectService;
FakePackageManagementConsoleHost fakeConsoleHost;
FakeScriptingConsole fakeScriptingConsole;
ResetPowerShellWorkingDirectoryOnSolutionClosed reset;
void CreateReset()
{
fakeProjectService = new FakePackageManagementProjectService();
fakeConsoleHost = new FakePackageManagementConsoleHost();
fakeScriptingConsole = new FakeScriptingConsole();
fakeConsoleHost.ScriptingConsole = fakeScriptingConsole;
reset = new ResetPowerShellWorkingDirectoryOnSolutionClosed(fakeProjectService, fakeConsoleHost);
}
bool IsWorkingDirectoryUpdated()
{
return fakeScriptingConsole.AllTextPassedToSendLine.Contains("Invoke-UpdateWorkingDirectory");
}
[Test]
public void Instance_SolutionClosedWhenConsoleHostIsRunning_WorkingDirectoryIsUpdated()
{
CreateReset();
fakeConsoleHost.IsRunning = true;
fakeProjectService.FireSolutionClosedEvent();
bool workingDirectoryUpdated = IsWorkingDirectoryUpdated();
Assert.IsTrue(workingDirectoryUpdated);
}
[Test]
public void Instance_SolutionClosedWhenConsoleHostIsNotRunning_WorkingDirectoryIsNotUpdated()
{
CreateReset();
fakeConsoleHost.IsRunning = false;
fakeProjectService.FireSolutionClosedEvent();
bool workingDirectoryUpdated = IsWorkingDirectoryUpdated();
Assert.IsFalse(workingDirectoryUpdated);
}
}
}
Loading…
Cancel
Save