52 changed files with 1472 additions and 116 deletions
@ -0,0 +1,61 @@ |
|||||||
|
// Copyright (c) 2015 AlphaSierraPapa for the SharpDevelop Team
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
|
// substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.PackageManagement.Scripting; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement.Design |
||||||
|
{ |
||||||
|
public class FakeReinstallPackageAction : ReinstallPackageAction |
||||||
|
{ |
||||||
|
public bool IsExecuted; |
||||||
|
|
||||||
|
public FakePackageManagementProject FakeProject; |
||||||
|
|
||||||
|
public FakeReinstallPackageAction() |
||||||
|
: this(new FakePackageManagementProject()) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public FakeReinstallPackageAction(IPackageManagementProject project) |
||||||
|
: base(project, null) |
||||||
|
{ |
||||||
|
FakeProject = project as FakePackageManagementProject; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void ExecuteCore() |
||||||
|
{ |
||||||
|
IsExecuted = true; |
||||||
|
} |
||||||
|
|
||||||
|
protected override void BeforeExecute() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
protected override RunPackageScriptsAction CreateRunPackageScriptsAction( |
||||||
|
IPackageScriptRunner scriptRunner, |
||||||
|
IPackageManagementProject project) |
||||||
|
{ |
||||||
|
return new RunPackageScriptsAction( |
||||||
|
project, |
||||||
|
scriptRunner, |
||||||
|
new PackageScriptFactory(), |
||||||
|
new NullGlobalMSBuildProjectCollection()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
//
|
||||||
|
// NullOpenPackageReadMeMonitor.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Matt Ward <matt.ward@xamarin.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement |
||||||
|
{ |
||||||
|
public class NullOpenPackageReadMeMonitor : IOpenPackageReadMeMonitor |
||||||
|
{ |
||||||
|
public static readonly IOpenPackageReadMeMonitor Null = new NullOpenPackageReadMeMonitor(); |
||||||
|
|
||||||
|
public void Dispose() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public void OpenReadMeFile() |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,70 @@ |
|||||||
|
//
|
||||||
|
// ReinstallPackageAction.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Matt Ward <matt.ward@xamarin.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.PackageManagement; |
||||||
|
using NuGet; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement |
||||||
|
{ |
||||||
|
public class ReinstallPackageAction : ProcessPackageAction |
||||||
|
{ |
||||||
|
public ReinstallPackageAction( |
||||||
|
IPackageManagementProject project, |
||||||
|
IPackageManagementEvents packageManagementEvents) |
||||||
|
: base(project, packageManagementEvents) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public bool UpdateDependencies { get; set; } |
||||||
|
|
||||||
|
protected override void ExecuteCore() |
||||||
|
{ |
||||||
|
UninstallPackage(); |
||||||
|
InstallPackage(); |
||||||
|
} |
||||||
|
|
||||||
|
void UninstallPackage() |
||||||
|
{ |
||||||
|
UninstallPackageAction action = Project.CreateUninstallPackageAction(); |
||||||
|
action.Package = Package; |
||||||
|
action.ForceRemove = true; |
||||||
|
action.RemoveDependencies = UpdateDependencies; |
||||||
|
action.Execute(); |
||||||
|
} |
||||||
|
|
||||||
|
void InstallPackage() |
||||||
|
{ |
||||||
|
InstallPackageAction action = Project.CreateInstallPackageAction(); |
||||||
|
action.Package = Package; |
||||||
|
action.OpenReadMeText = false; |
||||||
|
action.IgnoreDependencies = !UpdateDependencies; |
||||||
|
action.AllowPrereleaseVersions = !Package.IsReleaseVersion(); |
||||||
|
action.Execute(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,52 @@ |
|||||||
|
// Copyright (c) 2015 AlphaSierraPapa for the SharpDevelop Team
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
|
// substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
using System; |
||||||
|
using NUnit.Framework; |
||||||
|
using Rhino.Mocks; |
||||||
|
|
||||||
|
namespace PackageManagement.Tests.Helpers |
||||||
|
{ |
||||||
|
public class PackageRepositoryOperationInfo |
||||||
|
{ |
||||||
|
public PackageRepositoryOperationInfo(string operationName, string packageId, string packageVersion) |
||||||
|
{ |
||||||
|
Operation = MockRepository.GenerateStub<IDisposable>(); |
||||||
|
Name = operationName; |
||||||
|
PackageId = packageId; |
||||||
|
PackageVersion = packageVersion; |
||||||
|
} |
||||||
|
|
||||||
|
public IDisposable Operation { get; set; } |
||||||
|
public string Name { get; set; } |
||||||
|
public string PackageId { get; set; } |
||||||
|
public string PackageVersion{ get; set; } |
||||||
|
|
||||||
|
public void AssertOperationWasStartedAndDisposed(string expectedOperationName, string expectedMainPackageId) |
||||||
|
{ |
||||||
|
Assert.AreEqual(expectedOperationName, Name); |
||||||
|
Assert.AreEqual(expectedMainPackageId, PackageId); |
||||||
|
AssertOperationIsDisposed(); |
||||||
|
} |
||||||
|
|
||||||
|
void AssertOperationIsDisposed() |
||||||
|
{ |
||||||
|
Operation.AssertWasCalled(o => o.Dispose()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,148 @@ |
|||||||
|
//
|
||||||
|
// ReinstallPackageActionTests.cs
|
||||||
|
//
|
||||||
|
// Author:
|
||||||
|
// Matt Ward <matt.ward@xamarin.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
using ICSharpCode.PackageManagement; |
||||||
|
using ICSharpCode.PackageManagement.Design; |
||||||
|
using NuGet; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class ReinstallPackageActionTests |
||||||
|
{ |
||||||
|
ReinstallPackageAction action; |
||||||
|
PackageManagementEvents packageManagementEvents; |
||||||
|
FakePackageManagementProject project; |
||||||
|
|
||||||
|
void CreateAction(string packageId = "MyPackage", string packageVersion = "1.2.3.4") |
||||||
|
{ |
||||||
|
project = new FakePackageManagementProject(); |
||||||
|
project.AddFakeInstallOperation(); |
||||||
|
|
||||||
|
packageManagementEvents = new PackageManagementEvents(); |
||||||
|
|
||||||
|
action = new ReinstallPackageAction(project, packageManagementEvents); |
||||||
|
action.PackageId = packageId; |
||||||
|
action.PackageVersion = new SemanticVersion(packageVersion); |
||||||
|
} |
||||||
|
|
||||||
|
FakePackage AddPackageToSourceRepository(string packageId, string packageVersion) |
||||||
|
{ |
||||||
|
return project.FakeSourceRepository.AddFakePackageWithVersion(packageId, packageVersion); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_PackageExistsInSourceRepository_PackageIsUninstalled() |
||||||
|
{ |
||||||
|
CreateAction("MyPackage", "1.2.3.4"); |
||||||
|
FakePackage package = AddPackageToSourceRepository("MyPackage", "1.2.3.4"); |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
Assert.IsTrue(project.FakeUninstallPackageAction.IsExecuted); |
||||||
|
Assert.AreEqual(package, project.FakeUninstallPackageAction.Package); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_PackageExistsInSourceRepository_PackageIsInstalled() |
||||||
|
{ |
||||||
|
CreateAction("MyPackage", "1.2.3.4"); |
||||||
|
FakePackage package = AddPackageToSourceRepository("MyPackage", "1.2.3.4"); |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
Assert.IsTrue(project.LastInstallPackageCreated.IsExecuteCalled); |
||||||
|
Assert.AreEqual(package, project.LastInstallPackageCreated.Package); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_PackageExistsInSourceRepository_PackageIsForcefullyRemovedSoItDoesNotFailIfOtherPackagesDependOnIt() |
||||||
|
{ |
||||||
|
CreateAction("MyPackage", "1.2.3.4"); |
||||||
|
AddPackageToSourceRepository("MyPackage", "1.2.3.4"); |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
Assert.IsTrue(project.FakeUninstallPackageAction.ForceRemove); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_UpdateDependenciesIsFalse_PackageInstalledWithoutUpdatingDependencies() |
||||||
|
{ |
||||||
|
CreateAction("MyPackage", "1.2.3.4"); |
||||||
|
AddPackageToSourceRepository("MyPackage", "1.2.3.4"); |
||||||
|
action.UpdateDependencies = false; |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
Assert.IsTrue(project.LastInstallPackageCreated.IsExecuteCalled); |
||||||
|
Assert.IsTrue(project.LastInstallPackageCreated.IgnoreDependencies); |
||||||
|
Assert.IsFalse(project.FakeUninstallPackageAction.RemoveDependencies); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_UpdateDependenciesIsTrue_PackageInstalledWithoutIgnoringDependencies() |
||||||
|
{ |
||||||
|
CreateAction("MyPackage", "1.2.3.4"); |
||||||
|
AddPackageToSourceRepository("MyPackage", "1.2.3.4"); |
||||||
|
action.UpdateDependencies = true; |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
Assert.IsTrue(project.LastInstallPackageCreated.IsExecuteCalled); |
||||||
|
Assert.IsFalse(project.LastInstallPackageCreated.IgnoreDependencies); |
||||||
|
Assert.IsTrue(project.FakeUninstallPackageAction.RemoveDependencies); |
||||||
|
Assert.IsFalse(project.LastInstallPackageCreated.AllowPrereleaseVersions); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_PackageIsPrerelease_PackageInstalledAllowingPrereleases() |
||||||
|
{ |
||||||
|
CreateAction("MyPackage", "1.2.3-alpha1"); |
||||||
|
AddPackageToSourceRepository("MyPackage", "1.2.3-alpha1"); |
||||||
|
action.UpdateDependencies = true; |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
Assert.IsTrue(project.LastInstallPackageCreated.IsExecuteCalled); |
||||||
|
Assert.IsTrue(project.LastInstallPackageCreated.AllowPrereleaseVersions); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Execute_PackageExistsInSourceRepository_PackageIsInstalledWithoutOpeningReadmeTxt () |
||||||
|
{ |
||||||
|
CreateAction("MyPackage", "1.2.3.4"); |
||||||
|
FakePackage package = AddPackageToSourceRepository("MyPackage", "1.2.3.4"); |
||||||
|
|
||||||
|
action.Execute(); |
||||||
|
|
||||||
|
Assert.IsTrue(project.LastInstallPackageCreated.IsExecuteCalled); |
||||||
|
Assert.IsFalse(project.LastInstallPackageCreated.OpenReadMeText); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
Loading…
Reference in new issue