diff --git a/src/EditorFeatures/TestUtilities/Threading/WpfFactDiscoverer.cs b/src/EditorFeatures/TestUtilities/Threading/WpfFactDiscoverer.cs index 6d6d2ff178b34ee363925730dd2136624253fe50..d2ebf0b72854a6dc9ca9aa2d16990764fdb1a153 100644 --- a/src/EditorFeatures/TestUtilities/Threading/WpfFactDiscoverer.cs +++ b/src/EditorFeatures/TestUtilities/Threading/WpfFactDiscoverer.cs @@ -9,38 +9,34 @@ namespace Roslyn.Test.Utilities public class WpfFactDiscoverer : FactDiscoverer { private readonly IMessageSink _diagnosticMessageSink; - private readonly IDictionary _passedTests; public WpfFactDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink) { _diagnosticMessageSink = diagnosticMessageSink; - _passedTests = TestInfo.GetPassedTestsInfo(); } protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) - => new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, _passedTests); + => new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod); } public class WpfTheoryDiscoverer : TheoryDiscoverer { private readonly IMessageSink _diagnosticMessageSink; - private readonly IDictionary _passedTests; public WpfTheoryDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink) { _diagnosticMessageSink = diagnosticMessageSink; - _passedTests = TestInfo.GetPassedTestsInfo(); } protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) { - var testCase = new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, _passedTests, dataRow); + var testCase = new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, dataRow); return new[] { testCase }; } protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) { - var testCase = new WpfTheoryTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, _passedTests); + var testCase = new WpfTheoryTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod); return new[] { testCase }; } } diff --git a/src/EditorFeatures/TestUtilities/Threading/WpfTestCase.cs b/src/EditorFeatures/TestUtilities/Threading/WpfTestCase.cs index bd19eebb191d87c261d8ea02e6a78f8fe7e60166..ded0bd6ef9e564c470962d748eb5e3a6f8f2abd7 100644 --- a/src/EditorFeatures/TestUtilities/Threading/WpfTestCase.cs +++ b/src/EditorFeatures/TestUtilities/Threading/WpfTestCase.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.ComponentModel; using System.Threading; using System.Threading.Tasks; @@ -12,24 +11,20 @@ namespace Roslyn.Test.Utilities { public sealed class WpfTestCase : XunitTestCase { - private readonly IDictionary _passedTests; - [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] public WpfTestCase() { - _passedTests = new Dictionary(); } - public WpfTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, IDictionary passedTests, object[] testMethodArguments = null) + public WpfTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { - _passedTests = passedTests; } public override Task RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { - var runner = new WpfTestCaseRunner(WpfTestSharedData.Instance, this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, _passedTests, cancellationTokenSource); + var runner = new WpfTestCaseRunner(WpfTestSharedData.Instance, this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource); return runner.RunAsync(); } } diff --git a/src/EditorFeatures/TestUtilities/Threading/WpfTestCaseRunner.cs b/src/EditorFeatures/TestUtilities/Threading/WpfTestCaseRunner.cs index ff7524feab332d71eadd6d1d903ea914af5114b9..259382bca800ca7474c125073669f362e219b084 100644 --- a/src/EditorFeatures/TestUtilities/Threading/WpfTestCaseRunner.cs +++ b/src/EditorFeatures/TestUtilities/Threading/WpfTestCaseRunner.cs @@ -12,7 +12,6 @@ namespace Roslyn.Test.Utilities public sealed class WpfTestCaseRunner : XunitTestCaseRunner { public WpfTestSharedData SharedData { get; } - public readonly IDictionary _passedTests; public WpfTestCaseRunner( WpfTestSharedData sharedData, @@ -23,17 +22,15 @@ public sealed class WpfTestCaseRunner : XunitTestCaseRunner object[] testMethodArguments, IMessageBus messageBus, ExceptionAggregator aggregator, - IDictionary passedTests, CancellationTokenSource cancellationTokenSource) : base(testCase, displayName, skipReason, constructorArguments, testMethodArguments, messageBus, aggregator, cancellationTokenSource) { SharedData = sharedData; - _passedTests = passedTests; } protected override XunitTestRunner CreateTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { - var runner = new WpfTestRunner(SharedData, test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, _passedTests, cancellationTokenSource); + var runner = new WpfTestRunner(SharedData, test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource); return runner; } } diff --git a/src/EditorFeatures/TestUtilities/Threading/WpfTestRunner.cs b/src/EditorFeatures/TestUtilities/Threading/WpfTestRunner.cs index bebab22004800e63c735018d76d7383bf3b8fe84..95e4d04b32c72b6cb1f4975b3ac822e40150b55a 100644 --- a/src/EditorFeatures/TestUtilities/Threading/WpfTestRunner.cs +++ b/src/EditorFeatures/TestUtilities/Threading/WpfTestRunner.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics; using System.Reflection; using System.Threading; @@ -25,10 +26,15 @@ namespace Roslyn.Test.Utilities /// public sealed class WpfTestRunner : XunitTestRunner { + private static readonly ImmutableDictionary _passedTests; private static string s_wpfFactRequirementReason; public WpfTestSharedData SharedData { get; } - public readonly IDictionary _passedTests; + + static WpfTestRunner() + { + _passedTests = TestInfo.GetPassedTestsInfo(); + } public WpfTestRunner( WpfTestSharedData sharedData, @@ -41,12 +47,10 @@ public sealed class WpfTestRunner : XunitTestRunner string skipReason, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, - IDictionary passedTests, CancellationTokenSource cancellationTokenSource) : base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource) { SharedData = sharedData; - _passedTests = passedTests; } protected override Task InvokeTestMethodAsync(ExceptionAggregator aggregator) diff --git a/src/EditorFeatures/TestUtilities/Threading/WpfTheoryTestCase.cs b/src/EditorFeatures/TestUtilities/Threading/WpfTheoryTestCase.cs index 3221811202c6d596412ce7d183891f19336c77e8..7006d89d104907c7ec56e7c97e56367b3e3935e0 100644 --- a/src/EditorFeatures/TestUtilities/Threading/WpfTheoryTestCase.cs +++ b/src/EditorFeatures/TestUtilities/Threading/WpfTheoryTestCase.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.ComponentModel; using System.Threading; using System.Threading.Tasks; @@ -12,24 +11,20 @@ namespace Roslyn.Test.Utilities { public class WpfTheoryTestCase : XunitTheoryTestCase { - public readonly IDictionary _passedTests; - [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] public WpfTheoryTestCase() { - _passedTests = new Dictionary(); } - public WpfTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, IDictionary passedTests) + public WpfTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { - _passedTests = passedTests; } public override Task RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { - var runner = new WpfTheoryTestCaseRunner(WpfTestSharedData.Instance, this, DisplayName, SkipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, _passedTests, cancellationTokenSource); + var runner = new WpfTheoryTestCaseRunner(WpfTestSharedData.Instance, this, DisplayName, SkipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource); return runner.RunAsync(); } } diff --git a/src/EditorFeatures/TestUtilities/Threading/WpfTheoryTestCaseRunner.cs b/src/EditorFeatures/TestUtilities/Threading/WpfTheoryTestCaseRunner.cs index 90bb9f14cc1f5b9d5db939a26e6cc4494d7bea7f..8a14f67abf7d9683b3dcebf8fd48d48087336d82 100644 --- a/src/EditorFeatures/TestUtilities/Threading/WpfTheoryTestCaseRunner.cs +++ b/src/EditorFeatures/TestUtilities/Threading/WpfTheoryTestCaseRunner.cs @@ -12,7 +12,6 @@ namespace Roslyn.Test.Utilities public class WpfTheoryTestCaseRunner : XunitTheoryTestCaseRunner { public WpfTestSharedData SharedData { get; } - public readonly IDictionary _passedTests; public WpfTheoryTestCaseRunner( WpfTestSharedData sharedData, @@ -23,17 +22,15 @@ public class WpfTheoryTestCaseRunner : XunitTheoryTestCaseRunner IMessageSink diagnosticMessageSink, IMessageBus messageBus, ExceptionAggregator aggregator, - IDictionary passedTests, CancellationTokenSource cancellationTokenSource) : base(testCase, displayName, skipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource) { SharedData = sharedData; - _passedTests = passedTests; } protected override XunitTestRunner CreateTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { - var runner = new WpfTestRunner(SharedData, test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, _passedTests, cancellationTokenSource); + var runner = new WpfTestRunner(SharedData, test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource); return runner; } }