10 changed files with 148 additions and 6 deletions
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// 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.Project; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public class PowerShellWorkingDirectory |
||||
{ |
||||
IPackageManagementProjectService projectService; |
||||
|
||||
public PowerShellWorkingDirectory(IPackageManagementProjectService projectService) |
||||
{ |
||||
this.projectService = projectService; |
||||
} |
||||
|
||||
public string GetWorkingDirectory() |
||||
{ |
||||
Solution solution = projectService.OpenSolution; |
||||
if (solution != null) { |
||||
return solution.Directory; |
||||
} |
||||
return "$env:USERPROFILE"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
// 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.SharpDevelop.Project; |
||||
using NUnit.Framework; |
||||
|
||||
namespace PackageManagement.Tests.Scripting |
||||
{ |
||||
[TestFixture] |
||||
public class PowerShellWorkingDirectoryTests |
||||
{ |
||||
FakePackageManagementProjectService fakeProjectService; |
||||
PowerShellWorkingDirectory workingDirectory; |
||||
|
||||
void CreateWorkingDirectory() |
||||
{ |
||||
fakeProjectService = new FakePackageManagementProjectService(); |
||||
workingDirectory = new PowerShellWorkingDirectory(fakeProjectService); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetWorkingDirectory_NoSolutionOpen_ReturnsUserProfileFolder() |
||||
{ |
||||
CreateWorkingDirectory(); |
||||
fakeProjectService.OpenSolution = null; |
||||
|
||||
string directory = workingDirectory.GetWorkingDirectory(); |
||||
|
||||
string expectedDirectory = "$env:USERPROFILE"; |
||||
|
||||
Assert.AreEqual(expectedDirectory, directory); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetWorkingDirectory_SolutionOpen_ReturnsSolutionDirectory() |
||||
{ |
||||
CreateWorkingDirectory(); |
||||
var solution = new Solution(); |
||||
solution.FileName = @"d:\projects\MyProject\myproject.sln"; |
||||
fakeProjectService.OpenSolution = solution; |
||||
|
||||
string directory = workingDirectory.GetWorkingDirectory(); |
||||
|
||||
string expectedDirectory = @"d:\projects\MyProject"; |
||||
|
||||
Assert.AreEqual(expectedDirectory, directory); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue