diff --git a/Invoke-Tests.ps1 b/Invoke-Tests.ps1 index 3704d78a16..968a36f401 100644 --- a/Invoke-Tests.ps1 +++ b/Invoke-Tests.ps1 @@ -103,6 +103,7 @@ try { if (-not $env:VM_RUNNING -and -not $env:TEST_KITCHEN) { 'VMOnly' } + 'NaOHBroken' ) } } diff --git a/build.ps1 b/build.ps1 index 674e6d1868..97728a54f5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -50,6 +50,9 @@ Param( [string[]]$ScriptArgs ) +#REMOVE ME, TEMP SET EXTRA nuget source: +$ENV:NUGETDEVRESTORE_SOURCE = "https://nuget.naoh.host/repository/nuget-public/index.json" + # Attempt to set highest encryption available for SecurityProtocol. # PowerShell will not set this by default (until maybe .NET 4.6.x). This # will typically produce a message for PowerShell v2 (just an info diff --git a/build.sh b/build.sh index dfdc92e93e..343211814c 100755 --- a/build.sh +++ b/build.sh @@ -23,6 +23,9 @@ export CAKE_PATHS_TOOLS=$TOOLS_DIR export CAKE_PATHS_ADDINS=$ADDINS_DIR export CAKE_PATHS_MODULES=$MODULES_DIR +#REMOVE ME, TEMP SET EXTRA nuget source: +export NUGETDEVRESTORE_SOURCE="https://nuget.naoh.host/repository/nuget-public/index.json" + # Define md5sum or md5 depending on Linux / macOS MD5_EXE= if [[ "$(uname -s)" == "Darwin" ]]; then diff --git a/src/chocolatey.console/chocolatey.console.csproj b/src/chocolatey.console/chocolatey.console.csproj index 247276ade9..a1d575ee1d 100644 --- a/src/chocolatey.console/chocolatey.console.csproj +++ b/src/chocolatey.console/chocolatey.console.csproj @@ -154,8 +154,8 @@ ..\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\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 f22e508f28..869d5bff72 100644 --- a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj +++ b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj @@ -68,12 +68,33 @@ ..\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 + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Chocolatey.NuGet.Common.6.4.1-zlocal.1\lib\net472\NuGet.Common.dll + + + ..\packages\Chocolatey.NuGet.Configuration.6.4.1-zlocal.1\lib\net472\NuGet.Configuration.dll + + + ..\packages\NuGet.Frameworks.6.4.1-zlocal.1\lib\net472\NuGet.Frameworks.dll + + + ..\packages\Chocolatey.NuGet.Packaging.6.4.1-zlocal.1\lib\net472\NuGet.Packaging.dll + + + ..\packages\Chocolatey.NuGet.Protocol.6.4.1-zlocal.1\lib\net472\NuGet.Protocol.dll + + + ..\packages\Chocolatey.NuGet.Versioning.6.4.1-zlocal.1\lib\net472\NuGet.Versioning.dll + False ..\packages\NUnit.2.6.4\lib\nunit.framework.dll @@ -87,6 +108,10 @@ + + + + ..\packages\Rx-Core.2.1.30214.0\lib\Net40\System.Reactive.Core.dll @@ -96,6 +121,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 80598378cf..aafb607efd 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 b0ffb1d023..863aff7ef7 100644 --- a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs @@ -26,6 +26,8 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.services; using chocolatey.infrastructure.commands; using chocolatey.infrastructure.results; + using NuGet.Configuration; + using NuGet.Packaging; using NUnit.Framework; using Should; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; @@ -44,8 +46,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(); @@ -175,9 +177,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] @@ -344,10 +348,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() @@ -507,9 +511,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] @@ -590,9 +596,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] @@ -682,9 +690,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] @@ -778,9 +788,11 @@ 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] @@ -874,13 +886,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); @@ -901,7 +914,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(); @@ -914,7 +926,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(); @@ -1202,7 +1213,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() @@ -1228,9 +1239,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] @@ -1270,9 +1283,9 @@ public void config_should_match_package_result_name() } [Fact] - public void should_have_a_version_of_one_dot_zero() + public void should_have_a_version_of_one_dot_zero_dot_zero() { - packageResult.Version.ShouldEqual("1.0"); + packageResult.Version.ShouldEqual("1.0.0"); } } @@ -1288,7 +1301,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() @@ -1404,6 +1417,50 @@ public void should_install_a_package_in_the_lib_directory() Directory.Exists(packageDir).ShouldBeTrue(); } + [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)); + + File.Exists(packageFile).ShouldBeTrue(); + } + + [Fact] + 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)); + + File.Exists(packageFile).ShouldBeTrue(); + } + + [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)); + + File.Exists(packageFile).ShouldBeFalse(); + } + + [Fact] + 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)); + + File.Exists(packageFile).ShouldBeFalse(); + } + [Fact] public void should_contain_a_warning_message_that_it_installed_successfully() { @@ -1495,6 +1552,50 @@ public void should_install_a_package_in_the_lib_directory() Directory.Exists(packageDir).ShouldBeTrue(); } + [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)); + + File.Exists(packageFile).ShouldBeTrue(); + } + + [Fact] + 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)); + + File.Exists(packageFile).ShouldBeTrue(); + } + + [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)); + + File.Exists(packageFile).ShouldBeFalse(); + } + + [Fact] + 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)); + + File.Exists(packageFile).ShouldBeFalse(); + } + [Fact] public void should_contain_a_warning_message_that_it_installed_successfully() { @@ -1538,6 +1639,128 @@ public void should_have_a_version_of_one_dot_zero_dot_zero() } } + 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() + { + Directory.Exists(packageResult.InstallLocation).ShouldBeTrue(); + } + + [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"; + + Directory.Exists(packageDir).ShouldBeTrue(); + } + + [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)); + + File.Exists(packageFile).ShouldBeTrue(); + } + + [Fact] + 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)); + + File.Exists(packageFile).ShouldBeTrue(); + } + + [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)); + + File.Exists(packageFile).ShouldBeFalse(); + } + + [Fact] + 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)); + + File.Exists(packageFile).ShouldBeFalse(); + } + + [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"); + } + } + + public class when_switching_a_side_by_side_package_to_a_normal_package : ScenariosBase { private PackageResult packageResult; @@ -1571,6 +1794,58 @@ public void should_install_a_package_in_the_lib_directory() Directory.Exists(packageDir).ShouldBeTrue(); } + [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"); + + Directory.Exists(packageDir).ShouldBeFalse(); + } + + [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)); + + File.Exists(packageFile).ShouldBeTrue(); + } + + [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)); + + File.Exists(packageFile).ShouldBeTrue(); + } + + [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)); + + File.Exists(packageFile).ShouldBeFalse(); + } + + [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)); + + File.Exists(packageFile).ShouldBeFalse(); + } + [Fact] public void should_contain_a_warning_message_that_it_installed_successfully() { @@ -1620,9 +1895,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() @@ -1659,8 +1934,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] @@ -1719,11 +1996,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; } @@ -1752,9 +2029,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] @@ -1769,8 +2048,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] @@ -1829,11 +2110,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; } @@ -1863,9 +2144,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] @@ -1880,16 +2163,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] @@ -1939,11 +2226,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; } @@ -1973,9 +2260,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] @@ -1990,16 +2279,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] @@ -2049,11 +2342,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; @@ -2084,9 +2377,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] @@ -2149,7 +2444,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() @@ -2259,7 +2554,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; } @@ -2286,9 +2581,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] @@ -2342,10 +2639,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"); } @@ -2374,9 +2671,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] @@ -2391,8 +2690,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] @@ -2441,9 +2742,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"); } @@ -2506,9 +2807,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; } @@ -2538,9 +2839,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] @@ -2589,9 +2892,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; @@ -2614,8 +2917,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] @@ -2702,10 +3007,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"); } @@ -2736,8 +3041,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] @@ -2786,10 +3093,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"); } @@ -2800,17 +3107,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) { - Directory.Exists(packageResult.Value.InstallLocation).ShouldBeTrue(); + Directory.Exists(packageResult.Value.InstallLocation).ShouldBeFalse(); } } [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); @@ -2819,38 +3124,38 @@ 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")] public void should_contain_a_message_that_it_was_unable_to_install_any_packages() { bool expectedMessage = false; foreach (var message in MockLogger.MessagesFor(LogLevel.Warn).or_empty_list_if_null()) { - if (message.Contains("installed 0/3")) expectedMessage = true; + if (message.Contains("installed 0/")) expectedMessage = true; } expectedMessage.ShouldBeTrue(); } [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) @@ -2860,7 +3165,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) @@ -2870,7 +3174,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) @@ -2880,7 +3183,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; @@ -2906,10 +3208,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"); } @@ -2926,7 +3228,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); @@ -2935,29 +3236,28 @@ 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")] public void should_contain_a_message_that_it_was_unable_to_install_any_packages() { bool expectedMessage = false; foreach (var message in MockLogger.MessagesFor(LogLevel.Warn).or_empty_list_if_null()) { - if (message.Contains("installed 0/3")) expectedMessage = true; + if (message.Contains("installed 0/")) expectedMessage = true; } expectedMessage.ShouldBeTrue(); } [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) @@ -2967,7 +3267,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) @@ -2977,7 +3276,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) @@ -2987,7 +3285,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; @@ -3013,9 +3310,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() @@ -3031,7 +3328,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) @@ -3041,7 +3337,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); @@ -3050,7 +3345,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"); @@ -3059,25 +3353,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; @@ -3090,7 +3385,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) @@ -3100,7 +3394,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) @@ -3110,7 +3403,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) @@ -3153,9 +3445,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] @@ -3317,7 +3611,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"); } @@ -3333,9 +3627,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] @@ -3425,7 +3721,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; @@ -3447,9 +3743,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] @@ -3530,7 +3828,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"; } @@ -3558,9 +3856,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] @@ -3783,10 +4083,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() @@ -3812,9 +4112,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 5dcb4320cf..cba003e126 100644 --- a/src/chocolatey.tests.integration/scenarios/ListScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/ListScenarios.cs @@ -23,6 +23,7 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.configuration; using chocolatey.infrastructure.app.services; using chocolatey.infrastructure.results; + using NuGet.Configuration; using NUnit.Framework; using Should; @@ -38,8 +39,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"); @@ -436,7 +437,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; @@ -495,7 +496,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; @@ -550,7 +551,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; @@ -579,15 +580,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"); } } @@ -597,7 +598,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; @@ -627,17 +628,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 833c99cf96..071636ed70 100644 --- a/src/chocolatey.tests.integration/scenarios/PinScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/PinScenarios.cs @@ -26,6 +26,7 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.domain; using chocolatey.infrastructure.commands; using chocolatey.infrastructure.results; + using NuGet.Configuration; using Should; public class PinScenarios @@ -40,8 +41,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 f2daa097e9..a547a588e8 100644 --- a/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/UninstallScenarios.cs @@ -26,6 +26,7 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.commands; using chocolatey.infrastructure.filesystem; using chocolatey.infrastructure.results; + using NuGet.Configuration; using NUnit.Framework; using Should; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; @@ -44,9 +45,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; @@ -985,7 +986,7 @@ 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); + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames, Configuration.PackageNames + NuGetConstants.PackageExtension); File.Exists(packageFile).ShouldBeTrue(); } @@ -1075,7 +1076,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); } @@ -1153,7 +1154,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 9c86f56c52..dab3916df8 100644 --- a/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/UpgradeScenarios.cs @@ -28,6 +28,8 @@ namespace chocolatey.tests.integration.scenarios using chocolatey.infrastructure.app.services; using chocolatey.infrastructure.filesystem; using chocolatey.infrastructure.results; + using NuGet.Configuration; + using NuGet.Packaging; using NUnit.Framework; using Should; @@ -44,9 +46,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; @@ -240,9 +242,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] @@ -398,9 +402,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] @@ -477,10 +483,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] @@ -628,10 +636,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] @@ -790,9 +800,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] @@ -883,9 +895,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] @@ -946,9 +960,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] @@ -1081,9 +1097,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] @@ -1171,9 +1189,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] @@ -1259,9 +1279,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] @@ -1367,9 +1389,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] @@ -1486,9 +1510,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] @@ -1570,9 +1596,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] @@ -1648,9 +1676,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] @@ -1975,9 +2005,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] @@ -1991,9 +2023,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] @@ -2071,9 +2105,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"); } @@ -2087,24 +2121,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] @@ -2153,9 +2193,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"); } @@ -2169,24 +2209,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] @@ -2273,9 +2319,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; @@ -2290,24 +2336,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] @@ -2356,9 +2408,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"); } @@ -2372,24 +2424,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] @@ -2438,9 +2496,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"); @@ -2470,8 +2528,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] @@ -2492,8 +2552,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] @@ -2514,8 +2576,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] @@ -2578,9 +2642,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"); } @@ -2594,24 +2658,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] @@ -2660,9 +2730,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"); @@ -2684,8 +2754,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] @@ -2703,11 +2775,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] @@ -2718,7 +2792,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"); @@ -2729,8 +2803,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] @@ -2741,7 +2817,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"); @@ -2813,9 +2889,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] @@ -2911,9 +2989,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] @@ -3082,9 +3162,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] @@ -3132,9 +3214,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] @@ -3182,10 +3266,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() @@ -3219,9 +3303,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] @@ -3319,7 +3405,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"; } @@ -3363,9 +3449,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 b4a527e92b..234503511c 100644 --- a/src/chocolatey.tests/TinySpec.cs +++ b/src/chocolatey.tests/TinySpec.cs @@ -61,13 +61,23 @@ public MockLogger MockLogger get { return NUnitSetup.MockLogger; } } + Exception testFixtureSetupException = null; + [TestFixtureSetUp] public void Setup() { - if (MockLogger != null) MockLogger.reset(); - //Log.InitializeWith(MockLogger); - Context(); - Because(); + try + { + if (MockLogger != null) MockLogger.reset(); + //Log.InitializeWith(MockLogger); + Context(); + Because(); + + } + catch (Exception ex) + { + testFixtureSetupException = ex; + } } public abstract void Context(); @@ -77,6 +87,13 @@ public void Setup() [SetUp] public void EachSpecSetup() { + if (testFixtureSetupException != null) + { + string msg = string.Format("There was a failure during test fixture setup, resulting in a {1} exception. {0}Exception Message: {2}{0}Stack Trace:{3}", + Environment.NewLine, testFixtureSetupException.GetType(), testFixtureSetupException.Message, testFixtureSetupException.StackTrace); + Assert.Fail(msg); + } + BeforeEachSpec(); } diff --git a/src/chocolatey.tests/chocolatey.tests.csproj b/src/chocolatey.tests/chocolatey.tests.csproj index 8feed80f9d..7dd602e880 100644 --- a/src/chocolatey.tests/chocolatey.tests.csproj +++ b/src/chocolatey.tests/chocolatey.tests.csproj @@ -67,12 +67,33 @@ ..\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 + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Chocolatey.NuGet.Common.6.4.1-zlocal.1\lib\net472\NuGet.Common.dll + + + ..\packages\Chocolatey.NuGet.Configuration.6.4.1-zlocal.1\lib\net472\NuGet.Configuration.dll + + + ..\packages\NuGet.Frameworks.6.4.1-zlocal.1\lib\net472\NuGet.Frameworks.dll + + + ..\packages\Chocolatey.NuGet.Packaging.6.4.1-zlocal.1\lib\net472\NuGet.Packaging.dll + + + ..\packages\Chocolatey.NuGet.Protocol.6.4.1-zlocal.1\lib\net472\NuGet.Protocol.dll + + + ..\packages\Chocolatey.NuGet.Versioning.6.4.1-zlocal.1\lib\net472\NuGet.Versioning.dll + False ..\packages\NUnit.2.6.4\lib\nunit.framework.dll @@ -86,6 +107,12 @@ + + + + + + diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs index a00f6ff90b..9cbd5feb67 100644 --- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyPinCommandSpecs.cs @@ -28,6 +28,9 @@ namespace chocolatey.tests.infrastructure.app.commands using chocolatey.infrastructure.commandline; using chocolatey.infrastructure.results; using Moq; + using NuGet.Common; + using NuGet.Packaging; + using NuGet.Versioning; using Should; public class ChocolateyPinCommandSpecs @@ -39,27 +42,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) { @@ -328,7 +331,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"); @@ -385,8 +388,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() { @@ -430,13 +431,13 @@ 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); } @@ -447,13 +448,14 @@ 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/nuget/NugetCommonSpecs.cs b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs index d749d8ef39..2453b2c79c 100644 --- a/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/nuget/NugetCommonSpecs.cs @@ -17,10 +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.Common; + using NuGet.Packaging; + using NuGet.Protocol; + using NuGet.Protocol.Core.Types; using Should; public class NugetCommonSpecs @@ -31,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() { @@ -42,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] @@ -53,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 38aeb2d3db..5df8ad9ef3 100644 --- a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs @@ -31,6 +31,8 @@ namespace chocolatey.tests.infrastructure.app.services using chocolatey.infrastructure.commands; using chocolatey.infrastructure.results; using Moq; + using NuGet.Packaging; + using NuGet.Versioning; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; public class AutomaticUninstallerServiceSpecs @@ -44,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; @@ -65,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( @@ -114,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] @@ -298,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] @@ -453,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] @@ -501,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] @@ -550,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] @@ -600,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] @@ -692,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] @@ -747,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 3a5070d86b..b100fd7c35 100644 --- a/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/ChocolateyPackageServiceSpecs.cs @@ -32,6 +32,8 @@ namespace chocolatey.tests.infrastructure.app.services { + using NuGet.Packaging; + public class ChocolateyPackageServiceSpecs { public abstract class ChocolateyPackageServiceSpecsBase : TinySpec @@ -83,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 }); @@ -124,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 b96acbb26f..0209e21140 100644 --- a/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/NugetServiceSpecs.cs @@ -24,6 +24,8 @@ namespace chocolatey.tests.infrastructure.app.services using chocolatey.infrastructure.app.domain; using chocolatey.infrastructure.app.services; using Moq; + using NuGet.Common; + using NuGet.Packaging; using Should; using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem; @@ -36,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() @@ -47,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); } } @@ -305,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."); } @@ -319,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 aa07e6b709..e00be19ee7 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 ccb6abb4b3..f84d92f5e9 100644 --- a/src/chocolatey/chocolatey.csproj +++ b/src/chocolatey/chocolatey.csproj @@ -88,9 +88,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 + + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Chocolatey.NuGet.Commands.6.4.1-zlocal.1\lib\net472\NuGet.Commands.dll + + + ..\packages\Chocolatey.NuGet.Common.6.4.1-zlocal.1\lib\net472\NuGet.Common.dll + + + ..\packages\Chocolatey.NuGet.Configuration.6.4.1-zlocal.1\lib\net472\NuGet.Configuration.dll + + + ..\packages\Chocolatey.Nuget.Credentials.6.4.1-zlocal.1\lib\net472\NuGet.Credentials.dll + + + ..\packages\Chocolatey.NuGet.DependencyResolver.Core.6.4.1-zlocal.1\lib\net472\NuGet.DependencyResolver.Core.dll + + + ..\packages\NuGet.Frameworks.6.4.1-zlocal.1\lib\net472\NuGet.Frameworks.dll + + + ..\packages\Chocolatey.NuGet.LibraryModel.6.4.1-zlocal.1\lib\net472\NuGet.LibraryModel.dll + + + ..\packages\Chocolatey.NuGet.PackageManagement.6.4.1-zlocal.1\lib\net472\NuGet.PackageManagement.dll + + + ..\packages\Chocolatey.NuGet.Packaging.6.4.1-zlocal.1\lib\net472\NuGet.Packaging.dll + + + ..\packages\Chocolatey.NuGet.ProjectModel.6.4.1-zlocal.1\lib\net472\NuGet.ProjectModel.dll + + + ..\packages\Chocolatey.NuGet.Protocol.6.4.1-zlocal.1\lib\net472\NuGet.Protocol.dll + + + ..\packages\Chocolatey.NuGet.Resolver.6.4.1-zlocal.1\lib\net472\NuGet.Resolver.dll + + + ..\packages\Chocolatey.NuGet.Versioning.6.4.1-zlocal.1\lib\net472\NuGet.Versioning.dll ..\..\lib\Rhino.Licensing.1.4.1\lib\net40\Rhino.Licensing.dll @@ -99,13 +141,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 @@ -116,6 +165,7 @@ ..\packages\Rx-Linq.2.1.30214.0\lib\Net40\System.Reactive.Linq.dll + @@ -133,6 +183,7 @@ + @@ -145,6 +196,9 @@ + + + @@ -217,7 +271,6 @@ - @@ -413,6 +466,7 @@ +