diff --git a/build.ps1 b/build.ps1
index 674e6d1868..adfb2811aa 100644
--- a/build.ps1
+++ b/build.ps1
@@ -1,4 +1,4 @@
-##########################################################################
+##########################################################################
# This is the Cake bootstrapper script for PowerShell.
# This file was downloaded from https://github.com/cake-build/resources
# Feel free to change this file to fit your needs.
diff --git a/src/chocolatey.console/chocolatey.console.csproj b/src/chocolatey.console/chocolatey.console.csproj
index fcefdcc500..a1d575ee1d 100644
--- a/src/chocolatey.console/chocolatey.console.csproj
+++ b/src/chocolatey.console/chocolatey.console.csproj
@@ -154,12 +154,8 @@
..\packages\log4net.2.0.12\lib\net45\log4net.dll
-
- ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll
-
-
- False
- ..\..\lib\Chocolatey-NuGet.Core.2.11.0.20220901\lib\net4\NuGet.Core.dll
+
+ ..\packages\Microsoft.Web.Xdt.3.1.0\lib\net40\Microsoft.Web.XmlTransform.dll
..\packages\SimpleInjector.2.8.3\lib\net45\SimpleInjector.dll
diff --git a/src/chocolatey.console/packages.config b/src/chocolatey.console/packages.config
index 84c493cc67..be3de666cc 100644
--- a/src/chocolatey.console/packages.config
+++ b/src/chocolatey.console/packages.config
@@ -2,6 +2,6 @@
-
+
\ No newline at end of file
diff --git a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj
index b3493c386e..6fdcae3a80 100644
--- a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj
+++ b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj
@@ -72,15 +72,32 @@
..\packages\log4net.2.0.12\lib\net45\log4net.dll
-
- ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll
+
+ ..\packages\Microsoft.Web.Xdt.3.1.0\lib\net40\Microsoft.Web.XmlTransform.dll
..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll
-
- False
- ..\..\lib\Chocolatey-NuGet.Core.2.11.0.20220901\lib\net4\NuGet.Core.dll
+
+ ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
+
+
+ ..\packages\Chocolatey.NuGet.Common.3.0.0-alpha-20221121-42\lib\net472\NuGet.Common.dll
+
+
+ ..\packages\Chocolatey.NuGet.Configuration.3.0.0-alpha-20221121-42\lib\net472\NuGet.Configuration.dll
+
+
+ ..\packages\NuGet.Frameworks.3.0.0-alpha-20221121-42\lib\net472\NuGet.Frameworks.dll
+
+
+ ..\packages\Chocolatey.NuGet.Packaging.3.0.0-alpha-20221121-42\lib\net472\NuGet.Packaging.dll
+
+
+ ..\packages\Chocolatey.NuGet.Protocol.3.0.0-alpha-20221121-42\lib\net472\NuGet.Protocol.dll
+
+
+ ..\packages\Chocolatey.NuGet.Versioning.3.0.0-alpha-20221121-42\lib\net472\NuGet.Versioning.dll
..\packages\NUnit.3.13.3\lib\net40\nunit.framework.dll
@@ -94,6 +111,10 @@
+
+
+
+
..\packages\Rx-Core.2.1.30214.0\lib\Net40\System.Reactive.Core.dll
@@ -103,6 +124,8 @@
..\packages\Rx-Linq.2.1.30214.0\lib\Net40\System.Reactive.Linq.dll
+
+
diff --git a/src/chocolatey.tests.integration/packages.config b/src/chocolatey.tests.integration/packages.config
index 9c0e7e0c0a..0cad6ce81e 100644
--- a/src/chocolatey.tests.integration/packages.config
+++ b/src/chocolatey.tests.integration/packages.config
@@ -1,8 +1,15 @@
+
+
+
+
+
-
+
+
+
diff --git a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs
index 9889aecd15..36e360c3af 100644
--- a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs
+++ b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs
@@ -1,4 +1,4 @@
-// Copyright © 2017 - 2021 Chocolatey Software, Inc
+// Copyright © 2017 - 2021 Chocolatey Software, Inc
// Copyright © 2011 - 2017 RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,7 +26,8 @@ namespace chocolatey.tests.integration.scenarios
using chocolatey.infrastructure.app.services;
using chocolatey.infrastructure.commands;
using chocolatey.infrastructure.results;
- using NuGet;
+ using NuGet.Configuration;
+ using NuGet.Packaging;
using NUnit.Framework;
using Should;
using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem;
@@ -46,8 +47,8 @@ public override void Context()
Configuration = Scenario.install();
Scenario.reset(Configuration);
Configuration.PackageNames = Configuration.Input = "installpackage";
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "badpackage.1*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "badpackage.1*" + NuGetConstants.PackageExtension);
Service = NUnitSetup.Container.GetInstance();
@@ -177,9 +178,11 @@ public void should_install_the_package_in_the_lib_directory()
[Fact]
public void should_install_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -346,10 +349,10 @@ public override void Context()
base.Context();
var packagesConfig = "{0}{1}context{1}testing.packages.config".format_with(Scenario.get_top_level(), Path.DirectorySeparatorChar);
Configuration.PackageNames = Configuration.Input = packagesConfig;
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "upgradepackage*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "upgradepackage*" + NuGetConstants.PackageExtension);
}
public override void Because()
@@ -509,9 +512,11 @@ public void should_still_have_a_package_in_the_lib_directory()
[Fact]
public void should_still_have_the_expected_version_of_the_package_installed()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -592,9 +597,11 @@ public void should_install_the_package_in_the_lib_directory()
[Fact]
public void should_install_the_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -684,9 +691,11 @@ public override void Because()
[Fact]
public void should_restore_the_backup_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -781,13 +790,16 @@ public void should_reinstall_the_package_in_the_lib_directory()
[Fact]
public void should_reinstall_the_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
[Pending("Does not work under .Net 4.8, See issue #2690")]
+ [Broken]
public void should_not_be_able_delete_the_rollback()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib-bkp", Configuration.PackageNames);
@@ -878,13 +890,14 @@ public void should_have_a_package_installed_in_the_lib_directory()
[Fact]
public void should_still_have_the_package_installed_with_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
- [Pending("Force install with file locked leaves inconsistent state - GH-114")]
public void should_delete_the_rollback()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib-bkp", Configuration.PackageNames);
@@ -905,7 +918,6 @@ public void should_contain_a_message_that_it_was_unable_to_reinstall_successfull
}
[Fact]
- [Pending("Force install with file locked leaves inconsistent state - GH-114")]
public void should_not_have_a_successful_package_result()
{
packageResult.Success.ShouldBeFalse();
@@ -918,7 +930,6 @@ public void should_have_inconclusive_package_result()
}
[Fact]
- [Pending("Force install with file locked leaves inconsistent state - GH-114")]
public void should_not_have_warning_package_result()
{
packageResult.Warning.ShouldBeFalse();
@@ -1206,7 +1217,7 @@ public override void Context()
Configuration.PackageNames = Configuration.Input = "nonterminatingerror";
Configuration.Features.FailOnStandardError = false; //the default
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension);
}
public override void Because()
@@ -1232,9 +1243,11 @@ public void should_install_the_package_in_the_lib_directory()
[Fact]
public void should_install_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.Input, Configuration.Input + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.Input, Configuration.Input + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1273,10 +1286,10 @@ public void config_should_match_package_result_name()
packageResult.Name.ShouldEqual(Configuration.Input);
}
- [Fact]
- public void should_have_a_version_of_one_dot_zero()
+ [Fact, Pending("Current version of the NuGet client library changes this to 1.0"), Broken]
+ public void should_have_a_version_of_one_dot_zero_dot_zero()
{
- packageResult.Version.ShouldEqual("1.0");
+ packageResult.Version.ShouldEqual("1.0.0");
}
}
@@ -1292,7 +1305,7 @@ public override void Context()
Configuration.PackageNames = Configuration.Input = "nonterminatingerror";
Configuration.Features.FailOnStandardError = true;
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension);
}
public override void Because()
@@ -1378,6 +1391,7 @@ public void should_have_expected_error_in_package_result()
}
}
+ [Category("Side-by-Side")]
public class when_installing_a_side_by_side_package : ScenariosBase
{
private PackageResult packageResult;
@@ -1408,6 +1422,50 @@ public void should_install_a_package_in_the_lib_directory()
DirectoryAssert.Exists(packageDir);
}
+ [Fact]
+ public void should_put_version_in_nupkg_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.0.0"),
+ (Configuration.PackageNames + ".1.0.0" + NuGetConstants.PackageExtension));
+
+ FileAssert.Exists(packageFile);
+ }
+
+ [Fact, Pending("Will be removed together with side by side removal"), Broken]
+ public void should_put_version_in_nuspec_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.0.0"),
+ (Configuration.PackageNames + ".1.0.0" + NuGetConstants.ManifestExtension));
+
+ FileAssert.Exists(packageFile);
+ }
+
+ [Fact]
+ public void should_not_have_nupkg_without_version_in_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.0.0"),
+ (Configuration.PackageNames + NuGetConstants.PackageExtension));
+
+ FileAssert.DoesNotExist(packageFile);
+ }
+
+ [Fact, Pending("Broken, will be removed together with side by side install"), Broken]
+ public void should_not_have_nuspec_without_version_in_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.0.0"),
+ (Configuration.PackageNames + NuGetConstants.ManifestExtension));
+
+ FileAssert.DoesNotExist(packageFile);
+ }
+
[Fact]
public void should_contain_a_warning_message_that_it_installed_successfully()
{
@@ -1467,6 +1525,7 @@ public void should_have_a_version_of_one_dot_zero_dot_zero()
}
}
+ [Category("Side-by-Side")]
public class when_switching_a_normal_package_to_a_side_by_side_package : ScenariosBase
{
private PackageResult packageResult;
@@ -1499,6 +1558,50 @@ public void should_install_a_package_in_the_lib_directory()
DirectoryAssert.Exists(packageDir);
}
+ [Fact]
+ public void should_put_version_in_nupkg_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.0.0"),
+ (Configuration.PackageNames + ".1.0.0" + NuGetConstants.PackageExtension));
+
+ FileAssert.Exists(packageFile);
+ }
+
+ [Fact, Pending("Should be removed together with side by side installation"), Broken]
+ public void should_put_version_in_nuspec_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.0.0"),
+ (Configuration.PackageNames + ".1.0.0" + NuGetConstants.ManifestExtension));
+
+ FileAssert.Exists(packageFile);
+ }
+
+ [Fact]
+ public void should_not_have_nupkg_without_version_in_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.0.0"),
+ (Configuration.PackageNames + NuGetConstants.PackageExtension));
+
+ FileAssert.DoesNotExist(packageFile);
+ }
+
+ [Fact, Pending("Should be removed together with side by side installation"), Broken]
+ public void should_not_have_nuspec_without_version_in_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.0.0"),
+ (Configuration.PackageNames + NuGetConstants.ManifestExtension));
+
+ FileAssert.DoesNotExist(packageFile);
+ }
+
[Fact]
public void should_contain_a_warning_message_that_it_installed_successfully()
{
@@ -1542,6 +1645,129 @@ public void should_have_a_version_of_one_dot_zero_dot_zero()
}
}
+ [Category("Side-by-Side")]
+ public class when_installing_an_older_version_side_by_side_with_a_newer_version : ScenariosBase
+ {
+ private PackageResult packageResult;
+
+ public override void Context()
+ {
+ base.Context();
+ Configuration.PackageNames = Configuration.Input = "isdependency";
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension);
+ Scenario.install_package(Configuration, "isdependency", "2.0.0");
+ Configuration.AllowMultipleVersions = true;
+ Configuration.Version = "1.1.0";
+ }
+
+ public override void Because()
+ {
+ Results = Service.install_run(Configuration);
+ packageResult = Results.FirstOrDefault().Value;
+ }
+
+ [Fact]
+ public void should_install_where_install_location_reports()
+ {
+ DirectoryAssert.Exists(packageResult.InstallLocation);
+ }
+
+ [Fact]
+ public void should_install_a_package_in_the_lib_directory()
+ {
+ var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames) + ".1.1.0";
+
+ DirectoryAssert.Exists(packageDir);
+ }
+
+ [Fact]
+ public void should_put_version_in_nupkg_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.1.0"),
+ (Configuration.PackageNames + ".1.1.0" + NuGetConstants.PackageExtension));
+
+ FileAssert.Exists(packageFile);
+ }
+
+ [Fact, Pending("Should be removed together with side by side installation"), Broken]
+ public void should_put_version_in_nuspec_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.1.0"),
+ (Configuration.PackageNames + ".1.1.0" + NuGetConstants.ManifestExtension));
+
+ FileAssert.Exists(packageFile);
+ }
+
+ [Fact]
+ public void should_not_have_nupkg_without_version_in_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.1.0"),
+ (Configuration.PackageNames + NuGetConstants.PackageExtension));
+
+ FileAssert.DoesNotExist(packageFile);
+ }
+
+ [Fact, Pending("Should be removed together with side by side installation"), Broken]
+ public void should_not_have_nuspec_without_version_in_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ (Configuration.PackageNames + ".1.1.0"),
+ (Configuration.PackageNames + NuGetConstants.ManifestExtension));
+
+ FileAssert.DoesNotExist(packageFile);
+ }
+
+ [Fact]
+ public void should_contain_a_warning_message_that_it_installed_successfully()
+ {
+ bool installedSuccessfully = false;
+ foreach (var message in MockLogger.MessagesFor(LogLevel.Warn).or_empty_list_if_null())
+ {
+ if (message.Contains("1/1")) installedSuccessfully = true;
+ }
+
+ installedSuccessfully.ShouldBeTrue();
+ }
+
+ [Fact]
+ public void should_have_a_successful_package_result()
+ {
+ packageResult.Success.ShouldBeTrue();
+ }
+
+ [Fact]
+ public void should_not_have_inconclusive_package_result()
+ {
+ packageResult.Inconclusive.ShouldBeFalse();
+ }
+
+ [Fact]
+ public void should_not_have_warning_package_result()
+ {
+ packageResult.Warning.ShouldBeFalse();
+ }
+
+ [Fact]
+ public void config_should_match_package_result_name()
+ {
+ packageResult.Name.ShouldEqual(Configuration.PackageNames);
+ }
+
+ [Fact]
+ public void should_have_a_version_of_one_dot_one_dot_zero()
+ {
+ packageResult.Version.ShouldEqual("1.1.0");
+ }
+ }
+
+ [Category("Side-by-Side")]
public class when_switching_a_side_by_side_package_to_a_normal_package : ScenariosBase
{
private PackageResult packageResult;
@@ -1575,6 +1801,58 @@ public void should_install_a_package_in_the_lib_directory()
DirectoryAssert.Exists(packageDir);
}
+ [Fact]
+ public void should_remove_version_directory_in_the_lib_directory()
+ {
+ var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames + ".1.0.0");
+
+ DirectoryAssert.DoesNotExist(packageDir);
+ }
+
+ [Fact]
+ public void should_not_put_version_in_nupkg_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ Configuration.PackageNames,
+ (Configuration.PackageNames + NuGetConstants.PackageExtension));
+
+ FileAssert.Exists(packageFile);
+ }
+
+ [Fact]
+ public void should_not_put_version_in_nuspec_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ Configuration.PackageNames,
+ (Configuration.PackageNames + NuGetConstants.ManifestExtension));
+
+ FileAssert.Exists(packageFile);
+ }
+
+ [Fact]
+ public void should_not_have_nupkg_with_version_in_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ Configuration.PackageNames,
+ (Configuration.PackageNames + ".1.0.0" + NuGetConstants.PackageExtension));
+
+ FileAssert.DoesNotExist(packageFile);
+ }
+
+ [Fact]
+ public void should_not_have_nuspec_with_version_in_filename()
+ {
+ var packageFile = Path.Combine(
+ Scenario.get_top_level(), "lib",
+ Configuration.PackageNames,
+ (Configuration.PackageNames + ".1.0.0" + NuGetConstants.ManifestExtension));
+
+ FileAssert.DoesNotExist(packageFile);
+ }
+
[Fact]
public void should_contain_a_warning_message_that_it_installed_successfully()
{
@@ -1624,9 +1902,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
}
public override void Because()
@@ -1663,8 +1941,10 @@ public void should_install_the_dependency_in_the_lib_directory()
public void should_install_the_expected_version_of_the_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1723,11 +2003,11 @@ public override void Context()
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
- Scenario.add_packages_to_source_location(Configuration, "isdependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency*" + NuGetConstants.PackageExtension);
Configuration.Force = true;
}
@@ -1756,9 +2036,11 @@ public void should_install_a_package_in_the_lib_directory()
[Fact]
public void should_reinstall_the_exact_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1773,8 +2055,10 @@ public void should_still_have_the_dependency_in_the_lib_directory()
public void should_not_upgrade_the_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1833,11 +2117,11 @@ public override void Context()
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
- Scenario.add_packages_to_source_location(Configuration, "isdependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency*" + NuGetConstants.PackageExtension);
Configuration.Force = true;
Configuration.ForceDependencies = true;
}
@@ -1867,9 +2151,11 @@ public void should_install_a_package_in_the_lib_directory()
[Fact]
public void should_reinstall_the_exact_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1884,16 +2170,20 @@ public void should_install_the_dependency_in_the_lib_directory()
public void should_reinstall_the_floating_dependency_with_the_latest_version_that_satisfies_the_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
public void should_reinstall_the_exact_same_version_of_the_exact_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1943,11 +2233,11 @@ public override void Context()
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
- Scenario.add_packages_to_source_location(Configuration, "isdependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency*" + NuGetConstants.PackageExtension);
Configuration.Force = true;
Configuration.IgnoreDependencies = true;
}
@@ -1977,9 +2267,11 @@ public void should_install_a_package_in_the_lib_directory()
[Fact]
public void should_reinstall_the_exact_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1994,16 +2286,20 @@ public void should_install_the_dependency_in_the_lib_directory()
public void should_not_touch_the_floating_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
public void should_not_touch_the_exact_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -2053,11 +2349,11 @@ public override void Context()
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
- Scenario.add_packages_to_source_location(Configuration, "isdependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency*" + NuGetConstants.PackageExtension);
Configuration.Force = true;
Configuration.ForceDependencies = true;
Configuration.IgnoreDependencies = true;
@@ -2088,9 +2384,11 @@ public void should_install_a_package_in_the_lib_directory()
[Fact]
public void should_reinstall_the_exact_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -2153,7 +2451,7 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency*" + NuGetConstants.PackageExtension);
}
public override void Because()
@@ -2263,7 +2561,7 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency*" + NuGetConstants.PackageExtension);
Configuration.IgnoreDependencies = true;
}
@@ -2290,9 +2588,11 @@ public void should_install_a_package_in_the_lib_directory()
[Fact]
public void should_install_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("2.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0");
+ }
}
[Fact]
@@ -2346,10 +2646,10 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.1.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.1.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
}
@@ -2378,9 +2678,11 @@ public void should_install_a_package_in_the_lib_directory()
[Fact]
public void should_install_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.6.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.6.0.0");
+ }
}
[Fact]
@@ -2395,8 +2697,10 @@ public void should_install_the_dependency_in_the_lib_directory()
public void should_upgrade_the_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
@@ -2445,9 +2749,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
}
@@ -2510,9 +2814,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Configuration.IgnoreDependencies = true;
}
@@ -2542,9 +2846,11 @@ public void should_install_a_package_in_the_lib_directory()
[Fact]
public void should_install_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.6.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.6.0.0");
+ }
}
[Fact]
@@ -2593,9 +2899,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.6.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Configuration.Force = true;
Configuration.ForceDependencies = true;
@@ -2618,8 +2924,10 @@ public void should_not_install_a_package_in_the_lib_directory()
public void should_not_upgrade_the_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -2706,10 +3014,10 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "conflictingdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.1.0.1*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.1.0.1*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1.0.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
}
@@ -2740,8 +3048,10 @@ public void should_install_a_package_in_the_lib_directory()
public void should_upgrade_the_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.1.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.1.0");
+ }
}
[Fact]
@@ -2790,10 +3100,10 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "conflictingdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.2.1.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.2.1.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
}
@@ -2804,17 +3114,15 @@ public override void Because()
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_install_the_conflicting_package()
{
foreach (var packageResult in Results)
{
- DirectoryAssert.Exists(packageResult.Value.InstallLocation);
+ DirectoryAssert.DoesNotExist(packageResult.Value.InstallLocation);
}
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_install_the_conflicting_package_in_the_lib_directory()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames);
@@ -2823,25 +3131,26 @@ public void should_not_install_the_conflicting_package_in_the_lib_directory()
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_upgrade_the_minimum_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_upgrade_the_exact_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
- [Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
+ [Fact, Broken]
public void should_contain_a_message_that_it_was_unable_to_install_any_packages()
{
bool expectedMessage = false;
@@ -2854,7 +3163,6 @@ public void should_contain_a_message_that_it_was_unable_to_install_any_packages(
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_have_a_successful_package_result()
{
foreach (var packageResult in Results)
@@ -2864,7 +3172,6 @@ public void should_not_have_a_successful_package_result()
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_have_inconclusive_package_result()
{
foreach (var packageResult in Results)
@@ -2874,7 +3181,6 @@ public void should_not_have_inconclusive_package_result()
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_have_warning_package_result()
{
foreach (var packageResult in Results)
@@ -2884,7 +3190,6 @@ public void should_not_have_warning_package_result()
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_have_an_error_package_result()
{
bool errorFound = false;
@@ -2910,10 +3215,10 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.2.1.0*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.2.1.0*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "conflictingdependency", "2.1.0");
}
@@ -2930,7 +3235,6 @@ public override void Because()
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_install_the_conflicting_package_in_the_lib_directory()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames);
@@ -2939,16 +3243,16 @@ public void should_not_install_the_conflicting_package_in_the_lib_directory()
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
- public void should_not_upgrade_the_exact_version_dependency()
+ public void should_not_downgrade_the_exact_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0");
+ }
}
- [Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
+ [Fact, Broken]
public void should_contain_a_message_that_it_was_unable_to_install_any_packages()
{
bool expectedMessage = false;
@@ -2961,7 +3265,6 @@ public void should_contain_a_message_that_it_was_unable_to_install_any_packages(
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_have_a_successful_package_result()
{
foreach (var packageResult in Results)
@@ -2971,7 +3274,6 @@ public void should_not_have_a_successful_package_result()
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_have_inconclusive_package_result()
{
foreach (var packageResult in Results)
@@ -2981,7 +3283,6 @@ public void should_not_have_inconclusive_package_result()
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_not_have_warning_package_result()
{
foreach (var packageResult in Results)
@@ -2991,7 +3292,6 @@ public void should_not_have_warning_package_result()
}
[Fact]
- [Pending("NuGet does not deal with version conflicts - GH-116")]
public void should_have_an_error_package_result()
{
bool errorFound = false;
@@ -3017,9 +3317,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "toplevelhasexactversiondependency";
- Scenario.add_packages_to_source_location(Configuration, "toplevelhasexactversiondependency*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "childdependencywithlooserversiondependency*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "toplevelhasexactversiondependency*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "childdependencywithlooserversiondependency*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
}
public override void Because()
@@ -3035,7 +3335,6 @@ public override void Because()
*/
[Fact]
- [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")]
public void should_install_where_install_location_reports()
{
foreach (var packageResult in Results)
@@ -3045,7 +3344,6 @@ public void should_install_where_install_location_reports()
}
[Fact]
- [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")]
public void should_install_a_package_in_the_lib_directory()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames);
@@ -3054,7 +3352,6 @@ public void should_install_a_package_in_the_lib_directory()
}
[Fact]
- [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")]
public void should_install_the_dependency_in_the_lib_directory()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib", "childdependencywithlooserversiondependency");
@@ -3063,25 +3360,26 @@ public void should_install_the_dependency_in_the_lib_directory()
}
[Fact]
- [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")]
public void should_install_the_expected_version_of_the_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "childdependencywithlooserversiondependency", "childdependencywithlooserversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
- [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")]
public void should_install_the_expected_version_of_the_constrained_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
- [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")]
public void should_contain_a_message_that_everything_installed_successfully()
{
bool expectedMessage = false;
@@ -3094,7 +3392,6 @@ public void should_contain_a_message_that_everything_installed_successfully()
}
[Fact]
- [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")]
public void should_have_a_successful_package_result()
{
foreach (var packageResult in Results)
@@ -3104,7 +3401,6 @@ public void should_have_a_successful_package_result()
}
[Fact]
- [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")]
public void should_not_have_inconclusive_package_result()
{
foreach (var packageResult in Results)
@@ -3114,7 +3410,6 @@ public void should_not_have_inconclusive_package_result()
}
[Fact]
- [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")]
public void should_not_have_warning_package_result()
{
foreach (var packageResult in Results)
@@ -3157,9 +3452,11 @@ public void should_install_the_package_in_the_lib_directory()
[Fact]
public void should_install_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "installpackage", "installpackage" + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "installpackage", "installpackage" + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -3321,7 +3618,7 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "upgradepackage";
- Scenario.add_packages_to_source_location(Configuration, "upgradepackage.1.0.0*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "upgradepackage.1.0.0*" + NuGetConstants.PackageExtension);
_xmlFilePath = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, "tools", "console.exe.config");
}
@@ -3337,9 +3634,11 @@ public override void Because()
[Fact]
public void should_install_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -3429,7 +3728,7 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "scriptpackage.hook";
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".1.0.0" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".1.0.0" + NuGetConstants.PackageExtension);
}
private PackageResult _packageResult;
@@ -3451,9 +3750,11 @@ public void should_install_the_package_in_the_lib_directory()
[Fact]
public void should_install_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -3534,7 +3835,7 @@ public class when_installing_a_package_happy_path_with_hook_scripts : ScenariosB
public override void Context()
{
base.Context();
- Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "scriptpackage.hook", "1.0.0");
Configuration.PackageNames = Configuration.Input = "installpackage";
}
@@ -3562,9 +3863,11 @@ public void should_install_the_package_in_the_lib_directory()
[Fact]
public void should_install_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -3787,10 +4090,10 @@ public class when_installing_a_portable_package_happy_path_with_hook_scripts : S
public override void Context()
{
base.Context();
- Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + ".1.0.0" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + ".1.0.0" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "scriptpackage.hook", "1.0.0");
Configuration.PackageNames = Configuration.Input = "portablepackage";
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension);
}
public override void Because()
@@ -3816,9 +4119,11 @@ public void should_install_the_package_in_the_lib_directory()
[Fact]
public void should_install_the_expected_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
diff --git a/src/chocolatey.tests.integration/scenarios/ListScenarios.cs b/src/chocolatey.tests.integration/scenarios/ListScenarios.cs
index 4cb749e00d..6bdc38c039 100644
--- a/src/chocolatey.tests.integration/scenarios/ListScenarios.cs
+++ b/src/chocolatey.tests.integration/scenarios/ListScenarios.cs
@@ -23,7 +23,7 @@ namespace chocolatey.tests.integration.scenarios
using chocolatey.infrastructure.app.configuration;
using chocolatey.infrastructure.app.services;
using chocolatey.infrastructure.results;
- using NuGet;
+ using NuGet.Configuration;
using NUnit.Framework;
using Should;
@@ -40,8 +40,8 @@ public override void Context()
{
Configuration = Scenario.list();
Scenario.reset(Configuration);
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "installpackage*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "installpackage*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "installpackage", "1.0.0");
Scenario.install_package(Configuration, "upgradepackage", "1.0.0");
@@ -438,7 +438,7 @@ public override void Context()
{
Configuration = Scenario.list();
Scenario.reset(Configuration);
- Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + NuGetConstants.PackageExtension);
Service = NUnitSetup.Container.GetInstance();
Configuration.ListCommand.Exact = true;
@@ -497,7 +497,7 @@ public override void Context()
{
Configuration = Scenario.list();
Scenario.reset(Configuration);
- Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + NuGetConstants.PackageExtension);
Service = NUnitSetup.Container.GetInstance();
Configuration.ListCommand.Exact = true;
@@ -552,7 +552,7 @@ public override void Context()
{
Configuration = Scenario.list();
Scenario.reset(Configuration);
- Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + NuGetConstants.PackageExtension);
Service = NUnitSetup.Container.GetInstance();
Configuration.ListCommand.Exact = true;
@@ -581,15 +581,15 @@ public void should_find_two_results()
[Fact]
public void should_find_only_packages_with_exact_id()
{
- Results[0].Package.Id.ShouldEqual("exactpackage");
- Results[1].Package.Id.ShouldEqual("exactpackage");
+ Results[0].PackageMetadata.Id.ShouldEqual("exactpackage");
+ Results[1].PackageMetadata.Id.ShouldEqual("exactpackage");
}
[Fact]
public void should_find_all_non_prerelease_versions_in_descending_order()
{
- Results[0].Package.Version.ToNormalizedString().ShouldEqual("1.0.0");
- Results[1].Package.Version.ToNormalizedString().ShouldEqual("0.9.0");
+ Results[0].PackageMetadata.Version.ToNormalizedString().ShouldEqual("1.0.0");
+ Results[1].PackageMetadata.Version.ToNormalizedString().ShouldEqual("0.9.0");
}
}
@@ -599,7 +599,7 @@ public override void Context()
{
Configuration = Scenario.list();
Scenario.reset(Configuration);
- Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + NuGetConstants.PackageExtension);
Service = NUnitSetup.Container.GetInstance();
Configuration.ListCommand.Exact = true;
@@ -629,17 +629,17 @@ public void should_find_three_results()
[Fact]
public void should_find_only_packages_with_exact_id()
{
- Results[0].Package.Id.ShouldEqual("exactpackage");
- Results[1].Package.Id.ShouldEqual("exactpackage");
- Results[2].Package.Id.ShouldEqual("exactpackage");
+ Results[0].PackageMetadata.Id.ShouldEqual("exactpackage");
+ Results[1].PackageMetadata.Id.ShouldEqual("exactpackage");
+ Results[2].PackageMetadata.Id.ShouldEqual("exactpackage");
}
[Fact]
public void should_find_all_versions_in_descending_order()
{
- Results[0].Package.Version.ToNormalizedString().ShouldEqual("1.0.0");
- Results[1].Package.Version.ToNormalizedString().ShouldEqual("1.0.0-beta1");
- Results[2].Package.Version.ToNormalizedString().ShouldEqual("0.9.0");
+ Results[0].PackageMetadata.Version.ToNormalizedString().ShouldEqual("1.0.0");
+ Results[1].PackageMetadata.Version.ToNormalizedString().ShouldEqual("1.0.0-beta1");
+ Results[2].PackageMetadata.Version.ToNormalizedString().ShouldEqual("0.9.0");
}
}
}
diff --git a/src/chocolatey.tests.integration/scenarios/PinScenarios.cs b/src/chocolatey.tests.integration/scenarios/PinScenarios.cs
index 4dfc339120..7c17f7a6f6 100644
--- a/src/chocolatey.tests.integration/scenarios/PinScenarios.cs
+++ b/src/chocolatey.tests.integration/scenarios/PinScenarios.cs
@@ -26,10 +26,10 @@ namespace chocolatey.tests.integration.scenarios
using chocolatey.infrastructure.app.domain;
using chocolatey.infrastructure.commands;
using chocolatey.infrastructure.results;
- using NuGet;
using NUnit.Framework;
+ using NuGet.Configuration;
using Should;
public class PinScenarios
@@ -45,8 +45,8 @@ public override void Context()
{
Configuration = Scenario.pin();
Scenario.reset(Configuration);
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "installpackage*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "installpackage*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "installpackage", "1.0.0");
Scenario.install_package(Configuration, "upgradepackage", "1.0.0");
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
diff --git a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs
index 0707905fd4..c624bfd56a 100644
--- a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs
+++ b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs
@@ -1,4 +1,4 @@
-// Copyright © 2017 - 2021 Chocolatey Software, Inc
+// Copyright © 2017 - 2021 Chocolatey Software, Inc
// Copyright © 2011 - 2017 RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,7 +26,7 @@ namespace chocolatey.tests.integration.scenarios
using chocolatey.infrastructure.commands;
using chocolatey.infrastructure.filesystem;
using chocolatey.infrastructure.results;
- using NuGet;
+ using NuGet.Configuration;
using NUnit.Framework;
using Should;
using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem;
@@ -46,9 +46,9 @@ public override void Context()
Configuration = Scenario.uninstall();
Scenario.reset(Configuration);
Configuration.PackageNames = Configuration.Input = "installpackage";
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "installpackage", "1.0.0");
- Scenario.add_packages_to_source_location(Configuration, "badpackage*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "badpackage*" + NuGetConstants.PackageExtension);
Configuration.SkipPackageInstallProvider = true;
Scenario.install_package(Configuration, "badpackage", "1.0");
Configuration.SkipPackageInstallProvider = false;
@@ -455,6 +455,7 @@ public void should_uninstall_the_package_from_the_lib_directory()
[Fact]
[Pending("Does not work under .Net 4.8, See issue #2690")]
+ [Broken]
public void should_not_be_able_delete_the_rollback()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib-bkp", Configuration.PackageNames);
@@ -990,8 +991,8 @@ public void should_not_remove_package_from_the_lib_directory()
[Fact]
public void should_still_have_the_package_file_in_the_directory()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- File.Exists(packageFile).ShouldBeTrue();
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ FileAssert.Exists(packageFile);
}
[Fact]
@@ -1080,7 +1081,7 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "scriptpackage.hook";
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".1.0.0" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".1.0.0" + NuGetConstants.PackageExtension);
Service.install_run(Configuration);
}
@@ -1158,7 +1159,7 @@ public class when_uninstalling_a_package_happy_path_with_hooks : ScenariosBase
public override void Context()
{
base.Context();
- Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "scriptpackage.hook", "1.0.0");
}
diff --git a/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs b/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs
index 7048d7d0bf..221ae75c30 100644
--- a/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs
+++ b/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs
@@ -28,7 +28,8 @@ namespace chocolatey.tests.integration.scenarios
using chocolatey.infrastructure.app.services;
using chocolatey.infrastructure.filesystem;
using chocolatey.infrastructure.results;
- using NuGet;
+ using NuGet.Configuration;
+ using NuGet.Packaging;
using NUnit.Framework;
using Should;
@@ -46,9 +47,9 @@ public override void Context()
Configuration = Scenario.upgrade();
Scenario.reset(Configuration);
Configuration.PackageNames = Configuration.Input = "upgradepackage";
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "installpackage*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "badpackage*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + "*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "installpackage*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "badpackage*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "installpackage", "1.0.0");
Scenario.install_package(Configuration, "upgradepackage", "1.0.0");
Configuration.SkipPackageInstallProvider = true;
@@ -242,9 +243,11 @@ public void should_contain_newer_version_in_directory()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
@@ -400,9 +403,11 @@ public void should_not_remove_the_package_from_the_lib_directory()
[Fact]
public void should_be_the_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
@@ -479,10 +484,12 @@ public void should_contain_newer_version_in_directory()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.1.0");
- package.Version.to_string().ShouldEqual("1.1.1-beta2");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.1.0");
+ packageReader.NuspecReader.GetVersion().OriginalVersion.to_string().ShouldEqual("1.1.1-beta2");
+ }
}
[Fact]
@@ -630,10 +637,12 @@ public void should_contain_newer_version_in_directory()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.1.0");
- package.Version.to_string().ShouldEqual("1.1.1-beta2");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.1.0");
+ packageReader.NuspecReader.GetVersion().OriginalVersion.to_string().ShouldEqual("1.1.1-beta2");
+ }
}
[Fact]
@@ -792,9 +801,11 @@ public void should_not_remove_the_package_from_the_lib_directory()
[Fact]
public void should_be_the_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.1.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.1.0");
+ }
}
[Fact]
@@ -885,9 +896,11 @@ public void should_not_remove_the_package_from_the_lib_directory()
[Fact]
public void should_be_the_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.1.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.1.0");
+ }
}
[Fact]
@@ -948,9 +961,11 @@ public void should_upgrade_a_package_in_the_lib_directory()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
@@ -1083,9 +1098,11 @@ public void should_not_remove_the_package_from_the_lib_directory()
[Fact]
public void should_be_the_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1173,9 +1190,11 @@ public void should_not_remove_the_package_from_the_lib_directory()
[Fact]
public void should_be_the_same_version_of_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1262,9 +1281,11 @@ public void should_upgrade_a_package_in_the_lib_directory()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
@@ -1371,13 +1392,16 @@ public void should_upgrade_a_package_in_the_lib_directory()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
[Pending("Does not work under .Net 4.8, See issue #2690")]
+ [Broken]
public void should_not_be_able_delete_the_rollback()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib-bkp", Configuration.PackageNames);
@@ -1491,9 +1515,11 @@ public void should_contain_old_version_in_directory()
[Fact]
public void should_not_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1575,9 +1601,11 @@ public void should_contain_newer_version_in_directory()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
@@ -1653,9 +1681,11 @@ public void should_contain_newer_version_in_directory()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
@@ -1980,9 +2010,11 @@ public void should_not_remove_package_from_the_lib_directory()
[Fact]
public void should_not_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -1996,9 +2028,11 @@ public void should_put_the_package_in_the_lib_bad_directory()
[Fact]
public void should_have_the_erroring_upgraded_package_in_the_lib_bad_directory()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib-bad", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("2.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib-bad", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0");
+ }
}
[Fact]
@@ -2076,9 +2110,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
}
@@ -2092,24 +2126,30 @@ public override void Because()
public void should_upgrade_the_package()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("2.1.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0");
+ }
}
[Fact]
public void should_upgrade_the_minimum_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("2.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0");
+ }
}
[Fact]
public void should_upgrade_the_exact_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("2.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0");
+ }
}
[Fact]
@@ -2158,9 +2198,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency.1*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency.1*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
}
@@ -2174,24 +2214,30 @@ public override void Because()
public void should_not_upgrade_the_package()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
public void should_not_upgrade_the_minimum_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
public void should_not_upgrade_the_exact_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -2278,9 +2324,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "hasdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency.1*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency.1*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
Configuration.IgnoreDependencies = true;
@@ -2295,24 +2341,30 @@ public override void Because()
public void should_upgrade_the_package()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("2.1.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0");
+ }
}
[Fact]
public void should_not_upgrade_the_minimum_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
public void should_not_upgrade_the_exact_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -2361,9 +2413,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "isdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
}
@@ -2377,24 +2429,30 @@ public override void Because()
public void should_upgrade_the_package()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
public void should_not_upgrade_the_parent_package()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
public void should_not_upgrade_the_exact_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -2443,9 +2501,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "isdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.1*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.1*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Configuration.AllowMultipleVersions = true;
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
@@ -2475,8 +2533,10 @@ public override void Because()
public void should_upgrade_the_package()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
@@ -2497,8 +2557,10 @@ public void should_replace_the_legacy_folder_version_of_the_package_with_a_lib_p
public void should_not_upgrade_the_parent_package()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency.1.0.0", "hasdependency.1.0.0.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -2519,8 +2581,10 @@ public void should_leave_the_parent_package_as_legacy_folder()
public void should_not_upgrade_the_exact_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency.1.0.0", "isexactversiondependency.1.0.0.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.0.0.0");
+ }
}
[Fact]
@@ -2583,9 +2647,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "isdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
}
@@ -2599,24 +2663,30 @@ public override void Because()
public void should_upgrade_the_package()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("2.1.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0");
+ }
}
[Fact]
- public void should_upgrade_the_parent_package_to_lowest_version_that_meets_new_dependency_version()
+ public void should_upgrade_the_parent_package_to_highest_version_that_meets_new_dependency_version()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.1.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0");
+ }
}
[Fact]
public void should_upgrade_the_exact_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.1.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0");
+ }
}
[Fact]
@@ -2665,9 +2735,9 @@ public override void Context()
{
base.Context();
Configuration.PackageNames = Configuration.Input = "isdependency";
- Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension);
- Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "hasdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + NuGetConstants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + NuGetConstants.PackageExtension);
Configuration.AllowMultipleVersions = true;
Scenario.install_package(Configuration, "isdependency", "1.0.0");
Scenario.install_package(Configuration, "hasdependency", "1.0.0");
@@ -2689,8 +2759,10 @@ public override void Because()
public void should_upgrade_the_package()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isdependency", "isdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("2.1.0.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0");
+ }
}
[Fact]
@@ -2708,11 +2780,13 @@ public void should_replace_the_legacy_folder_version_of_the_package_with_a_lib_p
}
[Fact]
- public void should_upgrade_the_parent_package_to_lowest_version_that_meets_new_dependency_version()
+ public void should_upgrade_the_parent_package_to_highest_version_that_meets_new_dependency_version()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency", "hasdependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.1.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.1.0.0");
+ }
}
[Fact]
@@ -2723,7 +2797,7 @@ public void should_replace_the_legacy_folder_version_of_the_parent_package_with_
}
[Fact]
- [Pending("Legacy packages are left when implicit - GH-117")]
+ //[Pending("Legacy packages are left when implicit - GH-117")]
public void should_remove_the_legacy_folder_version_of_the_parent_package()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib", "hasdependency.1.0.0");
@@ -2734,8 +2808,10 @@ public void should_remove_the_legacy_folder_version_of_the_parent_package()
public void should_upgrade_the_exact_version_dependency()
{
var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg");
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.0.1.0");
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0");
+ }
}
[Fact]
@@ -2746,7 +2822,7 @@ public void should_replace_the_legacy_folder_version_of_the_exact_version_packag
}
[Fact]
- [Pending("Legacy packages are left when implicit - GH-117")]
+ //[Pending("Legacy packages are left when implicit - GH-117")]
public void should_remove_the_legacy_folder_version_of_the_exact_version_package()
{
var packageDir = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency.1.0.0");
@@ -2818,9 +2894,11 @@ public override void Because()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
@@ -2916,9 +2994,11 @@ public override void Because()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
@@ -3087,9 +3167,11 @@ public void should_upgrade_packages_with_upgrades()
[Fact]
public void should_upgrade_upgradepackage()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "upgradepackage", "upgradepackage" + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.to_string().ShouldEqual("1.1.1-beta2");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "upgradepackage", "upgradepackage" + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().OriginalVersion.ShouldEqual("1.1.1-beta2");
+ }
}
[Fact]
@@ -3137,9 +3219,11 @@ public void should_upgrade_packages_with_upgrades()
[Fact]
public void should_not_upgrade_upgradepackage()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "upgradepackage", "upgradepackage" + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.to_string().ShouldEqual("1.1.1-beta");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "upgradepackage", "upgradepackage" + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().OriginalVersion.to_string().ShouldEqual("1.1.1-beta");
+ }
}
[Fact]
@@ -3187,10 +3271,10 @@ public class when_upgrading_an_existing_hook_package : ScenariosBase
public override void Context()
{
base.Context();
- Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + ".1.0.0" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + ".1.0.0" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "scriptpackage.hook", "1.0.0");
Configuration.PackageNames = Configuration.Input = "scriptpackage.hook";
- Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".2.0.0" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, Configuration.Input + ".2.0.0" + NuGetConstants.PackageExtension);
}
public override void Because()
@@ -3224,9 +3308,11 @@ public void should_delete_the_rollback()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("2.0.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("2.0.0.0");
+ }
}
[Fact]
@@ -3324,7 +3410,7 @@ public class when_upgrading_an_existing_package_happy_path_with_hooks : Scenario
public override void Context()
{
base.Context();
- Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + Constants.PackageExtension);
+ Scenario.add_packages_to_source_location(Configuration, "scriptpackage.hook" + "*" + NuGetConstants.PackageExtension);
Scenario.install_package(Configuration, "scriptpackage.hook", "1.0.0");
Configuration.PackageNames = Configuration.Input = "upgradepackage";
}
@@ -3368,9 +3454,11 @@ public void should_contain_newer_version_in_directory()
[Fact]
public void should_upgrade_the_package()
{
- var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + Constants.PackageExtension);
- var package = new OptimizedZipPackage(packageFile);
- package.Version.Version.to_string().ShouldEqual("1.1.0.0");
+ var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension);
+ using (var packageReader = new PackageArchiveReader(packageFile))
+ {
+ packageReader.NuspecReader.GetVersion().Version.to_string().ShouldEqual("1.1.0.0");
+ }
}
[Fact]
diff --git a/src/chocolatey.tests/TinySpec.cs b/src/chocolatey.tests/TinySpec.cs
index 6385838b4d..bf04bcea08 100644
--- a/src/chocolatey.tests/TinySpec.cs
+++ b/src/chocolatey.tests/TinySpec.cs
@@ -1,4 +1,4 @@
-// ==============================================================================
+// ==============================================================================
//
// Fervent Coder Copyright © 2011 - Released under the Apache 2.0 License
//
@@ -147,6 +147,15 @@ public PendingAttribute(string reason)
}
}
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
+ public class BrokenAttribute : CategoryAttribute
+ {
+ public BrokenAttribute()
+ : base("Broken")
+ {
+ }
+ }
+
public class WindowsOnlyAttribute : PlatformAttribute
{
public WindowsOnlyAttribute()
diff --git a/src/chocolatey.tests/chocolatey.tests.csproj b/src/chocolatey.tests/chocolatey.tests.csproj
index 7ae3ba348f..bd52b6393e 100644
--- a/src/chocolatey.tests/chocolatey.tests.csproj
+++ b/src/chocolatey.tests/chocolatey.tests.csproj
@@ -71,15 +71,32 @@
..\packages\log4net.2.0.12\lib\net45\log4net.dll
-
- ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll
+
+ ..\packages\Microsoft.Web.Xdt.3.1.0\lib\net40\Microsoft.Web.XmlTransform.dll
..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll
-
- False
- ..\..\lib\Chocolatey-NuGet.Core.2.11.0.20220901\lib\net4\NuGet.Core.dll
+
+ ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
+
+
+ ..\packages\Chocolatey.NuGet.Common.3.0.0-alpha-20221121-42\lib\net472\NuGet.Common.dll
+
+
+ ..\packages\Chocolatey.NuGet.Configuration.3.0.0-alpha-20221121-42\lib\net472\NuGet.Configuration.dll
+
+
+ ..\packages\NuGet.Frameworks.3.0.0-alpha-20221121-42\lib\net472\NuGet.Frameworks.dll
+
+
+ ..\packages\Chocolatey.NuGet.Packaging.3.0.0-alpha-20221121-42\lib\net472\NuGet.Packaging.dll
+
+
+ ..\packages\Chocolatey.NuGet.Protocol.3.0.0-alpha-20221121-42\lib\net472\NuGet.Protocol.dll
+
+
+ ..\packages\Chocolatey.NuGet.Versioning.3.0.0-alpha-20221121-42\lib\net472\NuGet.Versioning.dll
..\packages\NUnit.3.13.3\lib\net40\nunit.framework.dll
@@ -93,6 +110,12 @@
+
+
+
+
+
+
diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs
index 303785a46b..fbec89b3bb 100644
--- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs
+++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs
@@ -28,7 +28,12 @@ namespace chocolatey.tests.infrastructure.app.commands
using chocolatey.infrastructure.commandline;
using chocolatey.infrastructure.results;
using Moq;
- using NuGet;
+ using NuGet.Common;
+ using NuGet.Packaging;
+ using NuGet.Versioning;
+
+ using NUnit.Framework;
+
using Should;
public class ChocolateyPinCommandSpecs
@@ -41,27 +46,27 @@ public abstract class ChocolateyPinCommandSpecsBase : TinySpec
protected Mock nugetLogger = new Mock();
protected Mock nugetService = new Mock();
protected ChocolateyConfiguration configuration = new ChocolateyConfiguration();
- protected Mock package = new Mock();
- protected Mock pinnedPackage = new Mock();
+ protected Mock package = new Mock();
+ protected Mock pinnedPackage = new Mock();
public override void Context()
{
- // MockLogger = new MockLogger();
- // Log.InitializeWith(MockLogger);
+ //MockLogger = new MockLogger();
+ //Log.InitializeWith(MockLogger);
configuration.Sources = "https://localhost/somewhere/out/there";
command = new ChocolateyPinCommand(packageInfoService.Object, nugetLogger.Object, nugetService.Object);
- package = new Mock();
+ package = new Mock();
package.Setup(p => p.Id).Returns("regular");
- package.Setup(p => p.Version).Returns(new SemanticVersion("1.2.0"));
+ package.Setup(p => p.Version).Returns(new NuGetVersion("1.2.0"));
packageInfoService.Setup(s => s.get_package_information(package.Object)).Returns(
new ChocolateyPackageInformation(package.Object)
{
IsPinned = false
});
- pinnedPackage = new Mock();
+ pinnedPackage = new Mock();
pinnedPackage.Setup(p => p.Id).Returns("pinned");
- pinnedPackage.Setup(p => p.Version).Returns(new SemanticVersion("1.1.0"));
+ pinnedPackage.Setup(p => p.Version).Returns(new NuGetVersion("1.1.0"));
packageInfoService.Setup(s => s.get_package_information(pinnedPackage.Object)).Returns(
new ChocolateyPackageInformation(pinnedPackage.Object)
{
@@ -330,7 +335,7 @@ public void should_log_a_message()
[Fact]
public void should_log_the_message_we_expect()
{
- var messages = MockLogger.MessagesFor(LogLevel.Info);
+ var messages = MockLogger.MessagesFor(tests.LogLevel.Info);
messages.ShouldNotBeEmpty();
messages.Count.ShouldEqual(1);
messages[0].ShouldContain("Pin would have called");
@@ -387,8 +392,6 @@ public void should_log_one_message()
public class when_run_is_called : ChocolateyPinCommandSpecsBase
{
//private Action because;
- private readonly Mock packageManager = new Mock();
- private readonly Mock localRepository = new Mock();
public override void Context()
{
@@ -425,37 +428,38 @@ public void should_call_nuget_service_list_run_when_command_is_list()
nugetService.Verify(n => n.list_run(It.IsAny()), Times.Once);
}
- [Pending("NuGet is killing me with extension methods. Need to find proper item to mock out to return the package object.")]
+ [Pending("NuGet is killing me with extension methods. Need to find proper item to mock out to return the package object."), Category("Pending")]
[Fact]
public void should_set_pin_when_command_is_add()
{
reset();
configuration.PinCommand.Name = "regular";
- packageManager.Setup(pm => pm.LocalRepository).Returns(localRepository.Object);
- SemanticVersion semanticVersion = null;
+ //packageManager.Setup(pm => pm.LocalRepository).Returns(localRepository.Object);
+ NuGetVersion nugetVersion = null;
//nuget woes
- localRepository.Setup(r => r.FindPackage(configuration.PinCommand.Name, semanticVersion)).Returns(package.Object);
+ //localRepository.Setup(r => r.FindPackage(configuration.PinCommand.Name, nugetVersion)).Returns(package.Object);
configuration.PinCommand.Command = PinCommandType.add;
- command.set_pin(packageManager.Object, configuration);
+ //command.set_pin(packageManager.Object, configuration);
packageInfoService.Verify(s => s.save_package_information(It.IsAny()), Times.Once);
}
- [Pending("NuGet is killing me with extension methods. Need to find proper item to mock out to return the package object.")]
+ [Pending("NuGet is killing me with extension methods. Need to find proper item to mock out to return the package object."), Category("Pending")]
[Fact]
public void should_remove_pin_when_command_is_remove()
{
reset();
configuration.PinCommand.Name = "pinned";
- packageManager.Setup(pm => pm.LocalRepository).Returns(localRepository.Object);
+ // packageManager.Setup(pm => pm.LocalRepository).Returns(localRepository.Object);
configuration.PinCommand.Command = PinCommandType.remove;
- command.set_pin(packageManager.Object, configuration);
+ //command.set_pin(packageManager.Object, configuration);
packageInfoService.Verify(s => s.save_package_information(It.IsAny()), Times.Once);
}
}
+
}
}
diff --git a/src/chocolatey.tests/infrastructure.app/configuration/ConfigurationOptionsSpec.cs b/src/chocolatey.tests/infrastructure.app/configuration/ConfigurationOptionsSpec.cs
index c47a3efcce..240bb438e3 100644
--- a/src/chocolatey.tests/infrastructure.app/configuration/ConfigurationOptionsSpec.cs
+++ b/src/chocolatey.tests/infrastructure.app/configuration/ConfigurationOptionsSpec.cs
@@ -92,7 +92,7 @@ public void should_not_have_set_other_options_by_default()
because();
}
- [Fact, Explicit]
+ [Fact]
public void should_show_help_menu_when_help_is_requested()
{
args.Add("-h");
@@ -102,7 +102,7 @@ public void should_show_help_menu_when_help_is_requested()
config.HelpRequested.ShouldBeTrue();
}
- [Fact, Explicit]
+ [Fact]
public void should_have_a_helpMessage_with_contents_when_help_is_requested()
{
args.Add("-h");
@@ -112,7 +112,7 @@ public void should_have_a_helpMessage_with_contents_when_help_is_requested()
helpMessageContents.ToString().ShouldNotBeEmpty();
}
- [Fact, Explicit]
+ [Fact]
public void should_not_run_validate_configuration_when_help_is_requested()
{
args.Add("-h");
diff --git a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs
index 03d31f27c2..2453b2c79c 100644
--- a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs
+++ b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs
@@ -17,11 +17,15 @@
namespace chocolatey.tests.infrastructure.app.nuget
{
using System;
+ using System.Collections.Generic;
using System.Linq;
using chocolatey.infrastructure.app.configuration;
using chocolatey.infrastructure.app.nuget;
using Moq;
- using NuGet;
+ using NuGet.Common;
+ using NuGet.Packaging;
+ using NuGet.Protocol;
+ using NuGet.Protocol.Core.Types;
using Should;
public class NugetCommonSpecs
@@ -32,7 +36,7 @@ private class when_gets_remote_repository : TinySpec
private readonly Mock nugetLogger = new Mock();
private readonly Mock packageDownloader = new Mock();
private ChocolateyConfiguration configuration;
- private IPackageRepository packageRepository;
+ private IEnumerable packageRepositories;
public override void Context()
{
@@ -43,7 +47,7 @@ public override void Context()
public override void Because()
{
- because = () => packageRepository = NugetCommon.GetRemoteRepository(configuration, nugetLogger.Object, packageDownloader.Object);
+ because = () => packageRepositories = NugetCommon.GetRemoteRepositories(configuration, nugetLogger.Object);
}
[Fact]
@@ -54,7 +58,7 @@ public void should_create_repository_when_source_is_null()
because();
- ((AggregateRepository)packageRepository).Repositories.Count().ShouldEqual(0);
+ packageRepositories.Count().ShouldEqual(0);
}
}
}
diff --git a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs
index 0b12f36c2c..5df8ad9ef3 100644
--- a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs
+++ b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs
@@ -31,7 +31,8 @@ namespace chocolatey.tests.infrastructure.app.services
using chocolatey.infrastructure.commands;
using chocolatey.infrastructure.results;
using Moq;
- using NuGet;
+ using NuGet.Packaging;
+ using NuGet.Versioning;
using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem;
public class AutomaticUninstallerServiceSpecs
@@ -45,7 +46,7 @@ public abstract class AutomaticUninstallerServiceSpecsBase : TinySpec
protected Mock registryService = new Mock();
protected Mock commandExecutor = new Mock();
protected ChocolateyConfiguration config = new ChocolateyConfiguration();
- protected Mock package = new Mock();
+ protected Mock package = new Mock();
protected ConcurrentDictionary packageResults = new ConcurrentDictionary();
protected PackageResult packageResult;
protected ChocolateyPackageInformation packageInformation;
@@ -66,7 +67,7 @@ public override void Context()
config.PromptForConfirmation = false;
config.PackageNames = "regular";
package.Setup(p => p.Id).Returns("regular");
- package.Setup(p => p.Version).Returns(new SemanticVersion("1.2.0"));
+ package.Setup(p => p.Version).Returns(new NuGetVersion("1.2.0"));
packageResult = new PackageResult(package.Object, "c:\\packages\\thispackage");
packageInformation = new ChocolateyPackageInformation(package.Object);
registryKeys.Add(
@@ -115,7 +116,7 @@ public void should_log_why_it_skips_auto_uninstaller()
[Fact]
public void should_not_get_package_information()
{
- packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Never);
+ packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Never);
}
[Fact]
@@ -299,7 +300,7 @@ public override void Because()
[Fact]
public void should_call_get_package_information()
{
- packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
+ packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
}
[Fact]
@@ -454,7 +455,7 @@ public override void Because()
[Fact]
public void should_call_get_package_information()
{
- packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
+ packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
}
[Fact]
@@ -502,7 +503,7 @@ public override void Because()
[Fact]
public void should_call_get_package_information()
{
- packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
+ packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
}
[Fact]
@@ -551,7 +552,7 @@ public override void Because()
[Fact]
public void should_call_get_package_information()
{
- packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
+ packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
}
[Fact]
@@ -601,7 +602,7 @@ public override void Because()
[Fact]
public void should_call_get_package_information()
{
- packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
+ packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
}
[Fact]
@@ -693,7 +694,7 @@ public override void Because()
[Fact]
public void should_call_get_package_information()
{
- packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
+ packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
}
[Fact]
@@ -748,7 +749,7 @@ public override void Because()
[Fact]
public void should_call_get_package_information()
{
- packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
+ packageInfoService.Verify(s => s.get_package_information(It.IsAny()), Times.Once);
}
[Fact]
diff --git a/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs
index 43317e0198..b100fd7c35 100644
--- a/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs
+++ b/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs
@@ -26,13 +26,14 @@
using chocolatey.infrastructure.results;
using chocolatey.infrastructure.services;
using Moq;
-using NuGet;
using NUnit.Framework;
using Should;
using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem;
namespace chocolatey.tests.infrastructure.app.services
{
+ using NuGet.Packaging;
+
public class ChocolateyPackageServiceSpecs
{
public abstract class ChocolateyPackageServiceSpecsBase : TinySpec
@@ -84,13 +85,13 @@ public override void Context()
NormalRunner.Setup(r => r.SourceType).Returns(SourceTypes.NORMAL);
FeaturesRunner.Setup(r => r.SourceType).Returns(SourceTypes.WINDOWS_FEATURES);
- var package = new Mock();
+ var package = new Mock();
var expectedResult = new ConcurrentDictionary();
expectedResult.TryAdd("test-feature", new PackageResult(package.Object, "windowsfeatures", null));
- FeaturesRunner.Setup(r => r.install_run(It.IsAny(), It.IsAny>()))
+ FeaturesRunner.Setup(r => r.install_run(It.IsAny(), It.IsAny>()))
.Returns(expectedResult);
- NormalRunner.Setup(r => r.install_run(It.IsAny(), It.IsAny>()))
+ NormalRunner.Setup(r => r.install_run(It.IsAny(), It.IsAny>()))
.Returns(new ConcurrentDictionary());
SourceRunners.AddRange(new[] { NormalRunner.Object, FeaturesRunner.Object });
@@ -125,20 +126,20 @@ public void should_return_package_that_should_have_been_installed()
[Test]
public void should_have_called_runner_for_windows_features_source()
{
- FeaturesRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames == "test-feature"), It.IsAny>()), Times.Once);
+ FeaturesRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames == "test-feature"), It.IsAny>()), Times.Once);
}
[Test]
public void should_not_have_called_runner_for_windows_features_source_with_other_package_names()
{
- FeaturesRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames != "test-feature"), It.IsAny>()), Times.Never);
+ FeaturesRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames != "test-feature"), It.IsAny>()), Times.Never);
}
[Test]
public void should_not_have_called_normal_source_runner_for_non_empty_packages()
{
// The normal source runners will be called with an argument
- NormalRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames != string.Empty), It.IsAny>()), Times.Never);
+ NormalRunner.Verify(r => r.install_run(It.Is(c => c.PackageNames != string.Empty), It.IsAny>()), Times.Never);
}
}
}
diff --git a/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs
index a68b6d17b2..0209e21140 100644
--- a/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs
+++ b/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs
@@ -24,7 +24,8 @@ namespace chocolatey.tests.infrastructure.app.services
using chocolatey.infrastructure.app.domain;
using chocolatey.infrastructure.app.services;
using Moq;
- using NuGet;
+ using NuGet.Common;
+ using NuGet.Packaging;
using Should;
using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem;
@@ -37,7 +38,7 @@ public abstract class NugetServiceSpecsBase : TinySpec
protected Mock fileSystem = new Mock();
protected Mock nugetLogger = new Mock();
protected Mock filesService = new Mock();
- protected Mock package = new Mock();
+ protected Mock package = new Mock();
protected Mock packageDownloader = new Mock();
public override void Context()
@@ -48,7 +49,7 @@ public override void Context()
filesService.ResetCalls();
package.ResetCalls();
- service = new NugetService(fileSystem.Object, nugetLogger.Object, packageInfoService.Object, filesService.Object, packageDownloader.Object);
+ service = new NugetService(fileSystem.Object, nugetLogger.Object, packageInfoService.Object, filesService.Object);
}
}
@@ -306,7 +307,7 @@ public void generated_package_should_be_in_current_directory()
because();
- var infos = MockLogger.MessagesFor(LogLevel.Info);
+ var infos = MockLogger.MessagesFor(tests.LogLevel.Info);
infos.Count.ShouldEqual(1);
infos[0].ShouldEqual("Chocolatey would have searched for a nuspec file in \"c:\\projects\\chocolatey\" and attempted to compile it.");
}
@@ -320,7 +321,7 @@ public void generated_package_should_be_in_specified_directory()
because();
- var infos = MockLogger.MessagesFor(LogLevel.Info);
+ var infos = MockLogger.MessagesFor(tests.LogLevel.Info);
infos.Count.ShouldEqual(1);
infos[0].ShouldEqual("Chocolatey would have searched for a nuspec file in \"c:\\packages\" and attempted to compile it.");
}
diff --git a/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs
index 82db549daa..3cdf1d4bab 100644
--- a/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs
+++ b/src/chocolatey.tests/infrastructure.app/services/TemplateServiceSpecs.cs
@@ -28,8 +28,10 @@ namespace chocolatey.tests.infrastructure.app.services
using chocolatey.infrastructure.filesystem;
using chocolatey.infrastructure.services;
using Moq;
+ using NuGet.Common;
using NUnit.Framework;
using Should;
+ using LogLevel = tests.LogLevel;
public class TemplateServiceSpecs
{
@@ -38,13 +40,13 @@ public abstract class TemplateServiceSpecsBase : TinySpec
protected TemplateService service;
protected Mock fileSystem = new Mock();
protected Mock xmlService = new Mock();
+ protected Mock logger = new Mock();
public override void Context()
{
fileSystem.ResetCalls();
xmlService.ResetCalls();
-
- service = new TemplateService(fileSystem.Object, xmlService.Object);
+ service = new TemplateService(fileSystem.Object, xmlService.Object, logger.Object);
}
}
diff --git a/src/chocolatey.tests/packages.config b/src/chocolatey.tests/packages.config
index 0f56db505e..f71ec363b2 100644
--- a/src/chocolatey.tests/packages.config
+++ b/src/chocolatey.tests/packages.config
@@ -1,8 +1,15 @@
+
+
+
+
+
-
+
+
+
diff --git a/src/chocolatey/chocolatey.csproj b/src/chocolatey/chocolatey.csproj
index 2205a8f27b..c1c8a8470d 100644
--- a/src/chocolatey/chocolatey.csproj
+++ b/src/chocolatey/chocolatey.csproj
@@ -89,13 +89,51 @@
..\packages\log4net.2.0.12\lib\net45\log4net.dll
-
- False
- ..\packages\Microsoft.Web.Xdt.2.1.1\lib\net40\Microsoft.Web.XmlTransform.dll
+
+
+ ..\packages\Microsoft.Web.Xdt.3.1.0\lib\net40\Microsoft.Web.XmlTransform.dll
-
- False
- ..\..\lib\Chocolatey-NuGet.Core.2.11.0.20220901\lib\net4\NuGet.Core.dll
+
+ ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
+
+
+ ..\packages\Chocolatey.NuGet.Commands.3.0.0-alpha-20221121-42\lib\net472\NuGet.Commands.dll
+
+
+ ..\packages\Chocolatey.NuGet.Common.3.0.0-alpha-20221121-42\lib\net472\NuGet.Common.dll
+
+
+ ..\packages\Chocolatey.NuGet.Configuration.3.0.0-alpha-20221121-42\lib\net472\NuGet.Configuration.dll
+
+
+ ..\packages\Chocolatey.Nuget.Credentials.3.0.0-alpha-20221121-42\lib\net472\NuGet.Credentials.dll
+
+
+ ..\packages\Chocolatey.NuGet.DependencyResolver.Core.3.0.0-alpha-20221121-42\lib\net472\NuGet.DependencyResolver.Core.dll
+
+
+ ..\packages\NuGet.Frameworks.3.0.0-alpha-20221121-42\lib\net472\NuGet.Frameworks.dll
+
+
+ ..\packages\Chocolatey.NuGet.LibraryModel.3.0.0-alpha-20221121-42\lib\net472\NuGet.LibraryModel.dll
+
+
+ ..\packages\Chocolatey.NuGet.PackageManagement.3.0.0-alpha-20221121-42\lib\net472\NuGet.PackageManagement.dll
+
+
+ ..\packages\Chocolatey.NuGet.Packaging.3.0.0-alpha-20221121-42\lib\net472\NuGet.Packaging.dll
+
+
+ ..\packages\Chocolatey.NuGet.ProjectModel.3.0.0-alpha-20221121-42\lib\net472\NuGet.ProjectModel.dll
+
+
+ ..\packages\Chocolatey.NuGet.Protocol.3.0.0-alpha-20221121-42\lib\net472\NuGet.Protocol.dll
+
+
+ ..\packages\Chocolatey.NuGet.Resolver.3.0.0-alpha-20221121-42\lib\net472\NuGet.Resolver.dll
+
+
+ ..\packages\Chocolatey.NuGet.Versioning.3.0.0-alpha-20221121-42\lib\net472\NuGet.Versioning.dll
..\..\lib\Rhino.Licensing.1.4.1\lib\net40\Rhino.Licensing.dll
@@ -104,13 +142,20 @@
..\packages\SimpleInjector.2.8.3\lib\net45\SimpleInjector.dll
+
+
+
+
+
False
..\..\lib\PowerShell\System.Management.Automation.dll
+
+
..\packages\Rx-Core.2.1.30214.0\lib\Net40\System.Reactive.Core.dll
@@ -121,6 +166,7 @@
..\packages\Rx-Linq.2.1.30214.0\lib\Net40\System.Reactive.Linq.dll
+
@@ -138,6 +184,7 @@
+
@@ -150,6 +197,9 @@
+
+
+
@@ -222,7 +272,6 @@
-
@@ -418,6 +467,7 @@
+