diff --git a/playground/MSTest1/UnitTest1.cs b/playground/MSTest1/UnitTest1.cs index aa92d18eef..aba9b282d2 100644 --- a/playground/MSTest1/UnitTest1.cs +++ b/playground/MSTest1/UnitTest1.cs @@ -3,8 +3,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -#nullable disable - namespace MSTest1; [TestClass] diff --git a/playground/TestPlatform.Playground/Program.cs b/playground/TestPlatform.Playground/Program.cs index e096d723ef..3520b7b67b 100644 --- a/playground/TestPlatform.Playground/Program.cs +++ b/playground/TestPlatform.Playground/Program.cs @@ -15,8 +15,6 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; -#nullable disable - namespace TestPlatform.Playground; internal class Program @@ -205,10 +203,10 @@ public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessSta throw new NotImplementedException(); } - private static string WriteTests(IEnumerable testResults) + private static string WriteTests(IEnumerable? testResults) => WriteTests(testResults?.Select(t => t.TestCase)); - private static string WriteTests(IEnumerable testCases) + private static string WriteTests(IEnumerable? testCases) => testCases?.Any() == true ? "\t" + string.Join("\n\t", testCases.Select(r => r.DisplayName)) : "\t"; @@ -242,7 +240,7 @@ public int LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo, Cancell internal class TestSessionHandler : ITestSessionEventsHandler { - public TestSessionInfo TestSessionInfo { get; private set; } + public TestSessionInfo? TestSessionInfo { get; private set; } public void HandleLogMessage(TestMessageLevel level, string message) { diff --git a/scripts/build/ExternalAssemblyVersions.cs b/scripts/build/ExternalAssemblyVersions.cs index 9b258386c3..8eaa1ec38a 100644 --- a/scripts/build/ExternalAssemblyVersions.cs +++ b/scripts/build/ExternalAssemblyVersions.cs @@ -1,14 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform; internal class ExternalAssemblyVersions { /// - /// Refers to the versions of the assemblies retrieved from the + /// Refers to the versions of the assemblies retrieved from the /// Microsoft.QualityTools.Testing.Fakes.TestRunnerHarness package. /// The Package version can be found in "scripts\build\TestPlatform.Dependencies.props" /// diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/ProxyTestSessionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/ProxyTestSessionManager.cs index 4bc8f33b17..afe5e29c4b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/ProxyTestSessionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestSession/ProxyTestSessionManager.cs @@ -67,7 +67,7 @@ private IDictionary TestSessionEnvironmentVariables /// /// Initializes a new instance of the class. /// - /// + /// /// The test session criteria. /// The testhost count. /// The proxy creator. @@ -226,10 +226,10 @@ public virtual bool StopSession(IRequestData requestData) /// /// Dequeues a proxy to be used either by discovery or execution. /// - /// + /// /// The source to be associated to this proxy. /// The run settings. - /// + /// /// The dequeued proxy. public virtual ProxyOperationManager DequeueProxy(string source, string runSettings) { @@ -272,9 +272,9 @@ public virtual ProxyOperationManager DequeueProxy(string source, string runSetti /// /// Enqueues a proxy back once discovery or executions is done with it. /// - /// + /// /// The id of the proxy to be re-enqueued. - /// + /// /// True if the operation succeeded, false otherwise. public virtual bool EnqueueProxy(int proxyId) { @@ -430,7 +430,7 @@ internal class ProxyOperationManagerContainer /// /// Initializes a new instance of the class. /// - /// + /// /// The proxy. /// A flag indicating if the proxy is available to do work. public ProxyOperationManagerContainer(ProxyOperationManager proxy, bool available) diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs index c0a756e51b..fd2d992697 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs @@ -553,6 +553,7 @@ bool SilentlyForceToX64() internal /* for testing purposes */ void ForwardDotnetRootEnvironmentVariable(TestProcessStartInfo startInfo) { + TPDebug.Assert(_targetFramework is not null, "Initialize must have been called before this method."); const string prefix = "VSTEST_WINAPPHOST_"; const string dotnetRoot = "DOTNET_ROOT"; string vstestDotnetRootEnvName = $"{prefix}{dotnetRoot}(x86)"; diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Properties/TestExtensionTypesAttribute.cs b/src/Microsoft.TestPlatform.TestHostProvider/Properties/TestExtensionTypesAttribute.cs index 91cb9503eb..5b493e6cec 100644 --- a/src/Microsoft.TestPlatform.TestHostProvider/Properties/TestExtensionTypesAttribute.cs +++ b/src/Microsoft.TestPlatform.TestHostProvider/Properties/TestExtensionTypesAttribute.cs @@ -3,8 +3,6 @@ using System; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform; /// diff --git a/src/vstest.console/Internal/Interfaces/IConsoleHelper.cs b/src/vstest.console/Internal/Interfaces/IConsoleHelper.cs index 2fbddc51a2..c4b0d91141 100644 --- a/src/vstest.console/Internal/Interfaces/IConsoleHelper.cs +++ b/src/vstest.console/Internal/Interfaces/IConsoleHelper.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Internal; /// diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs index 8d26effd95..e006925c1a 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyDiscoveryManagerTests.cs @@ -17,17 +17,15 @@ using Moq; -#nullable disable - namespace TestPlatform.CrossPlatEngine.UnitTests.Client; [TestClass] public class InProcessProxyDiscoveryManagerTests { - private Mock _mockTestHostManagerFactory; + private readonly Mock _mockTestHostManagerFactory; private InProcessProxyDiscoveryManager _inProcessProxyDiscoveryManager; - private Mock _mockDiscoveryManager; - private Mock _mockTestHostManager; + private readonly Mock _mockDiscoveryManager; + private readonly Mock _mockTestHostManager; public InProcessProxyDiscoveryManagerTests() { @@ -38,15 +36,6 @@ public InProcessProxyDiscoveryManagerTests() _inProcessProxyDiscoveryManager = new InProcessProxyDiscoveryManager(_mockTestHostManager.Object, _mockTestHostManagerFactory.Object); } - [TestCleanup] - public void TestCleanup() - { - _mockDiscoveryManager = null; - _mockTestHostManagerFactory = null; - _inProcessProxyDiscoveryManager = null; - _mockTestHostManager = null; - } - [TestMethod] public void DiscoverTestsShouldCallInitialize() { diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs index 201930cf24..31b3ba61de 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs @@ -18,17 +18,15 @@ using Moq; -#nullable disable - namespace TestPlatform.CrossPlatEngine.UnitTests.Client; [TestClass] public class InProcessProxyExecutionManagerTests { - private Mock _mockTestHostManagerFactory; + private readonly Mock _mockTestHostManagerFactory; private InProcessProxyExecutionManager _inProcessProxyExecutionManager; - private Mock _mockExecutionManager; - private Mock _mockTestHostManager; + private readonly Mock _mockExecutionManager; + private readonly Mock _mockTestHostManager; public InProcessProxyExecutionManagerTests() { @@ -39,16 +37,6 @@ public InProcessProxyExecutionManagerTests() _inProcessProxyExecutionManager = new InProcessProxyExecutionManager(_mockTestHostManager.Object, _mockTestHostManagerFactory.Object); } - [TestCleanup] - public void TestCleanup() - { - _mockExecutionManager = null; - _mockTestHostManagerFactory = null; - _inProcessProxyExecutionManager = null; - _mockTestHostManager = null; - } - - [TestMethod] public void StartTestRunShouldCallInitialize() { @@ -138,7 +126,7 @@ public void StartTestRunShouldUpdateTestCaseSourceIfTestCaseSourceDiffersFromTes Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); _mockExecutionManager.Verify(o => o.StartTestRun(testRunCriteria.Tests, inputSource.FirstOrDefault(), testRunCriteria.TestRunSettings, It.IsAny(), null, null)); _mockTestHostManager.Verify(hm => hm.GetTestSources(inputSource), Times.Once); - Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); + Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault()?.Source); } [TestMethod] @@ -160,7 +148,7 @@ public void StartTestRunShouldNotUpdateTestCaseSourceIfTestCaseSourceDiffersFrom Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); _mockExecutionManager.Verify(o => o.StartTestRun(testRunCriteria.Tests, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null)); _mockTestHostManager.Verify(hm => hm.GetTestSources(actualSources)); - Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); + Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault()?.Source); } [TestMethod] diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyBaseManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyBaseManagerTests.cs index 93e3e8304b..deb9e7ea48 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyBaseManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyBaseManagerTests.cs @@ -19,23 +19,24 @@ using Moq; -#nullable disable - namespace TestPlatform.CrossPlatEngine.UnitTests.Client; [TestClass] public class ProxyBaseManagerTests { private const int Clientprocessexitwait = 10 * 1000; - private Mock _mockCommunicationEndpoint; - private ITestRequestSender _testRequestSender; - readonly ProtocolConfig _protocolConfig = new() { Version = 2 }; + private readonly ProtocolConfig _protocolConfig = new() { Version = 2 }; private readonly Mock _mockRequestData; + private readonly Mock _mockFileHelper; + private readonly DiscoveryDataAggregator _discoveryDataAggregator; + protected readonly Mock _mockTestHostManager; + + private Mock? _mockCommunicationEndpoint; + private ITestRequestSender? _testRequestSender; + protected Mock _mockDataSerializer; protected Mock _mockChannel; - private readonly Mock _mockFileHelper; - private readonly DiscoveryDataAggregator _discoveryDataAggregator; public ProxyBaseManagerTests() { diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs index dbbff3f3bb..448dd8b846 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs @@ -26,21 +26,15 @@ using CrossPlatEngineResources = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Resources; -#nullable disable - namespace TestPlatform.CrossPlatEngine.UnitTests.Client; [TestClass] public class ProxyExecutionManagerTests : ProxyBaseManagerTests { private readonly Mock _mockRequestSender; - private readonly Mock _mockTestRunCriteria; - private readonly Mock _mockRequestData; - private readonly Mock _mockMetricsCollection; - private readonly Mock _mockFileHelper; private ProxyExecutionManager _testExecutionManager; @@ -111,7 +105,7 @@ public void StartTestRunShouldUpdateTestCaseSourceIfTestCaseSourceDiffersFromTes _testExecutionManager.StartTestRun(testRunCriteria, mockTestRunEventsHandler.Object); _mockTestHostManager.Verify(hm => hm.GetTestSources(inputSource), Times.Once); - Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); + Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault()?.Source); } [TestMethod] @@ -133,7 +127,7 @@ public void StartTestRunShouldNotUpdateTestCaseSourceIfTestCaseSourceDoNotDiffer _testExecutionManager.StartTestRun(testRunCriteria, mockTestRunEventsHandler.Object); _mockTestHostManager.Verify(hm => hm.GetTestSources(inputSource), Times.Once); - Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault().Source); + Assert.AreEqual(actualSources.FirstOrDefault(), testRunCriteria.Tests.FirstOrDefault()?.Source); } [TestMethod] @@ -277,7 +271,7 @@ public void StartTestRunShouldInitializeExtensionsIfTestHostIsNotShared() public void StartTestRunShouldInitializeExtensionsWithExistingExtensionsOnly() { TestPluginCache.Instance = null; - TestPluginCache.Instance.UpdateExtensions(new List { "abc.TestAdapter.dll", "def.TestAdapter.dll", "xyz.TestAdapter.dll" }, false); + TestPluginCache.Instance!.UpdateExtensions(new List { "abc.TestAdapter.dll", "def.TestAdapter.dll", "xyz.TestAdapter.dll" }, false); var expectedOutputPaths = new[] { "abc.TestAdapter.dll", "xyz.TestAdapter.dll" }; _mockTestHostManager.SetupGet(th => th.Shared).Returns(false); @@ -436,7 +430,7 @@ public void StartTestRunForAnExceptionDuringLaunchOfTestShouldHandleLogMessageWi [TestMethod] public void StartTestRunShouldInitiateTestRunForSourcesThroughTheServer() { - TestRunCriteriaWithSources testRunCriteriaPassed = null; + TestRunCriteriaWithSources? testRunCriteriaPassed = null; _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); _mockRequestSender.Setup(s => s.StartTestRun(It.IsAny(), _testExecutionManager)) @@ -456,7 +450,7 @@ public void StartTestRunShouldInitiateTestRunForSourcesThroughTheServer() [TestMethod] public void StartTestRunShouldInitiateTestRunForTestsThroughTheServer() { - TestRunCriteriaWithTests testRunCriteriaPassed = null; + TestRunCriteriaWithTests? testRunCriteriaPassed = null; _mockFileHelper.Setup(fh => fh.Exists(It.IsAny())).Returns(true); _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); _mockRequestSender.Setup(s => s.StartTestRun(It.IsAny(), _testExecutionManager)) @@ -801,7 +795,7 @@ private void SignalEvent(ManualResetEvent manualResetEvent) private void InvokeAndVerifyStartTestRun(bool skipDefaultAdapters) { TestPluginCache.Instance = null; - TestPluginCache.Instance.DefaultExtensionPaths = new List { "default1.dll", "default2.dll" }; + TestPluginCache.Instance!.DefaultExtensionPaths = new List { "default1.dll", "default2.dll" }; TestPluginCache.Instance.UpdateExtensions(new List { "filterTestAdapter.dll" }, false); TestPluginCache.Instance.UpdateExtensions(new List { "unfilter.dll" }, true); @@ -822,40 +816,4 @@ private void InvokeAndVerifyStartTestRun(bool skipDefaultAdapters) TestPluginCache.Instance = null; } } - - //private void SetupReceiveRawMessageAsyncAndDeserializeMessageAndInitialize() - //{ - // var connectionInfo = new TestHostConnectionInfo - // { - // Endpoint = IPAddress.Loopback + ":0", - // Role = ConnectionRole.Client, - // Transport = Transport.Sockets - // }; - // this.mockCommunicationEndpoint = new Mock(); - // this.mockDataSerializer = new Mock(); - // this.testRequestSender = new TestRequestSender(this.mockCommunicationEndpoint.Object, connectionInfo, this.mockDataSerializer.Object, this.protocolConfig, CLIENTPROCESSEXITWAIT); - // this.mockCommunicationEndpoint.Setup(mc => mc.Start(connectionInfo.Endpoint)).Returns(connectionInfo.Endpoint).Callback(() => - // { - // this.mockCommunicationEndpoint.Raise( - // s => s.Connected += null, - // this.mockCommunicationEndpoint.Object, - // new ConnectedEventArgs(this.mockChannel.Object)); - // }); - // this.SetupChannelMessage(MessageType.VersionCheck, MessageType.VersionCheck, this.protocolConfig.Version); - - // this.testRequestSender.InitializeCommunication(); - - // this.testExecutionManager = new ProxyExecutionManager(this.mockRequestData.Object, this.testRequestSender, this.mockTestHostManager.Object, this.mockDataSerializer.Object, this.clientConnectionTimeout); - //} - - //private void SetupChannelMessage(string messageType, string returnMessageType, TPayload returnPayload) - //{ - // this.mockChannel.Setup(mc => mc.Send(It.Is(s => s.Contains(messageType)))) - // .Callback(() => this.mockChannel.Raise(c => c.MessageReceived += null, this.mockChannel.Object, new MessageReceivedEventArgs { Data = messageType })); - - // this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny())).Returns(messageType); - // this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is(s => s.Equals(messageType)), It.IsAny(), It.IsAny())).Returns(messageType); - // this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.Is(s => s.Equals(messageType)))).Returns(new Message { MessageType = returnMessageType }); - // this.mockDataSerializer.Setup(ds => ds.DeserializePayload(It.Is(m => m.MessageType.Equals(messageType)))).Returns(returnPayload); - //} } diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerWithDataCollectionTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerWithDataCollectionTests.cs index dd800c67cc..0a466824fa 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerWithDataCollectionTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerWithDataCollectionTests.cs @@ -21,35 +21,23 @@ using Moq; -#nullable disable - namespace TestPlatform.CrossPlatEngine.UnitTests.Client; [TestClass] public class ProxyExecutionManagerWithDataCollectionTests { - private ProxyExecutionManager _testExecutionManager; - - private Mock _mockTestHostManager; - - private Mock _mockRequestSender; - - private Mock _mockDataCollectionManager; - - private Mock _mockProcessHelper; - - private ProxyExecutionManagerWithDataCollection _proxyExecutionManager; - - private Mock _mockDataSerializer; - - private Mock _mockRequestData; - - private Mock _mockMetricsCollection; - - private Mock _mockFileHelper; - - [TestInitialize] - public void TestInit() + private readonly ProxyExecutionManager _testExecutionManager; + private readonly Mock _mockTestHostManager; + private readonly Mock _mockRequestSender; + private readonly Mock _mockDataCollectionManager; + private readonly Mock _mockProcessHelper; + private readonly ProxyExecutionManagerWithDataCollection _proxyExecutionManager; + private readonly Mock _mockDataSerializer; + private readonly Mock _mockRequestData; + private readonly Mock _mockMetricsCollection; + private readonly Mock _mockFileHelper; + + public ProxyExecutionManagerWithDataCollectionTests() { _mockTestHostManager = new Mock(); _mockRequestSender = new Mock(); @@ -168,7 +156,7 @@ public void LaunchProcessWithDebuggerAttachedShouldUpdateEnvironmentVariables() { // Setup var mockRunEventsHandler = new Mock(); - TestProcessStartInfo launchedStartInfo = null; + TestProcessStartInfo? launchedStartInfo = null; mockRunEventsHandler.Setup(runHandler => runHandler.LaunchProcessWithDebuggerAttached(It.IsAny())).Callback ((TestProcessStartInfo startInfo) => launchedStartInfo = startInfo); var proxyExecutionManager = new ProxyExecutionManagerWithDataCollection(_mockRequestData.Object, _mockRequestSender.Object, _mockTestHostManager.Object, Framework.DefaultFramework, _mockDataCollectionManager.Object); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyTestSessionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyTestSessionManagerTests.cs index 34d1f669e8..91cb8983e1 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyTestSessionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyTestSessionManagerTests.cs @@ -15,15 +15,13 @@ using Moq; -#nullable disable - namespace Microsoft.TestPlatform.CrossPlatEngine.UnitTests.Client; [TestClass] public class ProxyTestSessionManagerTests { private readonly IList _fakeTestSources = new List() { @"C:\temp\FakeTestAsset.dll" }; - private Dictionary _fakeTestSourcesToRuntimeProviderMap; + private readonly Dictionary _fakeTestSourcesToRuntimeProviderMap; private readonly IList _fakeTestMultipleSources = new List() { @"C:\temp\FakeTestAsset1.dll", @"C:\temp\FakeTestAsset2.dll", @@ -72,12 +70,11 @@ public class ProxyTestSessionManagerTests "; private readonly string _fakeRunSettings = "FakeRunSettings"; private readonly ProtocolConfig _protocolConfig = new() { Version = 1 }; - private Mock _mockEventsHandler; - private Mock _mockRequestData; - private Mock _mockMetricsCollection; + private readonly Mock _mockEventsHandler; + private readonly Mock _mockRequestData; + private readonly Mock _mockMetricsCollection; - [TestInitialize] - public void TestInitialize() + public ProxyTestSessionManagerTests() { TestSessionPool.Instance = null; @@ -178,7 +175,7 @@ public void StartSessionShouldSucceedWhenCalledWithMultipleSources() public void StartSessionShouldFailIfProxyCreatorIsNull() { var testSessionCriteria = CreateTestSession(_fakeTestSources, _fakeRunSettings); - var proxyManager = CreateProxy(testSessionCriteria, null); + var proxyManager = CreateProxy(testSessionCriteria, null!); Assert.IsFalse(proxyManager.StartSession(_mockEventsHandler.Object, _mockRequestData.Object)); _mockEventsHandler.Verify(eh => eh.HandleStartTestSessionComplete(