Skip to content

Commit

Permalink
Merge pull request #2883 from AdmiringWorm/upgrade-nunit-to-3.x
Browse files Browse the repository at this point in the history
(#2880) Update NUnit dependencies to v3
  • Loading branch information
gep13 authored Nov 17, 2022
2 parents 067027d + 42220ff commit 924a785
Show file tree
Hide file tree
Showing 37 changed files with 334 additions and 276 deletions.
6 changes: 1 addition & 5 deletions recipe.cake
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
// TOOLS
///////////////////////////////////////////////////////////////////////////////

// This is needed in order to allow NUnit v2 tested to be executed by the NUnit
// v3 Test Runner
#tool nuget:?package=NUnit.Extension.NUnitV2Driver&version=3.9.0

///////////////////////////////////////////////////////////////////////////////
// SCRIPT
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -65,7 +61,7 @@ Func<List<ILMergeConfig>> getILMergeConfigs = () =>
- GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/choco.exe")
- GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/System.Management.Automation.dll")
- GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/chocolatey.tests*.dll")
- GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/{Moq|nunit.framework|Should}.dll");
- GetFiles(BuildParameters.Paths.Directories.PublishedApplications + "/choco-no7zip/{Moq|nunit|Should|testcentric}*.dll");

Information("The following assemblies have been selected to be ILMerged for choco.exe No7zip Version...");
foreach (var assemblyToILMerge in no7zAssembliesToILMerge)
Expand Down
2 changes: 2 additions & 0 deletions src/chocolatey.tests.integration/NUnitSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

[assembly: chocolatey.tests.Integration]

namespace chocolatey.tests.integration
{
using System;
Expand Down
4 changes: 4 additions & 0 deletions src/chocolatey.tests.integration/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

// Because we use a static variable for collecting log message
// we can not run tests in parallel.
[assembly: NUnit.Framework.NonParallelizable]
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.4.3.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.4.3.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.13.3\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.13.3\build\NUnit.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -15,6 +17,8 @@
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<OverwriteReadOnlyFiles>true</OverwriteReadOnlyFiles>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -78,12 +82,11 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\Chocolatey-NuGet.Core.2.11.0.20220901\lib\net4\NuGet.Core.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=3.13.3.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.13.3\lib\net40\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Should, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Should.1.1.12.0\lib\Should.dll</HintPath>
<HintPath>..\packages\Should.1.1.20\lib\Should.dll</HintPath>
</Reference>
<Reference Include="SimpleInjector, Version=2.8.3.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\packages\SimpleInjector.2.8.3\lib\net45\SimpleInjector.dll</HintPath>
Expand Down Expand Up @@ -720,6 +723,13 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NUnit.3.13.3\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.13.3\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.4.3.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.4.3.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2017 - 2021 Chocolatey Software, Inc
// Copyright © 2017 - 2021 Chocolatey Software, Inc
// Copyright © 2011 - 2017 RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -46,6 +46,7 @@ public override void Context()
}
}

[SetCulture("en"), SetUICulture("en")]
public class when_FilesService_encounters_locked_files : FilesServiceSpecsBase
{
private PackageFiles _result;
Expand All @@ -69,6 +70,7 @@ public override void AfterObservations()
{
base.AfterObservations();
_fileStream.Close();
_fileStream.Dispose();
}

public override void Because()
Expand All @@ -93,13 +95,7 @@ public void should_log_a_warning()
[Platform(Exclude = "Mono")]
public void should_log_a_warning_about_locked_files()
{
bool lockedFiles = false;
foreach (var message in MockLogger.MessagesFor(LogLevel.Warn).or_empty_list_if_null())
{
if (message.Contains("The process cannot access the file")) lockedFiles = true;
}

lockedFiles.ShouldBeTrue();
MockLogger.Verify(l => l.Warn(It.Is<string>(s => s.Contains("The process cannot access the file"))), Times.Once);
}

[Fact]
Expand Down
6 changes: 3 additions & 3 deletions src/chocolatey.tests.integration/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<package id="log4net" version="2.0.12" targetFramework="net48" />
<package id="Microsoft.Web.Xdt" version="2.1.1" targetFramework="net40" />
<package id="Moq" version="4.2.1402.2112" targetFramework="net40" />
<package id="NUnit" version="2.6.4" targetFramework="net40" />
<package id="NUnitTestAdapter" version="2.3.0" targetFramework="net40" />
<package id="NUnit" version="3.13.3" targetFramework="net48" />
<package id="NUnit3TestAdapter" version="4.3.0" targetFramework="net48" />
<package id="Rx-Core" version="2.1.30214.0" targetFramework="net48" />
<package id="Rx-Interfaces" version="2.1.30214.0" targetFramework="net48" />
<package id="Rx-Linq" version="2.1.30214.0" targetFramework="net48" />
<package id="Should" version="1.1.12.0" />
<package id="Should" version="1.1.20" targetFramework="net48" />
<package id="SimpleInjector" version="2.8.3" targetFramework="net48" />
</packages>
Loading

0 comments on commit 924a785

Please sign in to comment.