55 changed files with 1456 additions and 127 deletions
@ -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 ICSharpCode.PackageManagement.Scripting; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement |
||||||
|
{ |
||||||
|
public interface IPackageAction |
||||||
|
{ |
||||||
|
void Execute(); |
||||||
|
bool HasPackageScriptsToRun(); |
||||||
|
IPackageScriptRunner PackageScriptRunner { get; set; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
// 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 |
||||||
|
{ |
||||||
|
public interface IUpdatePackageSettings |
||||||
|
{ |
||||||
|
bool UpdateDependencies { get; set; } |
||||||
|
bool AllowPrereleaseVersions { get; set; } |
||||||
|
} |
||||||
|
} |
@ -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 System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using NuGet; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement |
||||||
|
{ |
||||||
|
public class ReducedPackageOperations |
||||||
|
{ |
||||||
|
IPackageOperationResolver resolver; |
||||||
|
IList<PackageOperation> operations; |
||||||
|
IEnumerable<IPackage> packages; |
||||||
|
|
||||||
|
public ReducedPackageOperations(IPackageOperationResolver resolver, IEnumerable<IPackage> packages) |
||||||
|
{ |
||||||
|
this.resolver = resolver; |
||||||
|
this.packages = packages; |
||||||
|
this.operations = new List<PackageOperation>(); |
||||||
|
} |
||||||
|
|
||||||
|
public IEnumerable<PackageOperation> Operations { |
||||||
|
get { return operations; } |
||||||
|
} |
||||||
|
|
||||||
|
public void Reduce() |
||||||
|
{ |
||||||
|
foreach (IPackage package in packages) { |
||||||
|
if (!InstallOperationExists(package)) { |
||||||
|
operations.AddRange(resolver.ResolveOperations(package)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
operations = operations.Reduce(); |
||||||
|
} |
||||||
|
|
||||||
|
bool InstallOperationExists(IPackage package) |
||||||
|
{ |
||||||
|
var installOperation = new PackageOperation(package, PackageAction.Install); |
||||||
|
return operations.Any(operation => IsMatch(installOperation, operation)); |
||||||
|
} |
||||||
|
|
||||||
|
bool IsMatch(PackageOperation x, PackageOperation y) |
||||||
|
{ |
||||||
|
return (x.Package.Id == y.Package.Id) && |
||||||
|
(x.Package.Version == y.Package.Version) && |
||||||
|
(x.Action == y.Action); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,85 @@ |
|||||||
|
// 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; |
||||||
|
using NuGet; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement |
||||||
|
{ |
||||||
|
public class UpdatePackagesAction : IPackageAction, IUpdatePackageSettings |
||||||
|
{ |
||||||
|
List<IPackage> packages = new List<IPackage>(); |
||||||
|
List<PackageOperation> operations = new List<PackageOperation>(); |
||||||
|
|
||||||
|
public UpdatePackagesAction(IPackageManagementProject project) |
||||||
|
{ |
||||||
|
Project = project; |
||||||
|
UpdateDependencies = true; |
||||||
|
} |
||||||
|
|
||||||
|
public IPackageScriptRunner PackageScriptRunner { get; set; } |
||||||
|
public IPackageManagementProject Project { get; private set; } |
||||||
|
|
||||||
|
public IEnumerable<IPackage> Packages { |
||||||
|
get { return packages; } |
||||||
|
} |
||||||
|
|
||||||
|
public IEnumerable<PackageOperation> Operations { |
||||||
|
get { return operations; } |
||||||
|
} |
||||||
|
|
||||||
|
public bool UpdateDependencies { get; set; } |
||||||
|
public bool AllowPrereleaseVersions { get; set; } |
||||||
|
|
||||||
|
public bool HasPackageScriptsToRun() |
||||||
|
{ |
||||||
|
var files = new PackageFilesForOperations(Operations); |
||||||
|
return files.HasAnyPackageScripts(); |
||||||
|
} |
||||||
|
|
||||||
|
public void AddOperations(IEnumerable<PackageOperation> operations) |
||||||
|
{ |
||||||
|
this.operations.AddRange(operations); |
||||||
|
} |
||||||
|
|
||||||
|
public void AddPackages(IEnumerable<IPackage> packages) |
||||||
|
{ |
||||||
|
this.packages.AddRange(packages); |
||||||
|
} |
||||||
|
|
||||||
|
public void Execute() |
||||||
|
{ |
||||||
|
if (PackageScriptRunner != null) { |
||||||
|
ExecuteWithScriptRunner(); |
||||||
|
} else { |
||||||
|
ExecuteCore(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected virtual void ExecuteCore() |
||||||
|
{ |
||||||
|
Project.UpdatePackages(this); |
||||||
|
} |
||||||
|
|
||||||
|
void ExecuteWithScriptRunner() |
||||||
|
{ |
||||||
|
using (RunPackageScriptsAction runScriptsAction = CreateRunPackageScriptsAction()) { |
||||||
|
ExecuteCore(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
RunPackageScriptsAction CreateRunPackageScriptsAction() |
||||||
|
{ |
||||||
|
return CreateRunPackageScriptsAction(PackageScriptRunner, Project); |
||||||
|
} |
||||||
|
|
||||||
|
protected virtual RunPackageScriptsAction CreateRunPackageScriptsAction( |
||||||
|
IPackageScriptRunner scriptRunner, |
||||||
|
IPackageManagementProject project) |
||||||
|
{ |
||||||
|
return new RunPackageScriptsAction(scriptRunner, project); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
// 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; |
||||||
|
|
||||||
|
namespace PackageManagement.Tests.Helpers |
||||||
|
{ |
||||||
|
public class ExceptionThrowingPackageActionRunner : FakePackageActionRunner |
||||||
|
{ |
||||||
|
public Exception ExceptionToThrow = new Exception("test"); |
||||||
|
|
||||||
|
public override void Run(IPackageAction action) |
||||||
|
{ |
||||||
|
base.Run(action); |
||||||
|
throw ExceptionToThrow; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
// 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.Design; |
||||||
|
using NuGet; |
||||||
|
|
||||||
|
namespace PackageManagement.Tests.Helpers |
||||||
|
{ |
||||||
|
public static class PackageOperationHelper |
||||||
|
{ |
||||||
|
public static PackageOperation CreateInstallOperationWithFile(string fileName) |
||||||
|
{ |
||||||
|
var package = new FakePackage(); |
||||||
|
package.AddFile(fileName); |
||||||
|
|
||||||
|
return new PackageOperation(package, PackageAction.Install); |
||||||
|
} |
||||||
|
|
||||||
|
public static List<PackageOperation> CreateListWithOneInstallOperationWithFile(string fileName) |
||||||
|
{ |
||||||
|
PackageOperation operation = CreateInstallOperationWithFile(fileName); |
||||||
|
var operations = new List<PackageOperation>(); |
||||||
|
operations.Add(operation); |
||||||
|
return operations; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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 ICSharpCode.PackageManagement; |
||||||
|
using ICSharpCode.PackageManagement.Scripting; |
||||||
|
|
||||||
|
namespace PackageManagement.Tests.Helpers |
||||||
|
{ |
||||||
|
public class TestableUpdatePackagesAction : UpdatePackagesAction |
||||||
|
{ |
||||||
|
public bool IsRunPackageScriptsActionCreated; |
||||||
|
public IPackageScriptRunner ScriptRunnerPassedToCreateRunPackageScriptsAction; |
||||||
|
public IPackageManagementProject ProjectPassedToCreateRunPackageScriptsAction; |
||||||
|
public RunPackageScriptsAction RunPackageScriptsAction; |
||||||
|
|
||||||
|
public TestableUpdatePackagesAction(IPackageManagementProject project) |
||||||
|
: base(project) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
protected override RunPackageScriptsAction CreateRunPackageScriptsAction( |
||||||
|
IPackageScriptRunner scriptRunner, |
||||||
|
IPackageManagementProject project) |
||||||
|
{ |
||||||
|
IsRunPackageScriptsActionCreated = true; |
||||||
|
ScriptRunnerPassedToCreateRunPackageScriptsAction = scriptRunner; |
||||||
|
ProjectPassedToCreateRunPackageScriptsAction = project; |
||||||
|
RunPackageScriptsAction = base.CreateRunPackageScriptsAction(scriptRunner, project); |
||||||
|
return RunPackageScriptsAction; |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsRunPackageScriptsActionDisposed { |
||||||
|
get { return RunPackageScriptsAction.IsDisposed; } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,170 @@ |
|||||||
|
// 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 System.Linq; |
||||||
|
|
||||||
|
using ICSharpCode.PackageManagement; |
||||||
|
using NuGet; |
||||||
|
using NUnit.Framework; |
||||||
|
using Rhino.Mocks; |
||||||
|
|
||||||
|
namespace PackageManagement.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class ReducedPackageOperationsTests |
||||||
|
{ |
||||||
|
ReducedPackageOperations reducedPackageOperations; |
||||||
|
IPackageOperationResolver fakePackageOperationResolver; |
||||||
|
List<IPackage> packages; |
||||||
|
|
||||||
|
void CreateReducedPackageOperations() |
||||||
|
{ |
||||||
|
packages = new List<IPackage>(); |
||||||
|
fakePackageOperationResolver = MockRepository.GenerateStub<IPackageOperationResolver>(); |
||||||
|
reducedPackageOperations = new ReducedPackageOperations(fakePackageOperationResolver, packages); |
||||||
|
} |
||||||
|
|
||||||
|
IPackage AddPackage(string id, string version) |
||||||
|
{ |
||||||
|
IPackage package = CreatePackage(id, version); |
||||||
|
packages.Add(package); |
||||||
|
|
||||||
|
return package; |
||||||
|
} |
||||||
|
|
||||||
|
IPackage CreatePackage(string id, string version) |
||||||
|
{ |
||||||
|
IPackage package = MockRepository.GenerateStub<IPackage>(); |
||||||
|
package.Stub(p => p.Id).Return(id); |
||||||
|
package.Stub(p => p.Version).Return(new SemanticVersion(version)); |
||||||
|
return package; |
||||||
|
} |
||||||
|
|
||||||
|
PackageOperation AddInstallOperationForPackage(IPackage package) |
||||||
|
{ |
||||||
|
var operation = new PackageOperation(package, PackageAction.Install); |
||||||
|
AddInstallOperationsForPackage(package, operation); |
||||||
|
return operation; |
||||||
|
} |
||||||
|
|
||||||
|
void AddInstallOperationsForPackage(IPackage package, params PackageOperation[] operations) |
||||||
|
{ |
||||||
|
fakePackageOperationResolver |
||||||
|
.Stub(resolver => resolver.ResolveOperations(package)) |
||||||
|
.Return(operations); |
||||||
|
} |
||||||
|
|
||||||
|
PackageOperation CreatePackageOperation(string id, string version, PackageAction action) |
||||||
|
{ |
||||||
|
IPackage package = CreatePackage(id, version); |
||||||
|
return new PackageOperation(package, action); |
||||||
|
} |
||||||
|
|
||||||
|
void AssertReducedOperationsContains(PackageOperation operation) |
||||||
|
{ |
||||||
|
Assert.Contains(operation, reducedPackageOperations.Operations.ToList()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Reduce_OnePackage_ReturnsPackageOperationsFromResolverForPackage() |
||||||
|
{ |
||||||
|
CreateReducedPackageOperations(); |
||||||
|
IPackage package = AddPackage("Test", "1.0"); |
||||||
|
PackageOperation operation = AddInstallOperationForPackage(package); |
||||||
|
|
||||||
|
reducedPackageOperations.Reduce(); |
||||||
|
|
||||||
|
Assert.AreEqual(1, reducedPackageOperations.Operations.Count()); |
||||||
|
Assert.AreEqual(operation, reducedPackageOperations.Operations.First()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Reduce_TwoPackages_ReturnsPackageOperationsForBothPackages() |
||||||
|
{ |
||||||
|
CreateReducedPackageOperations(); |
||||||
|
IPackage package1 = AddPackage("Test", "1.0"); |
||||||
|
IPackage package2 = AddPackage("Test2", "1.0"); |
||||||
|
PackageOperation operation1 = AddInstallOperationForPackage(package1); |
||||||
|
PackageOperation operation2 = AddInstallOperationForPackage(package2); |
||||||
|
|
||||||
|
reducedPackageOperations.Reduce(); |
||||||
|
|
||||||
|
Assert.AreEqual(2, reducedPackageOperations.Operations.Count()); |
||||||
|
AssertReducedOperationsContains(operation1); |
||||||
|
AssertReducedOperationsContains(operation2); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Reduce_OncePackageOperationInstallsPackageWhilstOneUninstallsSamePackage_PackageOperationNotIncludedInReducedSet() |
||||||
|
{ |
||||||
|
CreateReducedPackageOperations(); |
||||||
|
IPackage package = AddPackage("Test", "1.0"); |
||||||
|
PackageOperation installOperation = CreatePackageOperation("Foo", "1.0", PackageAction.Install); |
||||||
|
PackageOperation uninstallOperation = CreatePackageOperation("Foo", "1.0", PackageAction.Uninstall); |
||||||
|
AddInstallOperationsForPackage(package, installOperation, uninstallOperation); |
||||||
|
|
||||||
|
reducedPackageOperations.Reduce(); |
||||||
|
|
||||||
|
Assert.AreEqual(0, reducedPackageOperations.Operations.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Reduce_OnePackageOperationMatchesPackageBeingInstalled_ReturnsOnlyOnePackageInstallOperationForThisPackage() |
||||||
|
{ |
||||||
|
CreateReducedPackageOperations(); |
||||||
|
IPackage package1 = AddPackage("Test", "1.0"); |
||||||
|
IPackage package2 = AddPackage("Test2", "1.0"); |
||||||
|
PackageOperation operation1a = CreatePackageOperation("Test", "1.0", PackageAction.Install); |
||||||
|
PackageOperation operation1b = CreatePackageOperation("Test2", "1.0", PackageAction.Install); |
||||||
|
PackageOperation operation2 = CreatePackageOperation("Test2", "1.0", PackageAction.Install); |
||||||
|
AddInstallOperationsForPackage(package1, operation1a, operation1b); |
||||||
|
AddInstallOperationsForPackage(package2, operation2); |
||||||
|
|
||||||
|
reducedPackageOperations.Reduce(); |
||||||
|
|
||||||
|
PackageOperation operation = reducedPackageOperations |
||||||
|
.Operations |
||||||
|
.SingleOrDefault(o => o.Package.Id == "Test2"); |
||||||
|
Assert.AreEqual(2, reducedPackageOperations.Operations.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Reduce_OnePackageOperationMatchesPackageBeingInstalledOnlyById_MatchingPackageOperationByIdIncludedInSet() |
||||||
|
{ |
||||||
|
CreateReducedPackageOperations(); |
||||||
|
IPackage package1 = AddPackage("Test", "1.0"); |
||||||
|
IPackage package2 = AddPackage("Test2", "1.0"); |
||||||
|
PackageOperation operation1a = CreatePackageOperation("Test", "1.0", PackageAction.Install); |
||||||
|
PackageOperation operation1b = CreatePackageOperation("Test2", "1.1", PackageAction.Install); |
||||||
|
PackageOperation operation2 = CreatePackageOperation("Test2", "1.0", PackageAction.Install); |
||||||
|
AddInstallOperationsForPackage(package1, operation1a, operation1b); |
||||||
|
AddInstallOperationsForPackage(package2, operation2); |
||||||
|
|
||||||
|
reducedPackageOperations.Reduce(); |
||||||
|
|
||||||
|
Assert.AreEqual(3, reducedPackageOperations.Operations.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Reduce_OnePackageOperationMatchesPackageBeingInstalledByIdAndVersionButOneIsInstallAndOneIsUninstall_BothOperationsNotIncludedInSet() |
||||||
|
{ |
||||||
|
CreateReducedPackageOperations(); |
||||||
|
IPackage package1 = AddPackage("Test", "1.0"); |
||||||
|
IPackage package2 = AddPackage("Test2", "1.0"); |
||||||
|
PackageOperation operation1a = CreatePackageOperation("Test", "1.0", PackageAction.Install); |
||||||
|
PackageOperation operation1b = CreatePackageOperation("Test2", "1.0", PackageAction.Uninstall); |
||||||
|
PackageOperation operation2 = CreatePackageOperation("Test2", "1.0", PackageAction.Install); |
||||||
|
AddInstallOperationsForPackage(package1, operation1a, operation1b); |
||||||
|
AddInstallOperationsForPackage(package2, operation2); |
||||||
|
|
||||||
|
reducedPackageOperations.Reduce(); |
||||||
|
|
||||||
|
PackageOperation operation = reducedPackageOperations |
||||||
|
.Operations |
||||||
|
.SingleOrDefault(o => o.Package.Id == "Test"); |
||||||
|
Assert.AreEqual(1, reducedPackageOperations.Operations.Count()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,165 @@ |
|||||||
|
// 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; |
||||||
|
using NuGet; |
||||||
|
using NUnit.Framework; |
||||||
|
using PackageManagement.Tests.Helpers; |
||||||
|
using Rhino.Mocks; |
||||||
|
|
||||||
|
namespace PackageManagement.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class UpdatePackagesActionTests |
||||||
|
{ |
||||||
|
TestableUpdatePackagesAction action; |
||||||
|
IPackageManagementProject project; |
||||||
|
|
||||||
|
void CreateAction() |
||||||
|
{ |
||||||
|
CreateProject(); |
||||||
|
action = new TestableUpdatePackagesAction(project); |
||||||
|
} |
||||||
|
|
||||||
|
void CreateActionWithOperations(params PackageOperation[] operations) |
||||||
|
{ |
||||||
|
CreateAction(); |
||||||
|
action.AddOperations(operations); |
||||||
|
} |
||||||
|
|
||||||
|
void CreateProject() |
||||||
|
{ |
||||||
|
project = MockRepository.GenerateStub<IPackageManagementProject>(); |
||||||
|
} |
||||||
|
|
||||||
|
IPackage CreatePackage() |
||||||
|
{ |
||||||
|
return MockRepository.GenerateStub<IPackage>(); |
||||||
|
} |
||||||
|
|
||||||
|
PackageOperation CreateInstallOperationWithFile(string fileName) |
||||||
|
{ |
||||||
|
return PackageOperationHelper.CreateInstallOperationWithFile(fileName); |
||||||
|
} |
||||||
|
|
||||||
|
IPackageScriptRunner CreatePackageScriptRunner() |
||||||
|
{ |
||||||
|
return MockRepository.GenerateStub<IPackageScriptRunner>(); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void UpdateDependencies_DefaultValue_IsTrue() |
||||||
|
{ |
||||||
|
CreateActionWithOperations(); |
||||||
|
|
||||||
|
bool result = action.UpdateDependencies; |
||||||
|
|
||||||
|
Assert.IsTrue(result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void HasPackageScriptsToRun_PackageHasInitPowerShellScript_ReturnsTrue() |
||||||
|
{ |
||||||
|
PackageOperation operation = CreateInstallOperationWithFile(@"tools\install.ps1"); |
||||||
|
CreateActionWithOperations(operation); |
||||||
|
|
||||||
|
bool result = action.HasPackageScriptsToRun(); |
||||||
|
|
||||||
|
Assert.IsTrue(result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void HasPackageScriptsToRun_PackageHasOneTextFile_ReturnsFalse() |
||||||
|
{ |
||||||
|
PackageOperation operation = CreateInstallOperationWithFile(@"tools\readme.txt"); |
||||||
|
CreateActionWithOperations(operation); |
||||||
|
|
||||||
|
bool result = action.HasPackageScriptsToRun(); |
||||||
|
|
||||||
|
Assert.IsFalse(result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_UpdatePackagesAction_PackagesUpdatedUsingProject() |
||||||
|
{ |
||||||
|
CreateAction(); |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
project.AssertWasCalled(p => p.UpdatePackages(action)); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_UpdatePackagesActionWithOnePackageOperation_PackagesUpdatedUsingProject() |
||||||
|
{ |
||||||
|
PackageOperation operation = CreateInstallOperationWithFile(@"tools\readme.txt"); |
||||||
|
CreateActionWithOperations(operation); |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
project.AssertWasCalled(p => p.UpdatePackages(action)); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_PackageScriptRunnerSet_RunPackageScriptsActionCreatedUsingPackageScriptRunner() |
||||||
|
{ |
||||||
|
CreateAction(); |
||||||
|
IPackageScriptRunner expectedRunner = CreatePackageScriptRunner(); |
||||||
|
action.PackageScriptRunner = expectedRunner; |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
IPackageScriptRunner actualRunner = action.ScriptRunnerPassedToCreateRunPackageScriptsAction; |
||||||
|
Assert.AreEqual(expectedRunner, actualRunner); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_PackageScriptRunnerSet_RunPackageScriptsActionCreatedUsingProject() |
||||||
|
{ |
||||||
|
CreateAction(); |
||||||
|
action.PackageScriptRunner = CreatePackageScriptRunner(); |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
IPackageManagementProject actualProject = action.ProjectPassedToCreateRunPackageScriptsAction; |
||||||
|
Assert.AreEqual(project, actualProject); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_PackageScriptRunnerSet_RunPackageScriptsActionIsDisposed() |
||||||
|
{ |
||||||
|
CreateAction(); |
||||||
|
action.PackageScriptRunner = CreatePackageScriptRunner(); |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
Assert.IsTrue(action.IsRunPackageScriptsActionDisposed); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_NullPackageScriptRunner_RunPackageScriptsActionIsNotCreated() |
||||||
|
{ |
||||||
|
CreateAction(); |
||||||
|
action.PackageScriptRunner = null; |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
Assert.IsFalse(action.IsRunPackageScriptsActionCreated); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_NullPackageScriptRunner_PackagesAreUpdated() |
||||||
|
{ |
||||||
|
CreateAction(); |
||||||
|
PackageOperation operation = CreateInstallOperationWithFile(@"tools\readme.txt"); |
||||||
|
CreateActionWithOperations(operation); |
||||||
|
action.PackageScriptRunner = CreatePackageScriptRunner(); |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
project.AssertWasCalled(p => p.UpdatePackages(action)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue