Skip to content

Commit

Permalink
remove param values where same as default (#4286)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Dec 9, 2024
1 parent e871a5e commit 6b1017d
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public static void TestsFailed(IEnumerable<TestResult> actual, params string[] e
=> ContainsExpectedTestsWithOutcome(actual, TestOutcome.Failed, expectedTests, true);

public static void ContainsTestsPassed(IEnumerable<TestResult> actual, IEnumerable<TestCase> testCases, IEnumerable<string> expectedTests, MSTestSettings settings = null)
=> ContainsExpectedTestsWithOutcome(actual, TestOutcome.Passed, expectedTests, false);
=> ContainsExpectedTestsWithOutcome(actual, TestOutcome.Passed, expectedTests);

public static void ContainsTestsPassed(IEnumerable<TestResult> actual, params string[] expectedTests)
=> ContainsExpectedTestsWithOutcome(actual, TestOutcome.Passed, expectedTests);

public static void ContainsTestsFailed(IEnumerable<TestResult> actual, IEnumerable<TestCase> testCases, IEnumerable<string> expectedTests, MSTestSettings settings = null)
=> ContainsExpectedTestsWithOutcome(actual, TestOutcome.Failed, expectedTests, false);
=> ContainsExpectedTestsWithOutcome(actual, TestOutcome.Failed, expectedTests);

public static void ContainsTestsFailed(IEnumerable<TestResult> actual, params string[] expectedTests)
=> ContainsExpectedTestsWithOutcome(actual, TestOutcome.Failed, expectedTests);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -41,16 +40,15 @@ 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]
[DynamicData(nameof(DataProvider.GetUserDataAndExceptedParsedUser), typeof(DataProvider), DynamicDataSourceType.Method)]
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]
Expand All @@ -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);

Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void ConcatenatingDictionariesReturnsEmptyDictionaryWhenBothSidesAreNullO

var overwrite = new Dictionary<string, string>();

IDictionary<string, string> actual = source.ConcatWithOverwrites(overwrite, nameof(source), nameof(overwrite));
IDictionary<string, string> actual = source.ConcatWithOverwrites(overwrite);
var expected = new Dictionary<string, string>();

actual.ToList().Sort();
Expand All @@ -33,7 +33,7 @@ public void ConcatenatingDictionariesReturnsSourceSideWhenOverwriteIsNullOrEmpty

Dictionary<string, string> overwrite = null;

IDictionary<string, string> actual = source.ConcatWithOverwrites(overwrite, nameof(source), nameof(overwrite));
IDictionary<string, string> actual = source.ConcatWithOverwrites(overwrite);

IOrderedEnumerable<KeyValuePair<string, string>> sortedActual = from entry in actual orderby entry.Key select entry;
IOrderedEnumerable<KeyValuePair<string, string>> sortedSource = from entry in source orderby entry.Key select entry;
Expand All @@ -50,7 +50,7 @@ public void ConcatenatingDictionariesReturnsOverwriteSideWhenSourceIsNullOrEmpty
["bbb"] = "overwrite",
};

IDictionary<string, string> actual = source.ConcatWithOverwrites(overwrite, nameof(source), nameof(overwrite));
IDictionary<string, string> actual = source.ConcatWithOverwrites(overwrite);

IOrderedEnumerable<KeyValuePair<string, string>> sortedActual = from entry in actual orderby entry.Key select entry;
IOrderedEnumerable<KeyValuePair<string, string>> sortedOverwrite = from entry in overwrite orderby entry.Key select entry;
Expand All @@ -71,7 +71,7 @@ public void ConcatenatingDictionariesShouldMergeThemAndTakeDuplicateKeysFromOver
["ccc"] = "overwrite",
};

IDictionary<string, string> actual = source.ConcatWithOverwrites(overwrite, nameof(source), nameof(overwrite));
IDictionary<string, string> actual = source.ConcatWithOverwrites(overwrite);
var expected = new Dictionary<string, string>
{
// this is only present in source, take it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 6b1017d

Please sign in to comment.