From 877c814c54f0e338bf4b9e7f4a495218ef8a7431 Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Tue, 11 Mar 2025 11:52:43 -0700 Subject: [PATCH 1/2] Update to AwesomeAssertions Update the addreportable call --- .../MSBuildBinLogQuery.Tests.csproj | 2 +- .../Shared/Commands/CommandBundleFilterTests.cs | 12 ++++++------ .../Shared/VSVersioning/VSVersionTests.cs | 7 ++++--- .../dotnet-core-uninstall.Tests.csproj | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/test/MSBuildBinLogQuery.Tests/MSBuildBinLogQuery.Tests.csproj b/test/MSBuildBinLogQuery.Tests/MSBuildBinLogQuery.Tests.csproj index 26d9eb38..4ab11349 100644 --- a/test/MSBuildBinLogQuery.Tests/MSBuildBinLogQuery.Tests.csproj +++ b/test/MSBuildBinLogQuery.Tests/MSBuildBinLogQuery.Tests.csproj @@ -11,7 +11,7 @@ - + diff --git a/test/dotnet-core-uninstall.Tests/Shared/Commands/CommandBundleFilterTests.cs b/test/dotnet-core-uninstall.Tests/Shared/Commands/CommandBundleFilterTests.cs index 20b0ed71..c4d5c584 100644 --- a/test/dotnet-core-uninstall.Tests/Shared/Commands/CommandBundleFilterTests.cs +++ b/test/dotnet-core-uninstall.Tests/Shared/Commands/CommandBundleFilterTests.cs @@ -105,14 +105,14 @@ internal void TestRequiredUninstallableWithOptionsMac(string command, string[] e internal void TestRequiredUninstallableWhenExplicitlyAdded(IEnumerable bundles, string command, string[] expectedUninstallableSdk, string[] expectedUninstallableRuntime) { - using var scope = new AssertionScope(); - scope.AddReportable("bundles", () => String.Join(Environment.NewLine, bundles.Select(b => b.ToDebugString()))); - scope.AddReportable("command", () => command); - scope.AddReportable("expectedUninstallableSdk", () => String.Join(Environment.NewLine, expectedUninstallableSdk)); - scope.AddReportable("expectedUninstallableRuntime", () => String.Join(Environment.NewLine, expectedUninstallableRuntime)); + var chain = AssertionChain.GetOrCreate(); + chain.AddReportable("bundles", () => String.Join(Environment.NewLine, bundles.Select(b => b.ToDebugString()))); + chain.AddReportable("command", () => command); + chain.AddReportable("expectedUninstallableSdk", () => String.Join(Environment.NewLine, expectedUninstallableSdk)); + chain.AddReportable("expectedUninstallableRuntime", () => String.Join(Environment.NewLine, expectedUninstallableRuntime)); var parseResult = CommandLineConfigs.UninstallRootCommand.Parse(command); var uninstallableBundles = CommandBundleFilter.GetFilteredBundles(bundles, parseResult); - scope.AddReportable("uninstallableBundles", () => String.Join(Environment.NewLine, uninstallableBundles.Select(b => b.ToDebugString()))); + chain.AddReportable("uninstallableBundles", () => String.Join(Environment.NewLine, uninstallableBundles.Select(b => b.ToDebugString()))); var uninstallableSdks = uninstallableBundles.Where(b => b.Version is SdkVersion).Select(b => b.DisplayName); var requiredSdks = bundles.Except(uninstallableBundles).Where(b => b.Version is SdkVersion).Select(b => b.DisplayName); diff --git a/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs b/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs index c45abdfa..f343da5d 100644 --- a/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs +++ b/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Metadata; using FluentAssertions; using FluentAssertions.Execution; using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo; @@ -136,9 +137,9 @@ internal void TestGetUninstallableNonSdkVersions(IEnumerable bundles, bo private void CheckAllowed(IEnumerable allBundles, IEnumerable uninstallableBundles, bool[] sdkAllowed, bool[] runtimeAllowed) { - using var scope = new AssertionScope(); - scope.AddReportable("allBundles", () => String.Join(Environment.NewLine, allBundles.Select(b => b.ToDebugString()))); - scope.AddReportable("uninstallableBundles", () => String.Join(Environment.NewLine, uninstallableBundles.Select(b => b.ToDebugString()))); + var chain = AssertionChain.GetOrCreate(); + chain.AddReportable("allBundles", () => String.Join(Environment.NewLine, allBundles.Select(b => b.ToDebugString()))); + chain.AddReportable("uninstallableBundles", () => String.Join(Environment.NewLine, uninstallableBundles.Select(b => b.ToDebugString()))); var sdkBundles = allBundles.Where(bundle => bundle.Version is SdkVersion).ToArray(); var runtimeBundles = allBundles.Where(bundle => bundle.Version is RuntimeVersion).ToArray(); var otherBundles = allBundles.Except(sdkBundles).Except(runtimeBundles); diff --git a/test/dotnet-core-uninstall.Tests/dotnet-core-uninstall.Tests.csproj b/test/dotnet-core-uninstall.Tests/dotnet-core-uninstall.Tests.csproj index abfcfdca..e5351147 100644 --- a/test/dotnet-core-uninstall.Tests/dotnet-core-uninstall.Tests.csproj +++ b/test/dotnet-core-uninstall.Tests/dotnet-core-uninstall.Tests.csproj @@ -4,7 +4,7 @@ - + From fb08874b1e7d7c7153272c68bede9a18be9f2293 Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Wed, 12 Mar 2025 13:51:11 -0700 Subject: [PATCH 2/2] Remove unused using directive --- .../Shared/VSVersioning/VSVersionTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs b/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs index f343da5d..8c36e183 100644 --- a/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs +++ b/test/dotnet-core-uninstall.Tests/Shared/VSVersioning/VSVersionTests.cs @@ -1,7 +1,6 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; -using System.Reflection.Metadata; using FluentAssertions; using FluentAssertions.Execution; using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo;