Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove missed #nullable disable on projects already handled #3741

Merged
merged 3 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions playground/MSTest1/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

using Microsoft.VisualStudio.TestTools.UnitTesting;

#nullable disable

namespace MSTest1;

[TestClass]
Expand Down
8 changes: 3 additions & 5 deletions playground/TestPlatform.Playground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -205,10 +203,10 @@ public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessSta
throw new NotImplementedException();
}

private static string WriteTests(IEnumerable<TestResult> testResults)
private static string WriteTests(IEnumerable<TestResult>? testResults)
=> WriteTests(testResults?.Select(t => t.TestCase));

private static string WriteTests(IEnumerable<TestCase> testCases)
private static string WriteTests(IEnumerable<TestCase>? testCases)
=> testCases?.Any() == true
? "\t" + string.Join("\n\t", testCases.Select(r => r.DisplayName))
: "\t<empty>";
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 1 addition & 3 deletions scripts/build/ExternalAssemblyVersions.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// 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"
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private IDictionary<string, string> TestSessionEnvironmentVariables
/// <summary>
/// Initializes a new instance of the <see cref="ProxyTestSessionManager"/> class.
/// </summary>
///
///
/// <param name="criteria">The test session criteria.</param>
/// <param name="maxTesthostCount">The testhost count.</param>
/// <param name="proxyCreator">The proxy creator.</param>
Expand Down Expand Up @@ -226,10 +226,10 @@ public virtual bool StopSession(IRequestData requestData)
/// <summary>
/// Dequeues a proxy to be used either by discovery or execution.
/// </summary>
///
///
/// <param name="source">The source to be associated to this proxy.</param>
/// <param name="runSettings">The run settings.</param>
///
///
/// <returns>The dequeued proxy.</returns>
public virtual ProxyOperationManager DequeueProxy(string source, string runSettings)
{
Expand Down Expand Up @@ -272,9 +272,9 @@ public virtual ProxyOperationManager DequeueProxy(string source, string runSetti
/// <summary>
/// Enqueues a proxy back once discovery or executions is done with it.
/// </summary>
///
///
/// <param name="proxyId">The id of the proxy to be re-enqueued.</param>
///
///
/// <returns>True if the operation succeeded, false otherwise.</returns>
public virtual bool EnqueueProxy(int proxyId)
{
Expand Down Expand Up @@ -430,7 +430,7 @@ internal class ProxyOperationManagerContainer
/// <summary>
/// Initializes a new instance of the <see cref="ProxyOperationManagerContainer"/> class.
/// </summary>
///
///
/// <param name="proxy">The proxy.</param>
/// <param name="available">A flag indicating if the proxy is available to do work.</param>
public ProxyOperationManagerContainer(ProxyOperationManager proxy, bool available)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

using System;

#nullable disable

namespace Microsoft.VisualStudio.TestPlatform;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/vstest.console/Internal/Interfaces/IConsoleHelper.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@

using Moq;

#nullable disable

namespace TestPlatform.CrossPlatEngine.UnitTests.Client;

[TestClass]
public class InProcessProxyDiscoveryManagerTests
{
private Mock<ITestHostManagerFactory> _mockTestHostManagerFactory;
private readonly Mock<ITestHostManagerFactory> _mockTestHostManagerFactory;
private InProcessProxyDiscoveryManager _inProcessProxyDiscoveryManager;
private Mock<IDiscoveryManager> _mockDiscoveryManager;
private Mock<ITestRuntimeProvider> _mockTestHostManager;
private readonly Mock<IDiscoveryManager> _mockDiscoveryManager;
private readonly Mock<ITestRuntimeProvider> _mockTestHostManager;

public InProcessProxyDiscoveryManagerTests()
{
Expand All @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@

using Moq;

#nullable disable

namespace TestPlatform.CrossPlatEngine.UnitTests.Client;

[TestClass]
public class InProcessProxyExecutionManagerTests
{
private Mock<ITestHostManagerFactory> _mockTestHostManagerFactory;
private readonly Mock<ITestHostManagerFactory> _mockTestHostManagerFactory;
private InProcessProxyExecutionManager _inProcessProxyExecutionManager;
private Mock<IExecutionManager> _mockExecutionManager;
private Mock<ITestRuntimeProvider> _mockTestHostManager;
private readonly Mock<IExecutionManager> _mockExecutionManager;
private readonly Mock<ITestRuntimeProvider> _mockTestHostManager;

public InProcessProxyExecutionManagerTests()
{
Expand All @@ -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()
{
Expand Down Expand Up @@ -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<TestExecutionContext>(), 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]
Expand All @@ -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<TestExecutionContext>(), 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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ICommunicationEndPoint> _mockCommunicationEndpoint;
private ITestRequestSender _testRequestSender;
readonly ProtocolConfig _protocolConfig = new() { Version = 2 };
private readonly ProtocolConfig _protocolConfig = new() { Version = 2 };
private readonly Mock<IRequestData> _mockRequestData;
private readonly Mock<IFileHelper> _mockFileHelper;
private readonly DiscoveryDataAggregator _discoveryDataAggregator;

protected readonly Mock<ITestRuntimeProvider> _mockTestHostManager;

private Mock<ICommunicationEndPoint>? _mockCommunicationEndpoint;
private ITestRequestSender? _testRequestSender;

protected Mock<IDataSerializer> _mockDataSerializer;
protected Mock<ICommunicationChannel> _mockChannel;
private readonly Mock<IFileHelper> _mockFileHelper;
private readonly DiscoveryDataAggregator _discoveryDataAggregator;

public ProxyBaseManagerTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ITestRequestSender> _mockRequestSender;

private readonly Mock<TestRunCriteria> _mockTestRunCriteria;

private readonly Mock<IRequestData> _mockRequestData;

private readonly Mock<IMetricsCollection> _mockMetricsCollection;

private readonly Mock<IFileHelper> _mockFileHelper;

private ProxyExecutionManager _testExecutionManager;
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -277,7 +271,7 @@ public void StartTestRunShouldInitializeExtensionsIfTestHostIsNotShared()
public void StartTestRunShouldInitializeExtensionsWithExistingExtensionsOnly()
{
TestPluginCache.Instance = null;
TestPluginCache.Instance.UpdateExtensions(new List<string> { "abc.TestAdapter.dll", "def.TestAdapter.dll", "xyz.TestAdapter.dll" }, false);
TestPluginCache.Instance!.UpdateExtensions(new List<string> { "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);
Expand Down Expand Up @@ -436,7 +430,7 @@ public void StartTestRunForAnExceptionDuringLaunchOfTestShouldHandleLogMessageWi
[TestMethod]
public void StartTestRunShouldInitiateTestRunForSourcesThroughTheServer()
{
TestRunCriteriaWithSources testRunCriteriaPassed = null;
TestRunCriteriaWithSources? testRunCriteriaPassed = null;
_mockFileHelper.Setup(fh => fh.Exists(It.IsAny<string>())).Returns(true);
_mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny<int>(), It.IsAny<CancellationToken>())).Returns(true);
_mockRequestSender.Setup(s => s.StartTestRun(It.IsAny<TestRunCriteriaWithSources>(), _testExecutionManager))
Expand All @@ -456,7 +450,7 @@ public void StartTestRunShouldInitiateTestRunForSourcesThroughTheServer()
[TestMethod]
public void StartTestRunShouldInitiateTestRunForTestsThroughTheServer()
{
TestRunCriteriaWithTests testRunCriteriaPassed = null;
TestRunCriteriaWithTests? testRunCriteriaPassed = null;
_mockFileHelper.Setup(fh => fh.Exists(It.IsAny<string>())).Returns(true);
_mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny<int>(), It.IsAny<CancellationToken>())).Returns(true);
_mockRequestSender.Setup(s => s.StartTestRun(It.IsAny<TestRunCriteriaWithTests>(), _testExecutionManager))
Expand Down Expand Up @@ -801,7 +795,7 @@ private void SignalEvent(ManualResetEvent manualResetEvent)
private void InvokeAndVerifyStartTestRun(bool skipDefaultAdapters)
{
TestPluginCache.Instance = null;
TestPluginCache.Instance.DefaultExtensionPaths = new List<string> { "default1.dll", "default2.dll" };
TestPluginCache.Instance!.DefaultExtensionPaths = new List<string> { "default1.dll", "default2.dll" };
TestPluginCache.Instance.UpdateExtensions(new List<string> { "filterTestAdapter.dll" }, false);
TestPluginCache.Instance.UpdateExtensions(new List<string> { "unfilter.dll" }, true);

Expand All @@ -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<ICommunicationEndPoint>();
// this.mockDataSerializer = new Mock<IDataSerializer>();
// 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<TPayload>(string messageType, string returnMessageType, TPayload returnPayload)
//{
// this.mockChannel.Setup(mc => mc.Send(It.Is<string>(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<string>(s => s.Equals(messageType)), It.IsAny<object>())).Returns(messageType);
// this.mockDataSerializer.Setup(ds => ds.SerializePayload(It.Is<string>(s => s.Equals(messageType)), It.IsAny<object>(), It.IsAny<int>())).Returns(messageType);
// this.mockDataSerializer.Setup(ds => ds.DeserializeMessage(It.Is<string>(s => s.Equals(messageType)))).Returns(new Message { MessageType = returnMessageType });
// this.mockDataSerializer.Setup(ds => ds.DeserializePayload<TPayload>(It.Is<Message>(m => m.MessageType.Equals(messageType)))).Returns(returnPayload);
//}
}
Loading