From cf00f53765c4e89eab2673d3628e77d9ae64316f Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 21 Dec 2024 19:21:54 +1100 Subject: [PATCH] invoke methods as extension methods --- .../MSTest.TestAdapter/Execution/TestMethodInfo.cs | 2 +- .../MSTest.TestAdapter/Execution/TestMethodRunner.cs | 2 +- .../TestingPlatformBuilderHook.cs | 2 +- .../Extensions/UnitTestOutcomeExtensionsTests.cs | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Adapter/MSTest.TestAdapter/Execution/TestMethodInfo.cs b/src/Adapter/MSTest.TestAdapter/Execution/TestMethodInfo.cs index 259903d3d4..9d2b627aff 100644 --- a/src/Adapter/MSTest.TestAdapter/Execution/TestMethodInfo.cs +++ b/src/Adapter/MSTest.TestAdapter/Execution/TestMethodInfo.cs @@ -652,7 +652,7 @@ private bool RunTestInitializeMethod(object classInstance, TestResult result) // Prefix the exception message with the exception type name as prefix when exception is not assert exception. string exceptionMessage = realException is UnitTestAssertException ? realException.TryGetMessage() - : ExceptionHelper.GetFormattedExceptionMessage(realException); + : realException.GetFormattedExceptionMessage(); string errorMessage = string.Format( CultureInfo.CurrentCulture, Resource.UTA_InitMethodThrows, diff --git a/src/Adapter/MSTest.TestAdapter/Execution/TestMethodRunner.cs b/src/Adapter/MSTest.TestAdapter/Execution/TestMethodRunner.cs index 017f45b100..1b68d21d94 100644 --- a/src/Adapter/MSTest.TestAdapter/Execution/TestMethodRunner.cs +++ b/src/Adapter/MSTest.TestAdapter/Execution/TestMethodRunner.cs @@ -447,7 +447,7 @@ private static UTF.UnitTestOutcome GetAggregateOutcome(List results) UTF.UnitTestOutcome aggregateOutcome = results[0].Outcome; foreach (TestResult result in results) { - aggregateOutcome = UnitTestOutcomeExtensions.GetMoreImportantOutcome(aggregateOutcome, result.Outcome); + aggregateOutcome = aggregateOutcome.GetMoreImportantOutcome(result.Outcome); } return aggregateOutcome; diff --git a/src/Platform/Microsoft.Testing.Extensions.MSBuild/TestingPlatformBuilderHook.cs b/src/Platform/Microsoft.Testing.Extensions.MSBuild/TestingPlatformBuilderHook.cs index 53e32087d3..badb923f0d 100644 --- a/src/Platform/Microsoft.Testing.Extensions.MSBuild/TestingPlatformBuilderHook.cs +++ b/src/Platform/Microsoft.Testing.Extensions.MSBuild/TestingPlatformBuilderHook.cs @@ -8,5 +8,5 @@ namespace Microsoft.Testing.Platform.MSBuild; public static class TestingPlatformBuilderHook { public static void AddExtensions(ITestApplicationBuilder testApplicationBuilder, string[] _) - => MSBuildExtensions.AddMSBuild(testApplicationBuilder); + => testApplicationBuilder.AddMSBuild(); } diff --git a/test/UnitTests/MSTestAdapter.UnitTests/Extensions/UnitTestOutcomeExtensionsTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/Extensions/UnitTestOutcomeExtensionsTests.cs index 852811883e..77c056e763 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/Extensions/UnitTestOutcomeExtensionsTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/Extensions/UnitTestOutcomeExtensionsTests.cs @@ -62,25 +62,25 @@ public void ToUnitTestResultsForUnknownTestResultsConvertsToErrorUnitTestResults public void GetMoreImportantOutcomeShouldReturnFailIfTwoOutcomesAreFailedAndInconclusive() { - UTF.UnitTestOutcome resultOutcome = UnitTestOutcomeExtensions.GetMoreImportantOutcome(UTF.UnitTestOutcome.Failed, UTF.UnitTestOutcome.Inconclusive); + UTF.UnitTestOutcome resultOutcome = UTF.UnitTestOutcome.Failed.GetMoreImportantOutcome(UTF.UnitTestOutcome.Inconclusive); Verify(resultOutcome == UTF.UnitTestOutcome.Failed); } public void GetMoreImportantOutcomeShouldReturnInconclusiveIfTwoOutcomesArePassedAndInconclusive() { - UTF.UnitTestOutcome resultOutcome = UnitTestOutcomeExtensions.GetMoreImportantOutcome(UTF.UnitTestOutcome.Passed, UTF.UnitTestOutcome.Inconclusive); + UTF.UnitTestOutcome resultOutcome = UTF.UnitTestOutcome.Passed.GetMoreImportantOutcome(UTF.UnitTestOutcome.Inconclusive); Verify(resultOutcome == UTF.UnitTestOutcome.Inconclusive); } public void GetMoreImportantOutcomeShouldReturnFailedIfTwoOutcomesArePassedAndFailed() { - UTF.UnitTestOutcome resultOutcome = UnitTestOutcomeExtensions.GetMoreImportantOutcome(UTF.UnitTestOutcome.Passed, UTF.UnitTestOutcome.Failed); + UTF.UnitTestOutcome resultOutcome = UTF.UnitTestOutcome.Passed.GetMoreImportantOutcome(UTF.UnitTestOutcome.Failed); Verify(resultOutcome == UTF.UnitTestOutcome.Failed); } public void GetMoreImportantOutcomeShouldReturnFailedIfBothOutcomesAreFailed() { - UTF.UnitTestOutcome resultOutcome = UnitTestOutcomeExtensions.GetMoreImportantOutcome(UTF.UnitTestOutcome.Failed, UTF.UnitTestOutcome.Failed); + UTF.UnitTestOutcome resultOutcome = UTF.UnitTestOutcome.Failed.GetMoreImportantOutcome(UTF.UnitTestOutcome.Failed); Verify(resultOutcome == UTF.UnitTestOutcome.Failed); } }