From 9567e6cf4093dd5182af81773d6419d65a4a7ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Thu, 23 Jun 2022 12:01:07 +0200 Subject: [PATCH] Enable nullable on missed files (#3801) --- .../Execution/TestRunRequest.cs | 14 +- .../TestPlatform.cs | 14 +- .../Client/InProcessProxyexecutionManager.cs | 2 +- .../Parallel/ParallelProxyExecutionManager.cs | 5 +- .../Client/ProxyOperationManager.cs | 2 +- .../Client/TestRunCriteriaExtensions.cs | 2 + .../TestEngine.cs | 8 +- .../Utility/Converter.cs | 1 + .../AttachmentSet.cs | 6 +- .../Interfaces/ITestRunConfiguration.cs | 2 +- .../Client/TestRunCriteria.cs | 124 ++++++++++-------- .../InProcDataCollector/TestCaseEndArgs.cs | 2 - .../InProcDataCollector/TestSessionEndArgs.cs | 2 - .../BaseTransferInformation.cs | 10 +- .../TestPlatformHelpers/TestRequestManager.cs | 3 +- .../DotnetArchitectureSwitchTests.Windows.cs | 2 - .../TestPlatformTests.cs | 12 +- .../InProcessProxyexecutionManagerTests.cs | 22 ++-- .../ParallelProxyExecutionManagerTests.cs | 6 +- .../Client/ProxyExecutionManagerTests.cs | 12 +- .../Client/TestRunCriteriaTests.cs | 2 +- .../TestRequestManagerTests.cs | 22 ++-- 22 files changed, 149 insertions(+), 126 deletions(-) diff --git a/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs b/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs index 76ceae3dca..002654eb28 100644 --- a/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs +++ b/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs @@ -425,14 +425,11 @@ public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, Test } finally { - if (isCanceled) - { - State = TestRunState.Canceled; - } - else - { - State = isAborted ? TestRunState.Aborted : TestRunState.Completed; - } + State = isCanceled + ? TestRunState.Canceled + : isAborted + ? TestRunState.Aborted + : TestRunState.Completed; // Notify the waiting handle that run is complete _runCompletionEvent.Set(); @@ -655,6 +652,7 @@ public int LaunchProcessWithDebuggerAttached(TestProcessStartInfo testProcessSta { int processId = -1; + TPDebug.Assert(TestRunCriteria.TestHostLauncher is not null, "TestRunCriteria.TestHostLauncher is null"); // Only launch while the test run is in progress and the launcher is a debug one if (State == TestRunState.InProgress && TestRunCriteria.TestHostLauncher.IsDebug) { diff --git a/src/Microsoft.TestPlatform.Client/TestPlatform.cs b/src/Microsoft.TestPlatform.Client/TestPlatform.cs index 05bfe258d2..bc53ffb859 100644 --- a/src/Microsoft.TestPlatform.Client/TestPlatform.cs +++ b/src/Microsoft.TestPlatform.Client/TestPlatform.cs @@ -386,9 +386,15 @@ private static IEnumerable ExpandAdaptersWithDefaultStrategy(string path TestPlatformConstants.RunTimeEndsWithPattern); } - private static IEnumerable GetSources(TestRunCriteria testRunCriteria) => - testRunCriteria.HasSpecificTests + private static IEnumerable GetSources(TestRunCriteria testRunCriteria) + { + if (testRunCriteria.HasSpecificTests) + { // If the test execution is with a test filter, filter sources too. - ? testRunCriteria.Tests.Select(tc => tc.Source).Distinct() - : testRunCriteria.Sources; + return testRunCriteria.Tests.Select(tc => tc.Source).Distinct(); + } + + TPDebug.Assert(testRunCriteria.Sources is not null, "testRunCriteria.Sources is null"); + return testRunCriteria.Sources; + } } diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs index cb593fc15f..de7e5d2a41 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/InProcessProxyexecutionManager.cs @@ -59,7 +59,7 @@ public int StartTestRun(TestRunCriteria testRunCriteria, IInternalTestRunEventsH var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(testRunCriteria.TestRunSettings); var testPackages = new List(testRunCriteria.HasSpecificSources ? testRunCriteria.Sources : // If the test execution is with a test filter, group them by sources - testRunCriteria.Tests.GroupBy(tc => tc.Source).Select(g => g.Key)); + testRunCriteria.Tests!.GroupBy(tc => tc.Source).Select(g => g.Key)); // This code should be in sync with ProxyExecutionManager.StartTestRun executionContext var executionContext = new TestExecutionContext( diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs index 895806f460..f0fc0969b8 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs @@ -103,6 +103,7 @@ public int StartTestRun(TestRunCriteria testRunCriteria, IInternalTestRunEventsH _runCompletedClients = 0; // One data aggregator per parallel run + TPDebug.Assert(testRunCriteria.TestRunSettings is not null, "testRunCriteria.TestRunSettings is null"); _currentRunDataAggregator = new ParallelRunDataAggregator(testRunCriteria.TestRunSettings); if (nonRunnableWorkloads.Count > 0) { @@ -267,9 +268,9 @@ private List> SplitToWorkloads(TestRun } else { - var sources = testRunCriteria.Sources; + TPDebug.Assert(testRunCriteria.Sources is not null, "testRunCriteria.Sources is null"); // Each source is grouped with its respective provider. - var providerGroups = sources + var providerGroups = testRunCriteria.Sources .Select(source => new ProviderSpecificWorkload(source, sourceToTestHostProviderMap[source])) .GroupBy(psw => psw.Provider); diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs index dc56206cd8..97e9820f6c 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyOperationManager.cs @@ -382,7 +382,7 @@ public virtual TestProcessStartInfo UpdateTestProcessStartInfo(TestProcessStartI /// Run settings string. /// /// The run settings after removing non-required nodes. - public string? RemoveNodesFromRunsettingsIfRequired(string runsettingsXml, Action logMessage) + public string? RemoveNodesFromRunsettingsIfRequired(string? runsettingsXml, Action logMessage) { var updatedRunSettingsXml = runsettingsXml; if (!_makeRunsettingsCompatibleSet) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestRunCriteriaExtensions.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestRunCriteriaExtensions.cs index 301bc1cd25..66d2835b5b 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestRunCriteriaExtensions.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/TestRunCriteriaExtensions.cs @@ -16,6 +16,7 @@ internal static class TestRunCriteriaExtensions { public static TestRunCriteriaWithSources CreateTestRunCriteriaForSources(this TestRunCriteria testRunCriteria, ITestRuntimeProvider? testRuntimeProvider, string? runSettings, TestExecutionContext executionContext, IEnumerable? inputPackages) { + TPDebug.Assert(testRunCriteria.AdapterSourceMap is not null, "testRunCriteria.AdapterSourceMap is null"); if (TryCheckTestSourceDifferFromPackage(testRuntimeProvider, inputPackages, out IEnumerable? actualTestSources)) { UpdateTestSources(actualTestSources, testRunCriteria.AdapterSourceMap); @@ -31,6 +32,7 @@ public static TestRunCriteriaWithSources CreateTestRunCriteriaForSources(this Te public static TestRunCriteriaWithTests CreateTestRunCriteriaForTests(this TestRunCriteria testRunCriteria, ITestRuntimeProvider? testRuntimeProvider, string? runSettings, TestExecutionContext executionContext, IEnumerable? inputPackages) { + TPDebug.Assert(testRunCriteria.Tests is not null, "testRunCriteria.Tests is null"); if (TryCheckTestSourceDifferFromPackage(testRuntimeProvider, inputPackages, out IEnumerable? actualTestSources)) { // In UWP scenario TestCase object contains the package as source, which is not actual test source for adapters, diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs index d65de6638d..9712415193 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/TestEngine.cs @@ -192,6 +192,8 @@ public IProxyExecutionManager GetExecutionManager( IDictionary sourceToSourceDetailMap, IWarningLogger warningLogger) { + TPDebug.Assert(testRunCriteria.TestRunSettings is not null, "testRunCriteria.TestRunSettings is null"); + // We use mulitple "different" runsettings here. We have runsettings that come with the testRunCriteria, // and we use that to figure out the common stuff before we try to setup the run. Later we patch the settings // from the additional details that were passed. Those should not affect the common properties that are used for setup. @@ -492,11 +494,11 @@ private static int GetDistinctNumberOfSources(TestRunCriteria testRunCriteria) { // No point in creating more processes if number of sources is less than what the user // configured for. - int numSources = testRunCriteria.HasSpecificTests + int numberOfSources = testRunCriteria.HasSpecificTests ? new HashSet( testRunCriteria.Tests.Select(testCase => testCase.Source)).Count : testRunCriteria.Sources.Count(); - return numSources; + return numberOfSources; } /// @@ -509,7 +511,7 @@ private static int GetDistinctNumberOfSources(TestRunCriteria testRunCriteria) /// The parallel level to use. private int VerifyParallelSettingAndCalculateParallelLevel( int sourceCount, - string runSettings) + string? runSettings) { // Default is 1. int parallelLevelToUse; diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs index 4b7698e473..be7574f9ef 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs @@ -471,6 +471,7 @@ private CollectorDataEntry ToCollectorEntry(AttachmentSet attachmentSet, Guid te // (Trx viewer automatically adds In\ to the collected file. string fileName = Path.Combine(Environment.MachineName, Path.GetFileName(targetFileName)); Uri sourceFileUri = new(fileName, UriKind.Relative); + TPDebug.Assert(uriDataAttachment.Description is not null, "uriDataAttachment.Description is null"); TrxObjectModel.UriDataAttachment dataAttachment = new(uriDataAttachment.Description, sourceFileUri, _trxFileHelper); uriDataAttachments.Add(dataAttachment); diff --git a/src/Microsoft.TestPlatform.ObjectModel/AttachmentSet.cs b/src/Microsoft.TestPlatform.ObjectModel/AttachmentSet.cs index c35942e94e..e4d777786e 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/AttachmentSet.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/AttachmentSet.cs @@ -57,7 +57,7 @@ public class UriDataAttachment /// Description of the attachment. /// [DataMember] - public string Description { get; } + public string? Description { get; } /// /// Uri of the attachment. @@ -65,7 +65,7 @@ public class UriDataAttachment [DataMember] public Uri Uri { get; } - public UriDataAttachment(Uri uri, string description) + public UriDataAttachment(Uri uri, string? description) { Uri = uri; Description = description; @@ -76,7 +76,7 @@ public override string ToString() return $"{nameof(Uri)}: {Uri.AbsoluteUri}, {nameof(Description)}: {Description}"; } - public static UriDataAttachment CreateFrom(string localFilePath, string description) + public static UriDataAttachment CreateFrom(string localFilePath, string? description) { var uri = new UriBuilder() { Scheme = "file", Host = "", Path = localFilePath }.Uri; return new UriDataAttachment(uri, description); diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunConfiguration.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunConfiguration.cs index c61cedea6f..3e9f82bbbb 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunConfiguration.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/ITestRunConfiguration.cs @@ -35,5 +35,5 @@ public interface ITestRunConfiguration /// /// The specific tests for this test run if any. /// - IEnumerable Tests { get; } + IEnumerable? Tests { get; } } diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunCriteria.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunCriteria.cs index 95bf1fbbb8..8d259a505c 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunCriteria.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/TestRunCriteria.cs @@ -3,15 +3,15 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Runtime.Serialization; using System.Text; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; /// @@ -19,8 +19,8 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; /// public class TestRunCriteria : BaseTestRunCriteria, ITestRunConfiguration { - private string _testCaseFilter; - private FilterOptions _filterOptions; + private string? _testCaseFilter; + private FilterOptions? _filterOptions; /// /// Initializes a new instance of the class. @@ -73,7 +73,7 @@ public TestRunCriteria( IEnumerable sources, long frequencyOfRunStatsChangeEvent, bool keepAlive, - string testSettings) + string? testSettings) : this( sources, frequencyOfRunStatsChangeEvent, @@ -100,7 +100,7 @@ public TestRunCriteria( IEnumerable sources, long frequencyOfRunStatsChangeEvent, bool keepAlive, - string testSettings, + string? testSettings, TimeSpan runStatsChangeEventTimeout) : this( sources, @@ -132,9 +132,9 @@ public TestRunCriteria( IEnumerable sources, long frequencyOfRunStatsChangeEvent, bool keepAlive, - string testSettings, + string? testSettings, TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher) + ITestHostLauncher? testHostLauncher) : this( sources, frequencyOfRunStatsChangeEvent, @@ -169,11 +169,11 @@ public TestRunCriteria( IEnumerable sources, long frequencyOfRunStatsChangeEvent, bool keepAlive, - string testSettings, + string? testSettings, TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher, - string testCaseFilter, - FilterOptions filterOptions) + ITestHostLauncher? testHostLauncher, + string? testCaseFilter, + FilterOptions? filterOptions) : this( sources, frequencyOfRunStatsChangeEvent, @@ -214,12 +214,12 @@ public TestRunCriteria( IEnumerable sources, long frequencyOfRunStatsChangeEvent, bool keepAlive, - string testSettings, + string? testSettings, TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher, - string testCaseFilter, - FilterOptions filterOptions, - TestSessionInfo testSessionInfo, + ITestHostLauncher? testHostLauncher, + string? testCaseFilter, + FilterOptions? filterOptions, + TestSessionInfo? testSessionInfo, bool debugEnabledForTestSession) : base( frequencyOfRunStatsChangeEvent, @@ -289,9 +289,9 @@ public TestRunCriteria( Dictionary> adapterSourceMap, long frequencyOfRunStatsChangeEvent, bool keepAlive, - string testSettings, + string? testSettings, TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher) + ITestHostLauncher? testHostLauncher) : base( frequencyOfRunStatsChangeEvent, keepAlive, @@ -431,7 +431,7 @@ public TestRunCriteria( bool keepAlive, string testSettings, TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher) + ITestHostLauncher? testHostLauncher) : this( tests, frequencyOfRunStatsChangeEvent, @@ -468,10 +468,10 @@ public TestRunCriteria( IEnumerable tests, long frequencyOfRunStatsChangeEvent, bool keepAlive, - string testSettings, + string? testSettings, TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher, - TestSessionInfo testSessionInfo, + ITestHostLauncher? testHostLauncher, + TestSessionInfo? testSessionInfo, bool debugEnabledForTestSession) : base( frequencyOfRunStatsChangeEvent, @@ -492,7 +492,7 @@ public TestRunCriteria( /// Gets the test containers (e.g. DLL/EXE/artifacts to scan). /// [IgnoreDataMember] - public IEnumerable Sources + public IEnumerable? Sources { get { @@ -510,21 +510,21 @@ public IEnumerable Sources /// /// [DataMember] - public Dictionary> AdapterSourceMap { get; private set; } + public Dictionary>? AdapterSourceMap { get; private set; } /// /// Gets the tests that need to executed in this test run. /// This will be null if test run is created with specific test containers. /// [DataMember] - public IEnumerable Tests { get; private set; } + public IEnumerable? Tests { get; private set; } /// /// Gets or sets the criteria for filtering test cases. /// /// This is only for with sources. [DataMember] - public string TestCaseFilter + public string? TestCaseFilter { get => _testCaseFilter; @@ -544,7 +544,7 @@ private set /// /// This is only applicable when TestCaseFilter is present. [DataMember] - public FilterOptions FilterOptions + public FilterOptions? FilterOptions { get => _filterOptions; @@ -562,7 +562,7 @@ private set /// /// Gets or sets the test session info object. /// - public TestSessionInfo TestSessionInfo { get; set; } + public TestSessionInfo? TestSessionInfo { get; set; } /// /// Gets or sets a flag indicating if debugging should be enabled when we have test session @@ -573,18 +573,40 @@ private set /// /// Gets a value indicating whether run criteria is based on specific tests. /// + [MemberNotNullWhen(true, nameof(Tests))] + [MemberNotNullWhen(false, nameof(Sources))] public bool HasSpecificTests { - get { return Tests != null; } + get + { + if (Tests != null) + { + return true; + } + + TPDebug.Assert(Sources is not null, "Sources is null and Tests is null"); + return false; + } } /// /// Gets a value indicating whether run criteria is based on specific sources. /// [DataMember] + [MemberNotNullWhen(true, nameof(Sources))] + [MemberNotNullWhen(false, nameof(Tests))] public bool HasSpecificSources { - get { return Sources != null; } + get + { + if (Sources != null) + { + return true; + } + + TPDebug.Assert(Tests is not null, "Tests is null and Sources is null"); + return false; + } } /// @@ -605,15 +627,14 @@ public override string ToString() return sb.ToString(); } - protected bool Equals(TestRunCriteria other) - { - return base.Equals(other) - && string.Equals(TestCaseFilter, other.TestCaseFilter) - && Equals(FilterOptions, other.FilterOptions); - } + protected bool Equals(TestRunCriteria? other) + => other is not null + && base.Equals(other) + && string.Equals(TestCaseFilter, other.TestCaseFilter) + && Equals(FilterOptions, other.FilterOptions); /// - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is null) { @@ -703,7 +724,7 @@ public BaseTestRunCriteria(long frequencyOfRunStatsChangeEvent, bool keepAlive) public BaseTestRunCriteria( long frequencyOfRunStatsChangeEvent, bool keepAlive, - string testSettings) + string? testSettings) : this( frequencyOfRunStatsChangeEvent, keepAlive, @@ -729,7 +750,7 @@ public BaseTestRunCriteria( public BaseTestRunCriteria( long frequencyOfRunStatsChangeEvent, bool keepAlive, - string testSettings, + string? testSettings, TimeSpan runStatsChangeEventTimeout) : this( frequencyOfRunStatsChangeEvent, @@ -758,9 +779,9 @@ public BaseTestRunCriteria( public BaseTestRunCriteria( long frequencyOfRunStatsChangeEvent, bool keepAlive, - string testSettings, + string? testSettings, TimeSpan runStatsChangeEventTimeout, - ITestHostLauncher testHostLauncher) + ITestHostLauncher? testHostLauncher) { if (frequencyOfRunStatsChangeEvent <= 0) { @@ -794,13 +815,13 @@ public BaseTestRunCriteria( /// Gets the settings used for this run. /// [DataMember] - public string TestRunSettings { get; private set; } + public string? TestRunSettings { get; private set; } /// /// Gets the custom launcher for test executor. /// [DataMember] - public ITestHostLauncher TestHostLauncher { get; private set; } + public ITestHostLauncher? TestHostLauncher { get; private set; } /// /// Gets the frequency of run stats test event. @@ -821,16 +842,15 @@ public BaseTestRunCriteria( [DataMember] public TimeSpan RunStatsChangeEventTimeout { get; private set; } - protected bool Equals(BaseTestRunCriteria other) - { - return KeepAlive == other.KeepAlive - && string.Equals(TestRunSettings, other.TestRunSettings) - && FrequencyOfRunStatsChangeEvent == other.FrequencyOfRunStatsChangeEvent - && RunStatsChangeEventTimeout.Equals(other.RunStatsChangeEventTimeout); - } + protected bool Equals(BaseTestRunCriteria? other) + => other is not null + && KeepAlive == other.KeepAlive + && string.Equals(TestRunSettings, other.TestRunSettings) + && FrequencyOfRunStatsChangeEvent == other.FrequencyOfRunStatsChangeEvent + && RunStatsChangeEventTimeout.Equals(other.RunStatsChangeEventTimeout); /// - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is null) { diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs index 170d876377..98d43adbeb 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestCaseEndArgs.cs @@ -3,8 +3,6 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; /// diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionEndArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionEndArgs.cs index 07b36db57e..8cc7a62b8b 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionEndArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/InProcDataCollector/TestSessionEndArgs.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.ObjectModel.DataCollector.InProcDataCollector; /// diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/BaseTransferInformation.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/BaseTransferInformation.cs index a4703adbb0..e3a43d8ef2 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/BaseTransferInformation.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/TransferInformation/BaseTransferInformation.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.ObjectModel.DataCollection; /// @@ -10,7 +8,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; /// public abstract class BasicTransferInformation { - private string _description; + private string? _description; /// /// Initializes a new instance of the class. @@ -40,7 +38,7 @@ protected BasicTransferInformation(DataCollectionContext context) /// /// Gets or sets a short description of the data being sent. /// - public string Description + public string? Description { get => _description; @@ -52,14 +50,14 @@ public string Description /// /// Gets or sets the token which will be included with the callback to identify this file transfer. /// - public object UserToken { get; set; } + public object? UserToken { get; set; } /// /// Gets or sets the ID of the request that this file should be associated with. This is used /// for sending transient data which will be associated only with this /// data request and not the session or test cases that are currently running. /// - public RequestId RequestId { get; set; } + public RequestId? RequestId { get; set; } /// /// Gets a value indicating whether cleanup should be performed after transferring the resource. This diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 6c2728f719..e62d4f2681 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -351,6 +351,7 @@ public void RunTests( // // OR we already did discovery and have a list of TestCases that have concrete test method information // and so we only pass those. TestCase also has the test container path (usually a DLL). + TPDebug.Assert(testRunRequestPayload.Sources != null || testRunRequestPayload.TestCases != null, "testRunRequestPayload.Sources or testRunRequestPayload.TestCases is null"); TestRunCriteria runCriteria = testRunRequestPayload.Sources != null && testRunRequestPayload.Sources.Any() ? new TestRunCriteria( testRunRequestPayload.Sources, @@ -365,7 +366,7 @@ public void RunTests( debugEnabledForTestSession: testRunRequestPayload.TestSessionInfo != null && testRunRequestPayload.DebuggingEnabled) : new TestRunCriteria( - testRunRequestPayload.TestCases, + testRunRequestPayload.TestCases!, batchSize, testRunRequestPayload.KeepAlive, runsettings, diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs index 5151f2ef0c..f07623f621 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/DotnetArchitectureSwitchTests.Windows.cs @@ -50,8 +50,6 @@ public void Use_EnvironmentVariables(string architectureFrom, string architectur using Microsoft.VisualStudio.TestTools.UnitTesting; using System; -#nullable disable - namespace cfebbc5339cf4c22854e79824e938c74; [TestClass] diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs index 1fb1b429ab..7d30077e40 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs @@ -149,8 +149,8 @@ public void CreateTestRunRequestShouldUpdateLoggerExtensionWhenDesingModeIsFalse var temp = Path.GetTempPath(); var testRunCriteria = new TestRunCriteria(new List { $@"{temp}foo.dll" }, 10, false, settingsXml, TimeSpan.Zero); - _hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) - .Returns(testRunCriteria.Sources); + _hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources!)) + .Returns(testRunCriteria.Sources!); _testEngine.Setup(te => te.GetExecutionManager(_mockRequestData.Object, It.IsAny(), It.IsAny>(), It.IsAny())).Returns(_executionManager.Object); _testEngine.Setup(te => te.GetExtensionManager()).Returns(_extensionManager.Object); @@ -233,8 +233,8 @@ public void CreateTestRunRequestShouldInitializeManagersAndCreateTestRunRequestW var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); var testRunCriteria = new TestRunCriteria(new List { "foo" }, 10); - _hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) - .Returns(testRunCriteria.Sources); + _hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources!)) + .Returns(testRunCriteria.Sources!); var testRunRequest = tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, new TestPlatformOptions(), It.IsAny>(), It.IsAny()); @@ -608,8 +608,8 @@ private void InvokeCreateTestRunRequest(TestPlatformOptions? options = null) var tp = new TestableTestPlatform(_testEngine.Object, _hostManager.Object); var testRunCriteria = new TestRunCriteria(new List { "foo" }, 10); - _hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)) - .Returns(testRunCriteria.Sources); + _hostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources!)) + .Returns(testRunCriteria.Sources!); tp.CreateTestRunRequest(_mockRequestData.Object, testRunCriteria, options, new Dictionary(), new Mock().Object); } diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs index ba0151d135..c5462caf0a 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/InProcessProxyexecutionManagerTests.cs @@ -67,7 +67,7 @@ public void StartTestRunShouldCallExecutionManagerStartTestRunWithAdapterSourceM var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); var manualResetEvent = new ManualResetEvent(true); - _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.AdapterSourceMap, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null!)).Callback( + _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.AdapterSourceMap!, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null!)).Callback( () => manualResetEvent.Set()); _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null!); @@ -80,11 +80,11 @@ public void StartTestRunShouldAllowRuntimeProviderToUpdateAdapterSource() { var testRunCriteria = new TestRunCriteria(new List { "source.dll" }, 10); - _mockTestHostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources)).Returns(testRunCriteria.Sources); + _mockTestHostManager.Setup(hm => hm.GetTestSources(testRunCriteria.Sources!)).Returns(testRunCriteria.Sources!); _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null!); - _mockTestHostManager.Verify(hm => hm.GetTestSources(testRunCriteria.Sources), Times.Once); + _mockTestHostManager.Verify(hm => hm.GetTestSources(testRunCriteria.Sources!), Times.Once); } [TestMethod] @@ -95,7 +95,7 @@ public void StartTestRunShouldCallExecutionManagerStartTestRunWithTestCase() frequencyOfRunStatsChangeEvent: 10); var manualResetEvent = new ManualResetEvent(true); - _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null!)).Callback( + _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests!, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null!)).Callback( () => manualResetEvent.Set()); _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null!); @@ -116,7 +116,7 @@ public void StartTestRunShouldUpdateTestCaseSourceIfTestCaseSourceDiffersFromTes _mockTestHostManager.Setup(hm => hm.GetTestSources(inputSource)).Returns(actualSources); - _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests, inputSource.FirstOrDefault(), testRunCriteria.TestRunSettings, It.IsAny(), null, null!)) + _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests!, inputSource.FirstOrDefault(), testRunCriteria.TestRunSettings, It.IsAny(), null, null!)) .Callback(() => manualResetEvent.Set()); _inProcessProxyExecutionManager = new InProcessProxyExecutionManager(_mockTestHostManager.Object, _mockTestHostManagerFactory.Object); @@ -124,9 +124,9 @@ public void StartTestRunShouldUpdateTestCaseSourceIfTestCaseSourceDiffersFromTes _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null!); 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!)); + _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] @@ -140,15 +140,15 @@ public void StartTestRunShouldNotUpdateTestCaseSourceIfTestCaseSourceDiffersFrom _mockTestHostManager.Setup(hm => hm.GetTestSources(actualSources)).Returns(actualSources); - _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null!)) + _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.Tests!, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null!)) .Callback(() => manualResetEvent.Set()); _inProcessProxyExecutionManager.StartTestRun(testRunCriteria, null!); Assert.IsTrue(manualResetEvent.WaitOne(5000), "IExecutionManager.StartTestRun should get called"); - _mockExecutionManager.Verify(o => o.StartTestRun(testRunCriteria.Tests, null, testRunCriteria.TestRunSettings, It.IsAny(), null, null!)); + _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] @@ -158,7 +158,7 @@ public void StartTestRunShouldCatchExceptionAndCallHandleRunComplete() var mockTestRunEventsHandler = new Mock(); var manualResetEvent = new ManualResetEvent(true); - _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.AdapterSourceMap, null, testRunCriteria.TestRunSettings, It.IsAny(), null, mockTestRunEventsHandler.Object)).Callback( + _mockExecutionManager.Setup(o => o.StartTestRun(testRunCriteria.AdapterSourceMap!, null, testRunCriteria.TestRunSettings, It.IsAny(), null, mockTestRunEventsHandler.Object)).Callback( () => throw new Exception()); mockTestRunEventsHandler.Setup(o => o.HandleTestRunComplete(It.IsAny(), null, null, null)).Callback( diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyExecutionManagerTests.cs index 39e8a6a119..e20b0434dd 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/Parallel/ParallelProxyExecutionManagerTests.cs @@ -348,7 +348,7 @@ public void StartTestRunShouldAggregateRunData() { lock (syncObject) { - _processedSources.AddRange(criteria.Sources); + _processedSources.AddRange(criteria.Sources!); } Task.Delay(100).Wait(); @@ -526,7 +526,7 @@ private void SetupMockManagersForTestCase(List processedTestCases, Tes { lock (syncObject) { - processedTestCases.AddRange(criteria.Tests); + processedTestCases.AddRange(criteria.Tests!); } Task.Delay(100).Wait(); @@ -561,7 +561,7 @@ private void SetupMockManagers(List processedSources, bool isCanceled = { lock (syncObject) { - processedSources.AddRange(criteria.Sources); + processedSources.AddRange(criteria.Sources!); } Task.Delay(100).Wait(); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs index 910d1b9bd1..27f56d9d5f 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/Client/ProxyExecutionManagerTests.cs @@ -76,14 +76,14 @@ public void StartTestRunShouldAllowRuntimeProviderToUpdateAdapterSource() // Make sure TestPlugincache is refreshed. TestPluginCache.Instance = null; - _mockTestHostManager.Setup(hm => hm.GetTestSources(_mockTestRunCriteria.Object.Sources)).Returns(_mockTestRunCriteria.Object.Sources); + _mockTestHostManager.Setup(hm => hm.GetTestSources(_mockTestRunCriteria.Object.Sources!)).Returns(_mockTestRunCriteria.Object.Sources!); _mockRequestSender.Setup(s => s.WaitForRequestHandlerConnection(It.IsAny(), It.IsAny())).Returns(true); Mock mockTestRunEventsHandler = new(); _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, mockTestRunEventsHandler.Object); - _mockTestHostManager.Verify(hm => hm.GetTestSources(_mockTestRunCriteria.Object.Sources), Times.Once); + _mockTestHostManager.Verify(hm => hm.GetTestSources(_mockTestRunCriteria.Object.Sources!), Times.Once); } [TestMethod] @@ -105,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] @@ -127,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] @@ -440,7 +440,7 @@ public void StartTestRunShouldInitiateTestRunForSourcesThroughTheServer() _testExecutionManager.StartTestRun(_mockTestRunCriteria.Object, null!); Assert.IsNotNull(testRunCriteriaPassed); - CollectionAssert.AreEqual(_mockTestRunCriteria.Object.AdapterSourceMap.Keys, testRunCriteriaPassed.AdapterSourceMap.Keys); + CollectionAssert.AreEqual(_mockTestRunCriteria.Object.AdapterSourceMap!.Keys, testRunCriteriaPassed.AdapterSourceMap.Keys); CollectionAssert.AreEqual(_mockTestRunCriteria.Object.AdapterSourceMap.Values, testRunCriteriaPassed.AdapterSourceMap.Values); Assert.AreEqual(_mockTestRunCriteria.Object.FrequencyOfRunStatsChangeEvent, testRunCriteriaPassed.TestExecutionContext!.FrequencyOfRunStatsChangeEvent); Assert.AreEqual(_mockTestRunCriteria.Object.RunStatsChangeEventTimeout, testRunCriteriaPassed.TestExecutionContext.RunStatsChangeEventTimeout); @@ -463,7 +463,7 @@ public void StartTestRunShouldInitiateTestRunForTestsThroughTheServer() _testExecutionManager.StartTestRun(runCriteria.Object, null!); Assert.IsNotNull(testRunCriteriaPassed); - CollectionAssert.AreEqual(runCriteria.Object.Tests.ToList(), testRunCriteriaPassed.Tests.ToList()); + CollectionAssert.AreEqual(runCriteria.Object.Tests!.ToList(), testRunCriteriaPassed.Tests.ToList()); Assert.AreEqual( runCriteria.Object.FrequencyOfRunStatsChangeEvent, testRunCriteriaPassed.TestExecutionContext!.FrequencyOfRunStatsChangeEvent); diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/TestRunCriteriaTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/TestRunCriteriaTests.cs index 6d480646ce..7e3bfdeb30 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/TestRunCriteriaTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/Client/TestRunCriteriaTests.cs @@ -72,7 +72,7 @@ public void SourcesShouldEnumerateThroughAllSourcesInTheAdapterSourceMap() var expectedSourceSet = new List(sourceSet1); expectedSourceSet.AddRange(sourceSet2); - CollectionAssert.AreEqual(expectedSourceSet, testRunCriteria.Sources.ToList()); + CollectionAssert.AreEqual(expectedSourceSet, testRunCriteria.Sources!.ToList()); } [TestMethod] diff --git a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs index e6aae3a36f..0e7a6480e9 100644 --- a/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs +++ b/test/vstest.console.UnitTests/TestPlatformHelpers/TestRequestManagerTests.cs @@ -1156,9 +1156,9 @@ public void RunTestsWithSourcesShouldCallTestPlatformAndSucceed() Assert.AreEqual(testCaseFilterValue, observedCriteria!.TestCaseFilter, "TestCaseFilter must be set"); Assert.AreEqual(1, createRunRequestCalled, "CreateRunRequest must be invoked only once."); - Assert.AreEqual(2, observedCriteria.Sources.Count(), "All Sources must be used for discovery request"); - Assert.AreEqual("a", observedCriteria.Sources.First(), "First Source in list is incorrect"); - Assert.AreEqual("b", observedCriteria.Sources.ElementAt(1), "Second Source in list is incorrect"); + Assert.AreEqual(2, observedCriteria.Sources!.Count(), "All Sources must be used for discovery request"); + Assert.AreEqual("a", observedCriteria.Sources!.First(), "First Source in list is incorrect"); + Assert.AreEqual("b", observedCriteria.Sources!.ElementAt(1), "Second Source in list is incorrect"); // Check for the default value for the frequency Assert.AreEqual(10, observedCriteria.FrequencyOfRunStatsChangeEvent); @@ -1364,7 +1364,7 @@ public void RunTestsShouldUpdateDesignModeIfRunnerIsInDesignMode(bool designMode _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); var designmode = $"{designModeValue}"; - _mockTestPlatform.Verify(tp => tp.CreateTestRunRequest(It.IsAny(), It.Is(rc => rc.TestRunSettings.Contains(designmode)), It.IsAny(), It.IsAny>(), It.IsAny())); + _mockTestPlatform.Verify(tp => tp.CreateTestRunRequest(It.IsAny(), It.Is(rc => rc.TestRunSettings!.Contains(designmode)), It.IsAny(), It.IsAny>(), It.IsAny())); } [DataTestMethod] @@ -1411,7 +1411,7 @@ public void RunTestsShouldShouldUpdateFrameworkAndPlatformIfNotSpecifiedInDesign _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); _mockAssemblyMetadataProvider.Verify(a => a.GetFrameworkName(It.IsAny())); - Assert.IsTrue(actualTestRunCriteria!.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualTestRunCriteria!.TestRunSettings!.Contains(Constants.DotNetFramework46)); Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); } @@ -1450,7 +1450,7 @@ public void RunTestsShouldNotUpdateFrameworkAndPlatformIfSpecifiedInDesignMode() _mockAssemblyMetadataProvider.Verify(a => a.GetFrameworkName(It.IsAny()), Times.Once); // but don't update runsettings because we want to keep what user specified - Assert.IsTrue(actualTestRunCriteria!.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualTestRunCriteria!.TestRunSettings!.Contains(Constants.DotNetFramework46)); Assert.IsTrue(actualTestRunCriteria!.TestRunSettings.Contains(nameof(Architecture.ARM))); } @@ -1491,7 +1491,7 @@ public void RunTestsShouldNotUpdatePlatformIfSpecifiedInDesignMode(string target _mockAssemblyMetadataProvider.Verify(a => a.GetFrameworkName(It.IsAny()), Times.Once); // don't update it in runsettings to keep what user provided - Assert.IsTrue(actualTestRunCriteria!.TestRunSettings.Contains(targetPlatform)); + Assert.IsTrue(actualTestRunCriteria!.TestRunSettings!.Contains(targetPlatform)); } [TestMethod] @@ -1523,7 +1523,7 @@ public void RunTestsShouldUpdateFrameworkAndPlatformInCommandLineScenarios() _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); _mockAssemblyMetadataProvider.Verify(a => a.GetFrameworkName(It.IsAny())); - Assert.IsTrue(actualTestRunCriteria!.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualTestRunCriteria!.TestRunSettings!.Contains(Constants.DotNetFramework46)); Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); } @@ -1563,7 +1563,7 @@ public void RunTestsShouldNotpdateFrameworkAndPlatformInRunsettingsIfSpecifiedBy _mockAssemblyMetadataProvider.Verify(a => a.GetFrameworkName(It.IsAny()), Times.Once); // but don't update them in runsettings so we keep what user specified - Assert.IsFalse(actualTestRunCriteria!.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsFalse(actualTestRunCriteria!.TestRunSettings!.Contains(Constants.DotNetFramework46)); Assert.IsFalse(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); } @@ -1603,7 +1603,7 @@ public void RunTestsWithTestCasesShouldUpdateFrameworkAndPlatformIfNotSpecifiedI _mockAssemblyMetadataProvider.Verify(a => a.GetArchitecture(It.IsAny())); _mockAssemblyMetadataProvider.Verify(a => a.GetFrameworkName(It.IsAny())); - Assert.IsTrue(actualTestRunCriteria!.TestRunSettings.Contains(Constants.DotNetFramework46)); + Assert.IsTrue(actualTestRunCriteria!.TestRunSettings!.Contains(Constants.DotNetFramework46)); Assert.IsTrue(actualTestRunCriteria.TestRunSettings.Contains(nameof(Architecture.ARM))); CollectionAssert.AreEqual(actualSources, archSources); CollectionAssert.AreEqual(actualSources, fxSources); @@ -1847,7 +1847,7 @@ public void RunTestsShouldNotAddConsoleLoggerInRunSettingsInDesignMode() (IRequestData requestData, TestRunCriteria runCriteria, TestPlatformOptions options, Dictionary sourceToSourceDetailMap, IWarningLogger _) => actualTestRunCriteria = runCriteria).Returns(mockTestRunRequest.Object); _testRequestManager.RunTests(payload, new Mock().Object, new Mock().Object, _protocolConfig); - Assert.IsFalse(actualTestRunCriteria!.TestRunSettings.Contains("LoggerRunSettings")); + Assert.IsFalse(actualTestRunCriteria!.TestRunSettings!.Contains("LoggerRunSettings")); } [TestMethod]