diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 4e91d091..80e4e82c 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -99,7 +99,7 @@ jobs: - name: build run: msbuild -t:rebuild -property:Configuration=TestWindows - - name: test + - name: test (${{ matrix.framework }}) uses: josepho0918/vstest-action@main with: testAssembly: "NuGetUtility.Test.dll" diff --git a/src/NuGetUtility/NuGetUtility.csproj b/src/NuGetUtility/NuGetUtility.csproj index 8ea2f91a..8893334c 100644 --- a/src/NuGetUtility/NuGetUtility.csproj +++ b/src/NuGetUtility/NuGetUtility.csproj @@ -37,7 +37,7 @@ - + @@ -48,7 +48,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/NuGetUtility.Test/NuGetUtility.Test.csproj b/tests/NuGetUtility.Test/NuGetUtility.Test.csproj index 7f014549..3aced992 100644 --- a/tests/NuGetUtility.Test/NuGetUtility.Test.csproj +++ b/tests/NuGetUtility.Test/NuGetUtility.Test.csproj @@ -36,7 +36,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath.Linux.verified.txt b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath.Linux.verified.txt new file mode 100644 index 00000000..b490ad87 --- /dev/null +++ b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath.Linux.verified.txt @@ -0,0 +1 @@ +{SolutionDirectory}tests/targets/PackageReferenceProject/PackageReferenceProject.csproj,{SolutionDirectory}tests/targets/PackagesConfigProject/PackagesConfigProject.csproj,{SolutionDirectory}tests/targets/ProjectWithoutNugetReferences/ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveNuget/ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveReferences/ProjectWithTransitiveReferences.csproj \ No newline at end of file diff --git a/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath.OSX.verified.txt b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath.OSX.verified.txt new file mode 100644 index 00000000..b490ad87 --- /dev/null +++ b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath.OSX.verified.txt @@ -0,0 +1 @@ +{SolutionDirectory}tests/targets/PackageReferenceProject/PackageReferenceProject.csproj,{SolutionDirectory}tests/targets/PackagesConfigProject/PackagesConfigProject.csproj,{SolutionDirectory}tests/targets/ProjectWithoutNugetReferences/ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveNuget/ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveReferences/ProjectWithTransitiveReferences.csproj \ No newline at end of file diff --git a/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath.Windows.verified.txt b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath.Windows.verified.txt new file mode 100644 index 00000000..952ecf2f --- /dev/null +++ b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath.Windows.verified.txt @@ -0,0 +1 @@ +{SolutionDirectory}tests\targets\PackageReferenceProject\PackageReferenceProject.csproj,{SolutionDirectory}tests\targets\PackagesConfigProject\PackagesConfigProject.csproj,{SolutionDirectory}tests\targets\ProjectWithoutNugetReferences\ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests\targets\ProjectWithTransitiveNuget\ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests\targets\ProjectWithTransitiveReferences\ProjectWithTransitiveReferences.csproj \ No newline at end of file diff --git a/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath.Linux.verified.txt b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath.Linux.verified.txt new file mode 100644 index 00000000..b490ad87 --- /dev/null +++ b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath.Linux.verified.txt @@ -0,0 +1 @@ +{SolutionDirectory}tests/targets/PackageReferenceProject/PackageReferenceProject.csproj,{SolutionDirectory}tests/targets/PackagesConfigProject/PackagesConfigProject.csproj,{SolutionDirectory}tests/targets/ProjectWithoutNugetReferences/ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveNuget/ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveReferences/ProjectWithTransitiveReferences.csproj \ No newline at end of file diff --git a/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath.OSX.verified.txt b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath.OSX.verified.txt new file mode 100644 index 00000000..b490ad87 --- /dev/null +++ b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath.OSX.verified.txt @@ -0,0 +1 @@ +{SolutionDirectory}tests/targets/PackageReferenceProject/PackageReferenceProject.csproj,{SolutionDirectory}tests/targets/PackagesConfigProject/PackagesConfigProject.csproj,{SolutionDirectory}tests/targets/ProjectWithoutNugetReferences/ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveNuget/ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests/targets/ProjectWithTransitiveReferences/ProjectWithTransitiveReferences.csproj \ No newline at end of file diff --git a/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath.Windows.verified.txt b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath.Windows.verified.txt new file mode 100644 index 00000000..952ecf2f --- /dev/null +++ b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath.Windows.verified.txt @@ -0,0 +1 @@ +{SolutionDirectory}tests\targets\PackageReferenceProject\PackageReferenceProject.csproj,{SolutionDirectory}tests\targets\PackagesConfigProject\PackagesConfigProject.csproj,{SolutionDirectory}tests\targets\ProjectWithoutNugetReferences\ProjectWithoutNugetReferences.csproj,{SolutionDirectory}tests\targets\ProjectWithTransitiveNuget\ProjectWithTransitiveNuget.csproj,{SolutionDirectory}tests\targets\ProjectWithTransitiveReferences\ProjectWithTransitiveReferences.csproj \ No newline at end of file diff --git a/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.cs b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.cs index 0ff6467f..83726e1e 100644 --- a/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.cs +++ b/tests/NuGetUtility.Test/ReferencedPackagesReader/ProjectsCollectorTest.cs @@ -12,6 +12,11 @@ namespace NuGetUtility.Test.ReferencedPackagesReader [TestFixture] public class ProjectsCollectorTest { + public ProjectsCollectorTest() + { + _osPlatformSpecificVerifySettings = new(); + _osPlatformSpecificVerifySettings.UniqueForOSPlatform(); + } [SetUp] public void SetUp() @@ -23,6 +28,7 @@ public void SetUp() private IMsBuildAbstraction _msBuild = null!; private ProjectsCollector _uut = null!; private Fixture _fixture = null!; + private readonly VerifySettings _osPlatformSpecificVerifySettings; [TestCase("A.csproj")] [TestCase("B.fsproj")] @@ -107,22 +113,22 @@ public void GetProjects_Should_ReturnOnlyExistingProjectsInSolutionFile(string s } [Test] - public void GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath() + public async Task GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileRelativePath() { var msbuild = new MsBuildAbstraction(); IEnumerable result = msbuild.GetProjectsFromSolution("../../../../targets/Projects.sln"); - Assert.That(result.Count(), Is.EqualTo(5)); + await Verify(string.Join(",", result), _osPlatformSpecificVerifySettings); } [Test] - public void GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath() + public async Task GetProjectsFromSolution_Should_ReturnProjectsInActualSolutionFileAbsolutePath() { var msbuild = new MsBuildAbstraction(); IEnumerable result = msbuild.GetProjectsFromSolution(Path.GetFullPath("../../../../targets/Projects.sln")); - Assert.That(result.Count(), Is.EqualTo(5)); + await Verify(string.Join(",", result), _osPlatformSpecificVerifySettings); } - private void CreateFiles(IEnumerable files) + private static void CreateFiles(IEnumerable files) { foreach (string file in files) { diff --git a/tests/NuGetUtility.Test/ReferencedPackagesReader/ReferencedPackagesReaderIntegrationTest.cs b/tests/NuGetUtility.Test/ReferencedPackagesReader/ReferencedPackagesReaderIntegrationTest.cs index 2e708352..824ae50e 100644 --- a/tests/NuGetUtility.Test/ReferencedPackagesReader/ReferencedPackagesReaderIntegrationTest.cs +++ b/tests/NuGetUtility.Test/ReferencedPackagesReader/ReferencedPackagesReaderIntegrationTest.cs @@ -80,7 +80,7 @@ public void GetInstalledPackagesShould_ReturnResolvedDependency_For_ProjectWithR IEnumerable result = _uut!.GetInstalledPackages(path, includeTransitive); - Assert.That(result.Count, Is.EqualTo(includeTransitive ? 2 : 1)); + Assert.That(result.Count, Is.EqualTo(includeTransitive ? 3 : 1)); } [Test] @@ -155,15 +155,15 @@ public void GetInstalledPackagesShould_ThrowError_For_PackagesForNativeCppProjec [TestCase("net8.0", false, "Microsoft.Extensions.Logging.Abstractions")] [TestCase("net8.0-browser", false, "Microsoft.Extensions.Logging.Abstractions")] [TestCase("net6.0", true, "TinyCsvParser")] - [TestCase("net8.0", true, "Microsoft.Extensions.Logging.Abstractions", "Microsoft.Extensions.DependencyInjection.Abstractions")] - [TestCase("net8.0-browser", true, "Microsoft.Extensions.Logging.Abstractions", "Microsoft.Extensions.DependencyInjection.Abstractions")] + [TestCase("net8.0", true, "Microsoft.Extensions.Logging.Abstractions", "Microsoft.Extensions.DependencyInjection.Abstractions", "System.Diagnostics.DiagnosticSource")] + [TestCase("net8.0-browser", true, "Microsoft.Extensions.Logging.Abstractions", "Microsoft.Extensions.DependencyInjection.Abstractions", "System.Diagnostics.DiagnosticSource")] public void GetInstalledPackagesShould_OnlyReturn_PackagesPackagesReferencedByRequestedFramework(string framework, bool includeTransitive, params string[] packages) { string path = Path.GetFullPath("../../../../targets/MultiTargetProjectWithDifferentDependencies/MultiTargetProjectWithDifferentDependencies.csproj"); IEnumerable result = _uut!.GetInstalledPackages(path, includeTransitive, framework); - Assert.That(packages, Is.EquivalentTo(result.Select(p => p.Id))); + Assert.That(result.Select(p => p.Id), Is.EquivalentTo(packages)); } } } diff --git a/tests/targets/MultiTargetProjectWithDifferentDependencies/MultiTargetProjectWithDifferentDependencies.csproj b/tests/targets/MultiTargetProjectWithDifferentDependencies/MultiTargetProjectWithDifferentDependencies.csproj index cb7a2f27..bf31adbf 100644 --- a/tests/targets/MultiTargetProjectWithDifferentDependencies/MultiTargetProjectWithDifferentDependencies.csproj +++ b/tests/targets/MultiTargetProjectWithDifferentDependencies/MultiTargetProjectWithDifferentDependencies.csproj @@ -8,6 +8,6 @@ - + diff --git a/tests/targets/PackagesConfigProject/PackagesConfigProject.csproj b/tests/targets/PackagesConfigProject/PackagesConfigProject.csproj index c72c3703..4c4708fb 100644 --- a/tests/targets/PackagesConfigProject/PackagesConfigProject.csproj +++ b/tests/targets/PackagesConfigProject/PackagesConfigProject.csproj @@ -47,8 +47,8 @@ - - ..\..\..\packages\TinyCsvParser.2.7.0\lib\netstandard2.0\TinyCsvParser.dll + + ..\..\..\packages\TinyCsvParser.2.7.1\lib\netstandard2.0\TinyCsvParser.dll diff --git a/tests/targets/PackagesConfigProject/packages.config b/tests/targets/PackagesConfigProject/packages.config index cd17ce22..317e7e0d 100644 --- a/tests/targets/PackagesConfigProject/packages.config +++ b/tests/targets/PackagesConfigProject/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/tests/targets/VersionRangesProject/VersionRangesProject.csproj b/tests/targets/VersionRangesProject/VersionRangesProject.csproj index 43c09b7f..40052649 100644 --- a/tests/targets/VersionRangesProject/VersionRangesProject.csproj +++ b/tests/targets/VersionRangesProject/VersionRangesProject.csproj @@ -5,7 +5,7 @@ - + \ No newline at end of file