From 6b1017ddc9fe319c22abd9b06693b496cab2189d Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 9 Dec 2024 19:01:34 +1100 Subject: [PATCH] remove param values where same as default (#4286) --- .../Hosts/TestHostBuilder.cs | 4 ++-- .../Services/CurrentTestApplicationModuleInfo.cs | 2 +- .../Extensions/VerifyE2E.cs | 4 ++-- .../DiagnosticTests.cs | 2 +- .../DiscoverInternalsProject/UnitTest1.cs | 2 +- .../DynamicDataTestProject/DynamicDataTests.cs | 14 ++++++-------- .../DynamicDataAttributeTests.cs | 6 +++--- .../Helpers/DictionaryHelperTests.cs | 8 ++++---- .../Logging/FileLoggerTests.cs | 2 +- 9 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs b/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs index 2bee5296da..9b19eea139 100644 --- a/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs +++ b/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs @@ -383,7 +383,7 @@ await LogTestHostCreatedAsync( // Check if we're in the test host or we should check test controllers extensions // Environment variable check should not be needed but in case we will rollback to use only env var we will need it. if ((!testHostControllerInfo.HasTestHostController || - systemEnvironment.GetEnvironmentVariable($"{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_SKIPEXTENSION}_{testHostControllerInfo.GetTestHostControllerPID(true)}") != "1") + systemEnvironment.GetEnvironmentVariable($"{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_SKIPEXTENSION}_{testHostControllerInfo.GetTestHostControllerPID()}") != "1") && !commandLineHandler.IsOptionSet(PlatformCommandLineProvider.DiscoverTestsOptionKey)) { PassiveNode? passiveNode = null; @@ -537,7 +537,7 @@ await LogTestHostCreatedAsync( return null; } - string pipeEnvironmentVariable = $"{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_PIPENAME}_{testHostControllerInfo.GetTestHostControllerPID(true)}"; + string pipeEnvironmentVariable = $"{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_PIPENAME}_{testHostControllerInfo.GetTestHostControllerPID()}"; string pipeName = environment.GetEnvironmentVariable(pipeEnvironmentVariable) ?? throw new InvalidOperationException($"Unexpected null pipe name from environment variable '{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_PIPENAME}'"); // RemoveVariable the environment variable so that it doesn't get passed to the eventually children processes diff --git a/src/Platform/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs b/src/Platform/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs index 5053c18b19..15c7d4a418 100644 --- a/src/Platform/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs +++ b/src/Platform/Microsoft.Testing.Platform/Services/CurrentTestApplicationModuleInfo.cs @@ -22,7 +22,7 @@ public bool IsCurrentTestApplicationHostDotnetMuxer { get { - string? processPath = GetProcessPath(_environment, _process, false); + string? processPath = GetProcessPath(_environment, _process); return processPath is not null && Path.GetFileNameWithoutExtension(processPath) == "dotnet"; } diff --git a/test/IntegrationTests/MSTest.IntegrationTests/Extensions/VerifyE2E.cs b/test/IntegrationTests/MSTest.IntegrationTests/Extensions/VerifyE2E.cs index 924ca20614..9d69238a49 100644 --- a/test/IntegrationTests/MSTest.IntegrationTests/Extensions/VerifyE2E.cs +++ b/test/IntegrationTests/MSTest.IntegrationTests/Extensions/VerifyE2E.cs @@ -41,13 +41,13 @@ public static void TestsFailed(IEnumerable actual, params string[] e => ContainsExpectedTestsWithOutcome(actual, TestOutcome.Failed, expectedTests, true); public static void ContainsTestsPassed(IEnumerable actual, IEnumerable testCases, IEnumerable expectedTests, MSTestSettings settings = null) - => ContainsExpectedTestsWithOutcome(actual, TestOutcome.Passed, expectedTests, false); + => ContainsExpectedTestsWithOutcome(actual, TestOutcome.Passed, expectedTests); public static void ContainsTestsPassed(IEnumerable actual, params string[] expectedTests) => ContainsExpectedTestsWithOutcome(actual, TestOutcome.Passed, expectedTests); public static void ContainsTestsFailed(IEnumerable actual, IEnumerable testCases, IEnumerable expectedTests, MSTestSettings settings = null) - => ContainsExpectedTestsWithOutcome(actual, TestOutcome.Failed, expectedTests, false); + => ContainsExpectedTestsWithOutcome(actual, TestOutcome.Failed, expectedTests); public static void ContainsTestsFailed(IEnumerable actual, params string[] expectedTests) => ContainsExpectedTestsWithOutcome(actual, TestOutcome.Failed, expectedTests); diff --git a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DiagnosticTests.cs b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DiagnosticTests.cs index da4f899172..65eaeb6028 100644 --- a/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DiagnosticTests.cs +++ b/test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DiagnosticTests.cs @@ -133,7 +133,7 @@ public async Task Diag_EnableWithEnvironmentVariables_Verbosity_Succeeded(string { EnvironmentVariableConstants.TESTINGPLATFORM_DIAGNOSTIC_VERBOSITY, "Trace" }, }); - await AssertDiagnosticReportWasGeneratedAsync(testHostResult, diagPathPattern, "Trace"); + await AssertDiagnosticReportWasGeneratedAsync(testHostResult, diagPathPattern); } [ArgumentsProvider(nameof(TargetFrameworks.All), typeof(TargetFrameworks))] diff --git a/test/IntegrationTests/TestAssets/DiscoverInternalsProject/UnitTest1.cs b/test/IntegrationTests/TestAssets/DiscoverInternalsProject/UnitTest1.cs index aa2f02e272..bef73871c7 100644 --- a/test/IntegrationTests/TestAssets/DiscoverInternalsProject/UnitTest1.cs +++ b/test/IntegrationTests/TestAssets/DiscoverInternalsProject/UnitTest1.cs @@ -56,7 +56,7 @@ internal sealed class SerializableInternalType; internal class DynamicDataTest { [DataTestMethod] - [DynamicData(nameof(DynamicData), DynamicDataSourceType.Property)] + [DynamicData(nameof(DynamicData))] internal void DynamicDataTestMethod(SerializableInternalType serializableInternalType) { } diff --git a/test/IntegrationTests/TestAssets/DynamicDataTestProject/DynamicDataTests.cs b/test/IntegrationTests/TestAssets/DynamicDataTestProject/DynamicDataTests.cs index f52f036ab7..bc467c3057 100644 --- a/test/IntegrationTests/TestAssets/DynamicDataTestProject/DynamicDataTests.cs +++ b/test/IntegrationTests/TestAssets/DynamicDataTestProject/DynamicDataTests.cs @@ -22,7 +22,7 @@ public class DynamicDataTests public void DynamicDataTest_SourceMethod(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); [DataTestMethod] - [DynamicData(nameof(ParseUserData), DynamicDataSourceType.Property)] + [DynamicData(nameof(ParseUserData))] public void DynamicDataTest_SourceProperty(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); [DataTestMethod] @@ -31,8 +31,7 @@ public class DynamicDataTests public void DynamicDataTest_SourceMethod_CustomDisplayName(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); [DataTestMethod] - [DynamicData(nameof(ParseUserData), DynamicDataSourceType.Property, - DynamicDataDisplayName = nameof(GetCustomDynamicDataDisplayName))] + [DynamicData(nameof(ParseUserData), DynamicDataDisplayName = nameof(GetCustomDynamicDataDisplayName))] public void DynamicDataTest_SourceProperty_CustomDisplayName(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); [DataTestMethod] @@ -41,8 +40,7 @@ public class DynamicDataTests public void DynamicDataTest_SourceMethod_CustomDisplayNameOtherType(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); // todo [DataTestMethod] - [DynamicData(nameof(ParseUserData), DynamicDataSourceType.Property, - DynamicDataDisplayName = nameof(DataProvider.GetUserDynamicDataDisplayName), DynamicDataDisplayNameDeclaringType = typeof(DataProvider))] + [DynamicData(nameof(ParseUserData), DynamicDataDisplayName = nameof(DataProvider.GetUserDynamicDataDisplayName), DynamicDataDisplayNameDeclaringType = typeof(DataProvider))] public void DynamicDataTest_SourceProperty_CustomDisplayNameOtherType(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); // todo [DataTestMethod] @@ -50,7 +48,7 @@ public class DynamicDataTests public void DynamicDataTest_SourceMethodOtherType(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); [DataTestMethod] - [DynamicData(nameof(DataProvider.UserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataSourceType.Property)] + [DynamicData(nameof(DataProvider.UserDataAndExceptedParsedUser), typeof(DataProvider))] public void DynamicDataTest_SourcePropertyOtherType(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); [DataTestMethod] @@ -59,7 +57,7 @@ public class DynamicDataTests public void DynamicDataTest_SourceMethodOtherType_CustomDisplayName(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); [DataTestMethod] - [DynamicData(nameof(DataProvider.UserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataSourceType.Property, + [DynamicData(nameof(DataProvider.UserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataDisplayName = nameof(GetCustomDynamicDataDisplayName))] public void DynamicDataTest_SourcePropertyOtherType_CustomDisplayName(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); @@ -69,7 +67,7 @@ public class DynamicDataTests public void DynamicDataTest_SourceMethodOtherType_CustomDisplayNameOtherType(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); [DataTestMethod] - [DynamicData(nameof(DataProvider.UserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataSourceType.Property, + [DynamicData(nameof(DataProvider.UserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataDisplayName = nameof(DataProvider.GetUserDynamicDataDisplayName), DynamicDataDisplayNameDeclaringType = typeof(DataProvider))] public void DynamicDataTest_SourcePropertyOtherType_CustomDisplayNameOtherType(string userData, User expectedUser) => ParseAndAssert(userData, expectedUser); diff --git a/test/UnitTests/MSTestAdapter.UnitTests/DynamicDataAttributeTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/DynamicDataAttributeTests.cs index 60162cf013..cad1caf3e4 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/DynamicDataAttributeTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/DynamicDataAttributeTests.cs @@ -244,7 +244,7 @@ public void GetDisplayNameForMultipleArraysOfArraysOfMultipleItems() public void DynamicDataSource_WithTuple_Works() { MethodInfo testMethodInfo = new TestClassTupleData().GetType().GetTypeInfo().GetDeclaredMethod(nameof(TestClassTupleData.DynamicDataTestWithTuple)); - var dynamicDataAttribute = new DynamicDataAttribute(nameof(TestClassTupleData.DataWithTuple), typeof(TestClassTupleData), DynamicDataSourceType.Property); + var dynamicDataAttribute = new DynamicDataAttribute(nameof(TestClassTupleData.DataWithTuple), typeof(TestClassTupleData)); dynamicDataAttribute.GetData(testMethodInfo); dynamicDataAttribute = new DynamicDataAttribute(nameof(TestClassTupleData.GetDataWithTuple), typeof(TestClassTupleData), DynamicDataSourceType.Method); @@ -254,7 +254,7 @@ public void DynamicDataSource_WithTuple_Works() public void DynamicDataSource_WithValueTuple_Works() { MethodInfo testMethodInfo = new TestClassTupleData().GetType().GetTypeInfo().GetDeclaredMethod(nameof(TestClassTupleData.DynamicDataTestWithTuple)); - var dynamicDataAttribute = new DynamicDataAttribute(nameof(TestClassTupleData.DataWithValueTuple), typeof(TestClassTupleData), DynamicDataSourceType.Property); + var dynamicDataAttribute = new DynamicDataAttribute(nameof(TestClassTupleData.DataWithValueTuple), typeof(TestClassTupleData)); dynamicDataAttribute.GetData(testMethodInfo); dynamicDataAttribute = new DynamicDataAttribute(nameof(TestClassTupleData.GetDataWithValueTuple), typeof(TestClassTupleData), DynamicDataSourceType.Method); @@ -264,7 +264,7 @@ public void DynamicDataSource_WithValueTuple_Works() public void DynamicDataSource_WithValueTupleWithTupleSyntax_Works() { MethodInfo testMethodInfo = new TestClassTupleData().GetType().GetTypeInfo().GetDeclaredMethod(nameof(TestClassTupleData.DynamicDataTestWithTuple)); - var dynamicDataAttribute = new DynamicDataAttribute(nameof(TestClassTupleData.DataWithValueTupleWithTupleSyntax), typeof(TestClassTupleData), DynamicDataSourceType.Property); + var dynamicDataAttribute = new DynamicDataAttribute(nameof(TestClassTupleData.DataWithValueTupleWithTupleSyntax), typeof(TestClassTupleData)); dynamicDataAttribute.GetData(testMethodInfo); dynamicDataAttribute = new DynamicDataAttribute(nameof(TestClassTupleData.GetDataWithValueTupleWithTupleSyntax), typeof(TestClassTupleData), DynamicDataSourceType.Method); diff --git a/test/UnitTests/MSTestAdapter.UnitTests/Helpers/DictionaryHelperTests.cs b/test/UnitTests/MSTestAdapter.UnitTests/Helpers/DictionaryHelperTests.cs index c1ae684171..0872333d45 100644 --- a/test/UnitTests/MSTestAdapter.UnitTests/Helpers/DictionaryHelperTests.cs +++ b/test/UnitTests/MSTestAdapter.UnitTests/Helpers/DictionaryHelperTests.cs @@ -15,7 +15,7 @@ public void ConcatenatingDictionariesReturnsEmptyDictionaryWhenBothSidesAreNullO var overwrite = new Dictionary(); - IDictionary actual = source.ConcatWithOverwrites(overwrite, nameof(source), nameof(overwrite)); + IDictionary actual = source.ConcatWithOverwrites(overwrite); var expected = new Dictionary(); actual.ToList().Sort(); @@ -33,7 +33,7 @@ public void ConcatenatingDictionariesReturnsSourceSideWhenOverwriteIsNullOrEmpty Dictionary overwrite = null; - IDictionary actual = source.ConcatWithOverwrites(overwrite, nameof(source), nameof(overwrite)); + IDictionary actual = source.ConcatWithOverwrites(overwrite); IOrderedEnumerable> sortedActual = from entry in actual orderby entry.Key select entry; IOrderedEnumerable> sortedSource = from entry in source orderby entry.Key select entry; @@ -50,7 +50,7 @@ public void ConcatenatingDictionariesReturnsOverwriteSideWhenSourceIsNullOrEmpty ["bbb"] = "overwrite", }; - IDictionary actual = source.ConcatWithOverwrites(overwrite, nameof(source), nameof(overwrite)); + IDictionary actual = source.ConcatWithOverwrites(overwrite); IOrderedEnumerable> sortedActual = from entry in actual orderby entry.Key select entry; IOrderedEnumerable> sortedOverwrite = from entry in overwrite orderby entry.Key select entry; @@ -71,7 +71,7 @@ public void ConcatenatingDictionariesShouldMergeThemAndTakeDuplicateKeysFromOver ["ccc"] = "overwrite", }; - IDictionary actual = source.ConcatWithOverwrites(overwrite, nameof(source), nameof(overwrite)); + IDictionary actual = source.ConcatWithOverwrites(overwrite); var expected = new Dictionary { // this is only present in source, take it diff --git a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Logging/FileLoggerTests.cs b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Logging/FileLoggerTests.cs index b26ea68c65..e770711541 100644 --- a/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Logging/FileLoggerTests.cs +++ b/test/UnitTests/Microsoft.Testing.Platform.UnitTests/Logging/FileLoggerTests.cs @@ -50,7 +50,7 @@ public void Write_IfMalformedUTF8_ShouldNotCrash() { using TempDirectory tempDirectory = new(nameof(Write_IfMalformedUTF8_ShouldNotCrash)); using FileLogger fileLogger = new( - new FileLoggerOptions(tempDirectory.Path, "Test", fileName: null, true), + new FileLoggerOptions(tempDirectory.Path, "Test", fileName: null), LogLevel.Trace, new SystemClock(), new SystemTask(),