48 changed files with 1834 additions and 42 deletions
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
// 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.EnvDTE |
||||
{ |
||||
public class Project |
||||
{ |
||||
} |
||||
} |
||||
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
// 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 interface IPackageScript |
||||
{ |
||||
IPackageManagementProject Project { get; set; } |
||||
|
||||
void Execute(); |
||||
} |
||||
} |
||||
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public interface IPackageScriptFactory |
||||
{ |
||||
IPackageScript CreatePackageInitializeScript(string packageInstallDirectory); |
||||
IPackageScript CreatePackageUninstallScript(string packageInstallDirectory); |
||||
IPackageScript CreatePackageInstallScript(string packageInstallDirectory); |
||||
} |
||||
} |
||||
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
// 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 interface IPackageScriptSession |
||||
{ |
||||
void SetEnvironmentPath(string path); |
||||
string GetEnvironmentPath(); |
||||
|
||||
void AddVariable(string name, object value); |
||||
void RemoveVariable(string name); |
||||
|
||||
void InvokeScript(string script); |
||||
} |
||||
} |
||||
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public class PackageInitializeScript : PackageScript |
||||
{ |
||||
public PackageInitializeScript( |
||||
PackageInitializeScriptFileName fileName, |
||||
IPackageScriptSession session) |
||||
: base(fileName, session) |
||||
{ |
||||
} |
||||
|
||||
protected override void BeforeExecute() |
||||
{ |
||||
AddScriptDirectoryToEnvironmentPath(); |
||||
} |
||||
|
||||
void AddScriptDirectoryToEnvironmentPath() |
||||
{ |
||||
if (ScriptFileName.ScriptDirectoryExists()) { |
||||
string directory = ScriptFileName.GetScriptDirectory(); |
||||
AddScriptDirectoryToEnvironmentPath(directory); |
||||
} |
||||
} |
||||
|
||||
void AddScriptDirectoryToEnvironmentPath(string directory) |
||||
{ |
||||
var environmentPath = new PowerShellSessionEnvironmentPath(Session); |
||||
environmentPath.Append(directory); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
// 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 System.IO; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public class PackageInitializeScriptFileName : PackageScriptFileName |
||||
{ |
||||
public PackageInitializeScriptFileName(string packageInstallDirectory) |
||||
: base(packageInstallDirectory) |
||||
{ |
||||
} |
||||
|
||||
public PackageInitializeScriptFileName(IFileSystem fileSystem) |
||||
: base(fileSystem) |
||||
{ |
||||
} |
||||
|
||||
public override string Name { |
||||
get { return "init.ps1"; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
// 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 PackageInstallScript : PackageScript |
||||
{ |
||||
public PackageInstallScript( |
||||
PackageInstallScriptFileName fileName, |
||||
IPackageScriptSession session) |
||||
: base(fileName, session) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public class PackageInstallScriptFileName : PackageScriptFileName |
||||
{ |
||||
public PackageInstallScriptFileName(string packageInstallDirectory) |
||||
: base(packageInstallDirectory) |
||||
{ |
||||
} |
||||
|
||||
public PackageInstallScriptFileName(IFileSystem fileSystem) |
||||
: base(fileSystem) |
||||
{ |
||||
} |
||||
|
||||
public override string Name { |
||||
get { return "install.ps1"; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
// 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.EnvDTE; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public class PackageScript : IPackageScript |
||||
{ |
||||
public PackageScript( |
||||
PackageScriptFileName fileName, |
||||
IPackageScriptSession session) |
||||
{ |
||||
this.ScriptFileName = fileName; |
||||
this.Session = session; |
||||
} |
||||
|
||||
protected PackageScriptFileName ScriptFileName { get; private set; } |
||||
protected IPackageScriptSession Session { get; private set; } |
||||
|
||||
public IPackage Package { get; set; } |
||||
public IPackageManagementProject Project { get; set; } |
||||
|
||||
public void Execute() |
||||
{ |
||||
BeforeExecute(); |
||||
AddSessionVariables(); |
||||
ExecuteScript(); |
||||
RemoveSessionVariables(); |
||||
} |
||||
|
||||
protected virtual void BeforeExecute() |
||||
{ |
||||
} |
||||
|
||||
void AddSessionVariables() |
||||
{ |
||||
Session.AddVariable("__rootPath", ScriptFileName.PackageInstallDirectory); |
||||
Session.AddVariable("__toolsPath", ScriptFileName.GetScriptDirectory()); |
||||
Session.AddVariable("__package", Package); |
||||
Session.AddVariable("__project", GetProject()); |
||||
} |
||||
|
||||
Project GetProject() |
||||
{ |
||||
if (Project != null) { |
||||
return Project.ConvertToDTEProject(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
void ExecuteScript() |
||||
{ |
||||
string script = GetScript(); |
||||
Session.InvokeScript(script); |
||||
} |
||||
|
||||
string GetScript() |
||||
{ |
||||
return String.Format( |
||||
"& '{0}' $__rootPath $__toolsPath $__package $__project", |
||||
ScriptFileName); |
||||
} |
||||
|
||||
void RemoveSessionVariables() |
||||
{ |
||||
Session.RemoveVariable("__rootPath"); |
||||
Session.RemoveVariable("__toolsPath"); |
||||
Session.RemoveVariable("__package"); |
||||
Session.RemoveVariable("__project"); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public class PackageScriptFactory : IPackageScriptFactory |
||||
{ |
||||
IPackageScriptSession session; |
||||
|
||||
public PackageScriptFactory(IPackageScriptSession session) |
||||
{ |
||||
this.session = session; |
||||
} |
||||
|
||||
public IPackageScript CreatePackageInitializeScript(string packageInstallDirectory) |
||||
{ |
||||
var scriptFileName = new PackageInitializeScriptFileName(packageInstallDirectory); |
||||
return new PackageInitializeScript(scriptFileName, session); |
||||
} |
||||
|
||||
public IPackageScript CreatePackageUninstallScript(string packageInstallDirectory) |
||||
{ |
||||
var scriptFileName = new PackageUninstallScriptFileName(packageInstallDirectory); |
||||
return new PackageUninstallScript(scriptFileName, session); |
||||
} |
||||
|
||||
public IPackageScript CreatePackageInstallScript(string packageInstallDirectory) |
||||
{ |
||||
var scriptFileName = new PackageInstallScriptFileName(packageInstallDirectory); |
||||
return new PackageInstallScript(scriptFileName, session); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
// 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 System.IO; |
||||
using NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public abstract class PackageScriptFileName |
||||
{ |
||||
IFileSystem fileSystem; |
||||
string relativeScriptFilePath; |
||||
|
||||
public PackageScriptFileName(string packageInstallDirectory) |
||||
: this(new PhysicalFileSystem(packageInstallDirectory)) |
||||
{ |
||||
} |
||||
|
||||
public PackageScriptFileName(IFileSystem fileSystem) |
||||
{ |
||||
this.fileSystem = fileSystem; |
||||
GetRelativeScriptFilePath(); |
||||
} |
||||
|
||||
void GetRelativeScriptFilePath() |
||||
{ |
||||
relativeScriptFilePath = Path.Combine("tools", Name); |
||||
} |
||||
|
||||
public abstract string Name { get; } |
||||
|
||||
public string PackageInstallDirectory { |
||||
get { return fileSystem.Root; } |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return fileSystem.GetFullPath(relativeScriptFilePath); |
||||
} |
||||
|
||||
public bool ScriptDirectoryExists() |
||||
{ |
||||
return fileSystem.DirectoryExists("tools"); |
||||
} |
||||
|
||||
public bool FileExists() |
||||
{ |
||||
return fileSystem.FileExists(relativeScriptFilePath); |
||||
} |
||||
|
||||
public string GetScriptDirectory() |
||||
{ |
||||
return fileSystem.GetFullPath("tools"); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
// 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 PackageUninstallScript : PackageScript |
||||
{ |
||||
public PackageUninstallScript( |
||||
PackageUninstallScriptFileName fileName, |
||||
IPackageScriptSession session) |
||||
: base(fileName, session) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public class PackageUninstallScriptFileName : PackageScriptFileName |
||||
{ |
||||
public PackageUninstallScriptFileName(string packageInstallDirectory) |
||||
: base(packageInstallDirectory) |
||||
{ |
||||
} |
||||
|
||||
public PackageUninstallScriptFileName(IFileSystem fileSystem) |
||||
: base(fileSystem) |
||||
{ |
||||
} |
||||
|
||||
public override string Name { |
||||
get { return "uninstall.ps1"; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
// 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 PowerShellSessionEnvironmentPath |
||||
{ |
||||
IPackageScriptSession session; |
||||
|
||||
public PowerShellSessionEnvironmentPath(IPackageScriptSession session) |
||||
{ |
||||
this.session = session; |
||||
} |
||||
|
||||
public void Append(string path) |
||||
{ |
||||
string environmentPath = GetEnvironmentPath(); |
||||
environmentPath = AppendPathSeparatorIfMissing(environmentPath); |
||||
SetEnvironmentPath(environmentPath + path); |
||||
} |
||||
|
||||
string GetEnvironmentPath() |
||||
{ |
||||
return session.GetEnvironmentPath(); |
||||
} |
||||
|
||||
string AppendPathSeparatorIfMissing(string path) |
||||
{ |
||||
if (String.IsNullOrEmpty(path)) { |
||||
return String.Empty; |
||||
} |
||||
|
||||
if (path.EndsWith(";")) { |
||||
return path; |
||||
} |
||||
return path + ";"; |
||||
} |
||||
|
||||
void SetEnvironmentPath(string path) |
||||
{ |
||||
session.SetEnvironmentPath(path); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,88 @@
@@ -0,0 +1,88 @@
|
||||
// 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 NuGet; |
||||
|
||||
namespace ICSharpCode.PackageManagement.Scripting |
||||
{ |
||||
public class RunPackageScriptsAction : IDisposable |
||||
{ |
||||
IPackageManagementProject project; |
||||
IPackageScriptFactory scriptFactory; |
||||
|
||||
public RunPackageScriptsAction( |
||||
IPackageScriptSession session, |
||||
IPackageManagementProject project) |
||||
: this(project, new PackageScriptFactory(session)) |
||||
{ |
||||
} |
||||
|
||||
public RunPackageScriptsAction( |
||||
IPackageManagementProject project, |
||||
IPackageScriptFactory scriptFactory) |
||||
{ |
||||
this.project = project; |
||||
this.scriptFactory = scriptFactory; |
||||
|
||||
RegisterEvents(); |
||||
} |
||||
|
||||
void RegisterEvents() |
||||
{ |
||||
project.PackageInstalled += PackageInstalled; |
||||
project.PackageReferenceAdded += PackageReferenceAdded; |
||||
project.PackageReferenceRemoved += PackageReferenceRemoved; |
||||
} |
||||
|
||||
void UnregisterEvents() |
||||
{ |
||||
project.PackageInstalled -= PackageInstalled; |
||||
project.PackageReferenceAdded -= PackageReferenceAdded; |
||||
project.PackageReferenceRemoved -= PackageReferenceRemoved; |
||||
} |
||||
|
||||
void PackageInstalled(object sender, PackageOperationEventArgs e) |
||||
{ |
||||
RunInitScript(e); |
||||
} |
||||
|
||||
void PackageReferenceRemoved(object sender, PackageOperationEventArgs e) |
||||
{ |
||||
RunUninstallScript(e); |
||||
} |
||||
|
||||
void PackageReferenceAdded(object sender, PackageOperationEventArgs e) |
||||
{ |
||||
RunInstallScript(e); |
||||
} |
||||
|
||||
void RunInitScript(PackageOperationEventArgs e) |
||||
{ |
||||
IPackageScript script = scriptFactory.CreatePackageInitializeScript(e.InstallPath); |
||||
script.Execute(); |
||||
} |
||||
|
||||
void RunUninstallScript(PackageOperationEventArgs e) |
||||
{ |
||||
IPackageScript script = scriptFactory.CreatePackageUninstallScript(e.InstallPath); |
||||
script.Project = project; |
||||
script.Execute(); |
||||
} |
||||
|
||||
void RunInstallScript(PackageOperationEventArgs e) |
||||
{ |
||||
IPackageScript script = scriptFactory.CreatePackageInstallScript(e.InstallPath); |
||||
script.Project = project; |
||||
script.Execute(); |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
IsDisposed = true; |
||||
UnregisterEvents(); |
||||
} |
||||
|
||||
public bool IsDisposed { get; private set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
// 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; |
||||
using ICSharpCode.PackageManagement.Scripting; |
||||
|
||||
namespace PackageManagement.Tests.Helpers |
||||
{ |
||||
public class FakePackageScript : IPackageScript |
||||
{ |
||||
public bool IsExecuted; |
||||
|
||||
public void Execute() |
||||
{ |
||||
IsExecuted = true; |
||||
} |
||||
|
||||
public IPackageManagementProject Project { get; set; } |
||||
} |
||||
} |
||||
@ -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 NuGet; |
||||
|
||||
namespace PackageManagement.Tests.Helpers |
||||
{ |
||||
public class FakePackageScriptFactory : IPackageScriptFactory |
||||
{ |
||||
public string PackageInstallDirectoryPassed; |
||||
public FakePackageScript FakePackageInitializeScript = new FakePackageScript(); |
||||
public FakePackageScript FakePackageInstallScript = new FakePackageScript(); |
||||
public FakePackageScript FakePackageUninstallScript = new FakePackageScript(); |
||||
|
||||
public IPackageScript CreatePackageInitializeScript(string packageInstallDirectory) |
||||
{ |
||||
PackageInstallDirectoryPassed = packageInstallDirectory; |
||||
return FakePackageInitializeScript; |
||||
} |
||||
|
||||
public IPackageScript CreatePackageUninstallScript(string packageInstallDirectory) |
||||
{ |
||||
PackageInstallDirectoryPassed = packageInstallDirectory; |
||||
return FakePackageUninstallScript; |
||||
} |
||||
|
||||
public IPackageScript CreatePackageInstallScript(string packageInstallDirectory) |
||||
{ |
||||
PackageInstallDirectoryPassed = packageInstallDirectory; |
||||
return FakePackageInstallScript; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
// 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 System.Collections.Generic; |
||||
using ICSharpCode.PackageManagement.Scripting; |
||||
|
||||
namespace PackageManagement.Tests.Helpers |
||||
{ |
||||
public class FakePackageScriptSession : IPackageScriptSession |
||||
{ |
||||
public string EnvironmentPath = String.Empty; |
||||
|
||||
public void SetEnvironmentPath(string path) |
||||
{ |
||||
EnvironmentPath = path; |
||||
} |
||||
|
||||
public string GetEnvironmentPath() |
||||
{ |
||||
return EnvironmentPath; |
||||
} |
||||
|
||||
public Dictionary<string, object> VariablesAdded = new Dictionary<string, object>(); |
||||
|
||||
public void AddVariable(string name, object value) |
||||
{ |
||||
VariablesAdded.Add(name, value); |
||||
} |
||||
|
||||
public List<string> VariablesRemoved = new List<string>(); |
||||
|
||||
public void RemoveVariable(string name) |
||||
{ |
||||
VariablesRemoved.Add(name); |
||||
} |
||||
|
||||
public string ScriptPassedToInvokeScript; |
||||
|
||||
public void InvokeScript(string script) |
||||
{ |
||||
ScriptPassedToInvokeScript = script; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,142 @@
@@ -0,0 +1,142 @@
|
||||
// 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 NUnit.Framework; |
||||
|
||||
namespace PackageManagement.Tests.Scripting |
||||
{ |
||||
[TestFixture] |
||||
public class PackageInitializeScriptFileNameTests |
||||
{ |
||||
PackageInitializeScriptFileName scriptFileName; |
||||
FakeFileSystem fakeFileSystem; |
||||
|
||||
void CreateFileSystem() |
||||
{ |
||||
fakeFileSystem = new FakeFileSystem(); |
||||
} |
||||
|
||||
void CreateFileName(string installPath) |
||||
{ |
||||
scriptFileName = new PackageInitializeScriptFileName(installPath); |
||||
} |
||||
|
||||
void CreateFakeFileSystem() |
||||
{ |
||||
fakeFileSystem = new FakeFileSystem(); |
||||
} |
||||
|
||||
void CreateFileNameWithFakeFileSystem() |
||||
{ |
||||
scriptFileName = new PackageInitializeScriptFileName(fakeFileSystem); |
||||
} |
||||
|
||||
[Test] |
||||
public void ToString_InstallDirectoryPassed_ReturnsFullPathToInitScript() |
||||
{ |
||||
CreateFileName(@"d:\projects\MyProject\packages\Test"); |
||||
|
||||
string actualFileName = scriptFileName.ToString(); |
||||
string expectedFileName = @"d:\projects\MyProject\packages\Test\tools\init.ps1"; |
||||
|
||||
Assert.AreEqual(expectedFileName, actualFileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void PackageInstallDirectory_InstallDirectoryPassed_ReturnsFullPathToInitScript() |
||||
{ |
||||
CreateFileName(@"d:\projects\MyProject\packages\Test"); |
||||
|
||||
string actualDirectory = scriptFileName.PackageInstallDirectory; |
||||
string expectedDirectory = @"d:\projects\MyProject\packages\Test"; |
||||
|
||||
Assert.AreEqual(expectedDirectory, actualDirectory); |
||||
} |
||||
|
||||
[Test] |
||||
public void ScriptDirectoryExists_FileSystemHasScriptDirectory_ReturnsTrue() |
||||
{ |
||||
CreateFakeFileSystem(); |
||||
fakeFileSystem.DirectoryExistsReturnValue = true; |
||||
CreateFileNameWithFakeFileSystem(); |
||||
|
||||
bool exists = scriptFileName.ScriptDirectoryExists(); |
||||
|
||||
Assert.IsTrue(exists); |
||||
} |
||||
|
||||
[Test] |
||||
public void ScriptDirectoryExists_FileSystemDoesNotHaveScriptDirectory_ReturnsFalse() |
||||
{ |
||||
CreateFakeFileSystem(); |
||||
fakeFileSystem.DirectoryExistsReturnValue = false; |
||||
CreateFileNameWithFakeFileSystem(); |
||||
|
||||
bool exists = scriptFileName.ScriptDirectoryExists(); |
||||
|
||||
Assert.IsFalse(exists); |
||||
} |
||||
|
||||
[Test] |
||||
public void ScriptDirectoryExists_FileSystemHasScriptDirectory_ToolsDirectoryCheckedForExistence() |
||||
{ |
||||
CreateFakeFileSystem(); |
||||
fakeFileSystem.DirectoryExistsReturnValue = true; |
||||
CreateFileNameWithFakeFileSystem(); |
||||
|
||||
scriptFileName.ScriptDirectoryExists(); |
||||
|
||||
Assert.AreEqual("tools", fakeFileSystem.PathPassedToDirectoryExists); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileExists_FileSystemHasScriptFile_ReturnsTrue() |
||||
{ |
||||
CreateFakeFileSystem(); |
||||
fakeFileSystem.FileExistsReturnValue = true; |
||||
CreateFileNameWithFakeFileSystem(); |
||||
|
||||
bool exists = scriptFileName.FileExists(); |
||||
|
||||
Assert.IsTrue(exists); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileExists_FileSystemDoesNotHaveScriptFile_ReturnsFalse() |
||||
{ |
||||
CreateFakeFileSystem(); |
||||
fakeFileSystem.FileExistsReturnValue = false; |
||||
CreateFileNameWithFakeFileSystem(); |
||||
|
||||
bool exists = scriptFileName.FileExists(); |
||||
|
||||
Assert.IsFalse(exists); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileExists_FileSystemHasScriptFile_ToolsScriptFileCheckedForExistence() |
||||
{ |
||||
CreateFakeFileSystem(); |
||||
fakeFileSystem.FileExistsReturnValue = true; |
||||
CreateFileNameWithFakeFileSystem(); |
||||
|
||||
scriptFileName.FileExists(); |
||||
|
||||
Assert.AreEqual(@"tools\init.ps1", fakeFileSystem.PathPassedToFileExists); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetScriptDirectory_InstallDirectoryPassed_ReturnsInitScriptDirectory() |
||||
{ |
||||
CreateFileName(@"d:\projects\MyProject\packages\Test"); |
||||
|
||||
string actualDirectory = scriptFileName.GetScriptDirectory(); |
||||
string expectedDirectory = @"d:\projects\MyProject\packages\Test\tools"; |
||||
|
||||
Assert.AreEqual(expectedDirectory, actualDirectory); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,224 @@
@@ -0,0 +1,224 @@
|
||||
// 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 NUnit.Framework; |
||||
using PackageManagement.Tests.Helpers; |
||||
|
||||
namespace PackageManagement.Tests.Scripting |
||||
{ |
||||
[TestFixture] |
||||
public class PackageInitializeScriptTests |
||||
{ |
||||
PackageInitializeScript script; |
||||
PackageInitializeScriptFileName scriptFileName; |
||||
FakeFileSystem fakeFileSystem; |
||||
FakePackageScriptSession fakeSession; |
||||
|
||||
void CreateScript() |
||||
{ |
||||
fakeFileSystem = new FakeFileSystem(); |
||||
fakeFileSystem.FileExistsReturnValue = true; |
||||
fakeFileSystem.DirectoryExistsReturnValue = true; |
||||
scriptFileName = new PackageInitializeScriptFileName(fakeFileSystem); |
||||
|
||||
fakeSession = new FakePackageScriptSession(); |
||||
|
||||
script = new PackageInitializeScript(scriptFileName, fakeSession); |
||||
} |
||||
|
||||
void CreateScriptWithPhysicalFileSystem() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(@"d:\projects\myproject\packages\test"); |
||||
} |
||||
|
||||
void CreateScriptWithPhysicalFileSystem(string packageInstallDirectory) |
||||
{ |
||||
scriptFileName = new PackageInitializeScriptFileName(packageInstallDirectory); |
||||
fakeSession = new FakePackageScriptSession(); |
||||
script = new PackageInitializeScript(scriptFileName, fakeSession); |
||||
} |
||||
|
||||
void AssertSessionVariableIsRemoved(string variableName) |
||||
{ |
||||
bool removed = fakeSession.VariablesRemoved.Contains(variableName); |
||||
Assert.IsTrue(removed); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_ExistingEnvironmentPathIsEmptyString_PathToScriptAddedToEnvironmentPath() |
||||
{ |
||||
CreateScript(); |
||||
fakeFileSystem.PathToReturnFromGetFullPath = @"d:\projects\myproject\packages\test"; |
||||
fakeSession.SetEnvironmentPath(String.Empty); |
||||
|
||||
script.Execute(); |
||||
|
||||
string actualEnvironmentPath = fakeSession.GetEnvironmentPath(); |
||||
string expectedEnvironmentPath = @"d:\projects\myproject\packages\test"; |
||||
|
||||
Assert.AreEqual(expectedEnvironmentPath, actualEnvironmentPath); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_OneItemInOriginalEnvironmentPath_PathToScriptAppendedToEnvironmentPath() |
||||
{ |
||||
CreateScript(); |
||||
fakeFileSystem.PathToReturnFromGetFullPath = @"d:\projects\myproject\packages\test"; |
||||
fakeSession.SetEnvironmentPath(@"c:\users\sharpdevelop\ps;"); |
||||
|
||||
script.Execute(); |
||||
|
||||
string actualEnvironmentPath = fakeSession.GetEnvironmentPath(); |
||||
string expectedEnvironmentPath = @"c:\users\sharpdevelop\ps;d:\projects\myproject\packages\test"; |
||||
|
||||
Assert.AreEqual(expectedEnvironmentPath, actualEnvironmentPath); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_OneItemInOriginalEnvironmentPathMissingSemiColonAtEnd_PathToScriptAppendedToEnvironmentPathWithSemiColonAtStart() |
||||
{ |
||||
CreateScript(); |
||||
fakeFileSystem.PathToReturnFromGetFullPath = @"d:\projects\myproject\packages\test"; |
||||
fakeSession.SetEnvironmentPath(@"c:\users\sharpdevelop\ps"); |
||||
|
||||
script.Execute(); |
||||
|
||||
string actualEnvironmentPath = fakeSession.GetEnvironmentPath(); |
||||
string expectedEnvironmentPath = @"c:\users\sharpdevelop\ps;d:\projects\myproject\packages\test"; |
||||
|
||||
Assert.AreEqual(expectedEnvironmentPath, actualEnvironmentPath); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_OriginalEnvironmentPathIsNull_PathToScriptAppendedToEnvironmentPath() |
||||
{ |
||||
CreateScript(); |
||||
fakeFileSystem.PathToReturnFromGetFullPath = @"d:\projects\myproject\packages\test"; |
||||
fakeSession.SetEnvironmentPath(null); |
||||
|
||||
script.Execute(); |
||||
|
||||
string actualEnvironmentPath = fakeSession.GetEnvironmentPath(); |
||||
string expectedEnvironmentPath = @"d:\projects\myproject\packages\test"; |
||||
|
||||
Assert.AreEqual(expectedEnvironmentPath, actualEnvironmentPath); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_ScriptDirectoryDoesNotExist_PathIsNotUpdated() |
||||
{ |
||||
CreateScript(); |
||||
fakeFileSystem.PathToReturnFromGetFullPath = @"d:\projects\myproject\packages\test"; |
||||
fakeFileSystem.DirectoryExistsReturnValue = false; |
||||
fakeSession.SetEnvironmentPath(String.Empty); |
||||
|
||||
script.Execute(); |
||||
|
||||
string actualEnvironmentPath = fakeSession.GetEnvironmentPath(); |
||||
string expectedEnvironmentPath = String.Empty; |
||||
|
||||
Assert.AreEqual(expectedEnvironmentPath, actualEnvironmentPath); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_PackageIsSet_PackageSessionVariableIsSet() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(); |
||||
var expectedPackage = new FakePackage("Test"); |
||||
script.Package = expectedPackage; |
||||
script.Execute(); |
||||
|
||||
var actualPackage = fakeSession.VariablesAdded["__package"]; |
||||
|
||||
Assert.AreEqual(expectedPackage, actualPackage); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_PackageInstallDirectoryIsSet_RootPathSessionVariableIsSet() |
||||
{ |
||||
string expectedRootPath = @"d:\projects\myproject\packages\test"; |
||||
CreateScriptWithPhysicalFileSystem(expectedRootPath); |
||||
script.Execute(); |
||||
|
||||
var rootPath = fakeSession.VariablesAdded["__rootPath"]; |
||||
|
||||
Assert.AreEqual(expectedRootPath, rootPath); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_PackageInstallDirectoryIsSet_ToolsPathSessionVariableIsSet() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(@"d:\projects\myproject\packages\test"); |
||||
script.Execute(); |
||||
|
||||
var toolsPath = fakeSession.VariablesAdded["__toolsPath"]; |
||||
string expectedToolsPath = @"d:\projects\myproject\packages\test\tools"; |
||||
|
||||
Assert.AreEqual(expectedToolsPath, toolsPath); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_PackageInstallDirectoryIsSet_ProjectSessionVariableIsSet() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(); |
||||
script.Execute(); |
||||
|
||||
var project = fakeSession.VariablesAdded["__project"]; |
||||
|
||||
Assert.IsNull(project); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_PackageInstallDirectoryIsSet_ScriptIsInvoked() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(@"d:\projects\myproject\packages\test"); |
||||
script.Execute(); |
||||
|
||||
string actualScript = fakeSession.ScriptPassedToInvokeScript; |
||||
|
||||
string expectedScript = |
||||
"& 'd:\\projects\\myproject\\packages\\test\\tools\\init.ps1' $__rootPath $__toolsPath $__package $__project"; |
||||
|
||||
Assert.AreEqual(expectedScript, actualScript); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_PackageInstallDirectoryIsSet_PackageSessionVariableIsRemoved() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(); |
||||
script.Execute(); |
||||
|
||||
AssertSessionVariableIsRemoved("__package"); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_PackageInstallDirectoryIsSet_RootPathSessionVariableIsRemoved() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(); |
||||
script.Execute(); |
||||
|
||||
AssertSessionVariableIsRemoved("__rootPath"); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_PackageInstallDirectoryIsSet_ToolsPathSessionVariableIsRemoved() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(); |
||||
script.Execute(); |
||||
|
||||
AssertSessionVariableIsRemoved("__toolsPath"); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_PackageInstallDirectoryIsSet_ProjectSessionVariableIsRemoved() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(); |
||||
script.Execute(); |
||||
|
||||
AssertSessionVariableIsRemoved("__project"); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// 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 NUnit.Framework; |
||||
|
||||
namespace PackageManagement.Tests.Scripting |
||||
{ |
||||
[TestFixture] |
||||
public class PackageInstallScriptFileNameTests |
||||
{ |
||||
PackageInstallScriptFileName scriptFileName; |
||||
FakeFileSystem fakeFileSystem; |
||||
|
||||
void CreateFileSystem() |
||||
{ |
||||
fakeFileSystem = new FakeFileSystem(); |
||||
} |
||||
|
||||
void CreateFileName(string installPath) |
||||
{ |
||||
scriptFileName = new PackageInstallScriptFileName(installPath); |
||||
} |
||||
|
||||
void CreateFakeFileSystem() |
||||
{ |
||||
fakeFileSystem = new FakeFileSystem(); |
||||
} |
||||
|
||||
void CreateFileNameWithFakeFileSystem() |
||||
{ |
||||
scriptFileName = new PackageInstallScriptFileName(fakeFileSystem); |
||||
} |
||||
|
||||
[Test] |
||||
public void ToString_InstallDirectoryPassed_ReturnsFullPathToInstallScript() |
||||
{ |
||||
CreateFileName(@"d:\projects\MyProject\packages\Test"); |
||||
|
||||
string actualFileName = scriptFileName.ToString(); |
||||
string expectedFileName = @"d:\projects\MyProject\packages\Test\tools\install.ps1"; |
||||
|
||||
Assert.AreEqual(expectedFileName, actualFileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileExists_FileSystemHasScriptFile_ToolsScriptFileCheckedForExistence() |
||||
{ |
||||
CreateFakeFileSystem(); |
||||
fakeFileSystem.FileExistsReturnValue = true; |
||||
CreateFileNameWithFakeFileSystem(); |
||||
|
||||
scriptFileName.FileExists(); |
||||
|
||||
Assert.AreEqual(@"tools\install.ps1", fakeFileSystem.PathPassedToFileExists); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// 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.EnvDTE; |
||||
using ICSharpCode.PackageManagement.Scripting; |
||||
using NUnit.Framework; |
||||
using PackageManagement.Tests.Helpers; |
||||
|
||||
namespace PackageManagement.Tests.Scripting |
||||
{ |
||||
[TestFixture] |
||||
public class PackageInstallScriptTests |
||||
{ |
||||
PackageInstallScriptFileName scriptFileName; |
||||
FakePackageScriptSession fakeSession; |
||||
PackageInstallScript script; |
||||
|
||||
void CreateScriptWithPhysicalFileSystem() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(@"d:\projects\myproject\packages\test"); |
||||
} |
||||
|
||||
void CreateScriptWithPhysicalFileSystem(string packageInstallDirectory) |
||||
{ |
||||
scriptFileName = new PackageInstallScriptFileName(packageInstallDirectory); |
||||
fakeSession = new FakePackageScriptSession(); |
||||
script = new PackageInstallScript(scriptFileName, fakeSession); |
||||
} |
||||
|
||||
[Test] |
||||
public void Execute_PackageInstallDirectoryIsSet_ProjectSessionVariableIsSet() |
||||
{ |
||||
CreateScriptWithPhysicalFileSystem(); |
||||
var expectedProject = new Project(); |
||||
var project = new FakePackageManagementProject(); |
||||
project.DTEProject = expectedProject; |
||||
script.Project = project; |
||||
script.Execute(); |
||||
|
||||
var projectVariable = fakeSession.VariablesAdded["__project"]; |
||||
|
||||
Assert.AreEqual(expectedProject, projectVariable); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// 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 NUnit.Framework; |
||||
|
||||
namespace PackageManagement.Tests.Scripting |
||||
{ |
||||
[TestFixture] |
||||
public class PackageUninstallScriptFileNameTests |
||||
{ |
||||
PackageUninstallScriptFileName scriptFileName; |
||||
FakeFileSystem fakeFileSystem; |
||||
|
||||
void CreateFileSystem() |
||||
{ |
||||
fakeFileSystem = new FakeFileSystem(); |
||||
} |
||||
|
||||
void CreateFileName(string installPath) |
||||
{ |
||||
scriptFileName = new PackageUninstallScriptFileName(installPath); |
||||
} |
||||
|
||||
void CreateFakeFileSystem() |
||||
{ |
||||
fakeFileSystem = new FakeFileSystem(); |
||||
} |
||||
|
||||
void CreateFileNameWithFakeFileSystem() |
||||
{ |
||||
scriptFileName = new PackageUninstallScriptFileName(fakeFileSystem); |
||||
} |
||||
|
||||
[Test] |
||||
public void ToString_InstallDirectoryPassed_ReturnsFullPathToInstallScript() |
||||
{ |
||||
CreateFileName(@"d:\projects\MyProject\packages\Test"); |
||||
|
||||
string actualFileName = scriptFileName.ToString(); |
||||
string expectedFileName = @"d:\projects\MyProject\packages\Test\tools\uninstall.ps1"; |
||||
|
||||
Assert.AreEqual(expectedFileName, actualFileName); |
||||
} |
||||
|
||||
[Test] |
||||
public void FileExists_FileSystemHasScriptFile_ToolsScriptFileCheckedForExistence() |
||||
{ |
||||
CreateFakeFileSystem(); |
||||
fakeFileSystem.FileExistsReturnValue = true; |
||||
CreateFileNameWithFakeFileSystem(); |
||||
|
||||
scriptFileName.FileExists(); |
||||
|
||||
Assert.AreEqual(@"tools\uninstall.ps1", fakeFileSystem.PathPassedToFileExists); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,178 @@
@@ -0,0 +1,178 @@
|
||||
// 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 NuGet; |
||||
using NUnit.Framework; |
||||
using PackageManagement.Tests.Helpers; |
||||
|
||||
namespace PackageManagement.Tests.Scripting |
||||
{ |
||||
[TestFixture] |
||||
public class RunPackageScriptsActionTests |
||||
{ |
||||
RunPackageScriptsAction action; |
||||
FakePackageManagementProject fakeProject; |
||||
FakePackageScriptFactory fakeScriptFactory; |
||||
|
||||
void CreateAction() |
||||
{ |
||||
fakeProject = new FakePackageManagementProject(); |
||||
fakeScriptFactory = new FakePackageScriptFactory(); |
||||
action = new RunPackageScriptsAction(fakeProject, fakeScriptFactory); |
||||
} |
||||
|
||||
PackageOperationEventArgs CreatePackageOperationEventArgs() |
||||
{ |
||||
return CreatePackageOperationEventArgs(@"d:\projects\myproject\packages\test"); |
||||
} |
||||
|
||||
PackageOperationEventArgs CreatePackageOperationEventArgs(string installPath) |
||||
{ |
||||
var package = new FakePackage("Test"); |
||||
string targetPath = @"d:\projects\myproject\packages\target"; |
||||
return new PackageOperationEventArgs(package, targetPath, installPath); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_PackageIsInstalled_PackageInitScriptIsRun() |
||||
{ |
||||
CreateAction(); |
||||
var eventArgs = CreatePackageOperationEventArgs(); |
||||
fakeProject.FirePackageInstalledEvent(eventArgs); |
||||
|
||||
bool executed = fakeScriptFactory.FakePackageInitializeScript.IsExecuted; |
||||
|
||||
Assert.IsTrue(executed); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_PackageIsInstalled_PackageInitScriptIsCreated() |
||||
{ |
||||
CreateAction(); |
||||
var eventArgs = CreatePackageOperationEventArgs(@"d:\projects\myproject\packages\test"); |
||||
|
||||
fakeProject.FirePackageInstalledEvent(eventArgs); |
||||
|
||||
string path = fakeScriptFactory.PackageInstallDirectoryPassed; |
||||
|
||||
Assert.AreEqual(@"d:\projects\myproject\packages\test", path); |
||||
} |
||||
|
||||
[Test] |
||||
public void Dispose_PackageIsInstalled_PackageInitScriptIsNotRun() |
||||
{ |
||||
CreateAction(); |
||||
action.Dispose(); |
||||
|
||||
var eventArgs = CreatePackageOperationEventArgs(); |
||||
fakeProject.FirePackageInstalledEvent(eventArgs); |
||||
|
||||
bool executed = fakeScriptFactory.FakePackageInitializeScript.IsExecuted; |
||||
|
||||
Assert.IsFalse(executed); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_PackageReferenceIsAdded_PackageInstallScriptIsRun() |
||||
{ |
||||
CreateAction(); |
||||
var eventArgs = CreatePackageOperationEventArgs(); |
||||
fakeProject.FirePackageReferenceAddedEvent(eventArgs); |
||||
|
||||
bool executed = fakeScriptFactory.FakePackageInstallScript.IsExecuted; |
||||
|
||||
Assert.IsTrue(executed); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_PackageReferenceIsAdded_PackageInstallScriptIsCreated() |
||||
{ |
||||
CreateAction(); |
||||
var eventArgs = CreatePackageOperationEventArgs(@"d:\projects\myproject\packages\test"); |
||||
fakeProject.FirePackageReferenceAddedEvent(eventArgs); |
||||
|
||||
string path = fakeScriptFactory.PackageInstallDirectoryPassed; |
||||
|
||||
Assert.AreEqual(@"d:\projects\myproject\packages\test", path); |
||||
} |
||||
|
||||
[Test] |
||||
public void Dispose_PackageReferenceIsAdded_PackageInstallScriptIsNotRun() |
||||
{ |
||||
CreateAction(); |
||||
action.Dispose(); |
||||
|
||||
var eventArgs = CreatePackageOperationEventArgs(); |
||||
fakeProject.FirePackageReferenceAddedEvent(eventArgs); |
||||
|
||||
bool executed = fakeScriptFactory.FakePackageInstallScript.IsExecuted; |
||||
|
||||
Assert.IsFalse(executed); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_PackageReferenceIsAdded_InstallScriptIsPassedProject() |
||||
{ |
||||
CreateAction(); |
||||
var eventArgs = CreatePackageOperationEventArgs(); |
||||
fakeProject.FirePackageReferenceAddedEvent(eventArgs); |
||||
|
||||
var project = fakeScriptFactory.FakePackageInstallScript.Project; |
||||
|
||||
Assert.AreEqual(fakeProject, project); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_PackageReferenceIsRemoved_PackageUninstallScriptIsRun() |
||||
{ |
||||
CreateAction(); |
||||
var eventArgs = CreatePackageOperationEventArgs(); |
||||
fakeProject.FirePackageReferenceRemovedEvent(eventArgs); |
||||
|
||||
bool executed = fakeScriptFactory.FakePackageUninstallScript.IsExecuted; |
||||
|
||||
Assert.IsTrue(executed); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_PackageReferenceIsRemoved_PackageUninstallScriptIsCreated() |
||||
{ |
||||
CreateAction(); |
||||
var eventArgs = CreatePackageOperationEventArgs(@"d:\projects\myproject\packages\test"); |
||||
fakeProject.FirePackageReferenceRemovedEvent(eventArgs); |
||||
|
||||
string path = fakeScriptFactory.PackageInstallDirectoryPassed; |
||||
|
||||
Assert.AreEqual(@"d:\projects\myproject\packages\test", path); |
||||
} |
||||
|
||||
[Test] |
||||
public void Dispose_PackageReferenceIsRemoved_PackageUninstallScriptIsNotRun() |
||||
{ |
||||
CreateAction(); |
||||
action.Dispose(); |
||||
|
||||
var eventArgs = CreatePackageOperationEventArgs(); |
||||
fakeProject.FirePackageReferenceRemovedEvent(eventArgs); |
||||
|
||||
bool executed = fakeScriptFactory.FakePackageUninstallScript.IsExecuted; |
||||
|
||||
Assert.IsFalse(executed); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_PackageReferenceIsRemoved_UninstallScriptIsPassedProject() |
||||
{ |
||||
CreateAction(); |
||||
var eventArgs = CreatePackageOperationEventArgs(); |
||||
fakeProject.FirePackageReferenceRemovedEvent(eventArgs); |
||||
|
||||
var project = fakeScriptFactory.FakePackageUninstallScript.Project; |
||||
|
||||
Assert.AreEqual(fakeProject, project); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue