diff --git a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/CollectorNameValueConfigurationManagerTests.cs b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/CollectorNameValueConfigurationManagerTests.cs
index 4dcd550c11..3c63ef3158 100644
--- a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/CollectorNameValueConfigurationManagerTests.cs
+++ b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/CollectorNameValueConfigurationManagerTests.cs
@@ -41,13 +41,13 @@ public void ConstructorShouldNotInitializeNameValuePairIfEmptyXmlElementIsPassed
}
var configManager = new CollectorNameValueConfigurationManager(xmlDocument.DocumentElement);
- Assert.AreEqual(0, configManager.NameValuePairs.Count);
+ Assert.IsEmpty(configManager.NameValuePairs);
}
[TestMethod]
public void ConstructorShouldNotInitializeNameValuePairNullIsPassed()
{
var configManager = new CollectorNameValueConfigurationManager(null);
- Assert.AreEqual(0, configManager.NameValuePairs.Count);
+ Assert.IsEmpty(configManager.NameValuePairs);
}
}
diff --git a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogContainerTests.cs b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogContainerTests.cs
index 72727cbb4a..0e77ce605a 100644
--- a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogContainerTests.cs
+++ b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogContainerTests.cs
@@ -60,7 +60,7 @@ public void OnEventLogEntryWrittenShouldAddLogs()
_eventLogContainer.OnEventLogEntryWritten(_eventLog, _entryWrittenEventArgs);
var newCount = _eventLogContainer.EventLogEntries.Count;
- Assert.IsTrue(newCount > 0);
+ Assert.IsGreaterThan(0, newCount);
}
[TestMethod]
diff --git a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs
index d977b765b1..fda7431395 100644
--- a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs
+++ b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogDataCollectorTests.cs
@@ -220,21 +220,21 @@ public void InitializeShouldSubscribeToDataCollectionEvents()
public void TestSessionStartEventShouldCreateEventLogContainer()
{
var eventLogDataCollector = new EventLogDataCollector();
- Assert.AreEqual(0, eventLogDataCollector.ContextMap.Count);
+ Assert.IsEmpty(eventLogDataCollector.ContextMap);
eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext);
_mockDataCollectionEvents.Raise(x => x.SessionStart += null, new SessionStartEventArgs());
- Assert.AreEqual(1, eventLogDataCollector.ContextMap.Count);
+ Assert.HasCount(1, eventLogDataCollector.ContextMap);
}
[TestMethod]
public void TestCaseStartEventShouldCreateEventLogContainer()
{
var eventLogDataCollector = new EventLogDataCollector();
- Assert.AreEqual(0, eventLogDataCollector.ContextMap.Count);
+ Assert.IsEmpty(eventLogDataCollector.ContextMap);
eventLogDataCollector.Initialize(null, _mockDataCollectionEvents.Object, _mockDataCollectionSink, _mockDataCollectionLogger.Object, _dataCollectionEnvironmentContext);
_mockDataCollectionEvents.Raise(x => x.TestCaseStart += null, new TestCaseStartEventArgs(new DataCollectionContext(new SessionId(Guid.NewGuid()), new TestExecId(Guid.NewGuid())), new TestCase()));
- Assert.AreEqual(1, eventLogDataCollector.ContextMap.Count);
+ Assert.HasCount(1, eventLogDataCollector.ContextMap);
}
[TestMethod]
diff --git a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogSessionContextTests.cs b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogSessionContextTests.cs
index cb5e7dd4dd..82d693be93 100644
--- a/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogSessionContextTests.cs
+++ b/test/DataCollectors/Microsoft.TestPlatform.Extensions.EventLogCollector.UnitTests/EventLogSessionContextTests.cs
@@ -29,7 +29,7 @@ public EventLogSessionContextTests()
public void CreateEventLogContainerStartIndexMapShouldCreateStartIndexMap()
{
_eventLogSessionContext = new EventLogSessionContext(_eventLogContainersMap);
- Assert.IsTrue(_eventLogSessionContext.EventLogContainerStartIndexMap["LogName"] == 2);
+ Assert.AreEqual(2, _eventLogSessionContext.EventLogContainerStartIndexMap["LogName"]);
}
[TestMethod]
@@ -37,7 +37,7 @@ public void CreateEventLogContainerEndIndexMapShouldCreateEndIndexMap()
{
_eventLogSessionContext = new EventLogSessionContext(_eventLogContainersMap);
_eventLogSessionContext.CreateEventLogContainerEndIndexMap();
- Assert.IsTrue(_eventLogSessionContext.EventLogContainerEndIndexMap["LogName"] == 1);
+ Assert.AreEqual(1, _eventLogSessionContext.EventLogContainerEndIndexMap["LogName"]);
}
[TestMethod]
@@ -47,8 +47,8 @@ public void CreateEventLogContainerShouldNotAddIndexEntriesIfEventLogContainerMa
_eventLogSessionContext.CreateEventLogContainerStartIndexMap();
_eventLogSessionContext.CreateEventLogContainerEndIndexMap();
- Assert.IsTrue(_eventLogSessionContext.EventLogContainerStartIndexMap.Count == 0);
- Assert.IsTrue(_eventLogSessionContext.EventLogContainerEndIndexMap.Count == 0);
+ Assert.IsEmpty(_eventLogSessionContext.EventLogContainerStartIndexMap);
+ Assert.IsEmpty(_eventLogSessionContext.EventLogContainerEndIndexMap);
}
[TestMethod]
@@ -62,8 +62,8 @@ public void CreateEventLogContainerShouldCreateNegativeEndIndexIfLogEntriesAreEm
_eventLogSessionContext.CreateEventLogContainerStartIndexMap();
_eventLogSessionContext.CreateEventLogContainerEndIndexMap();
- Assert.IsTrue(_eventLogSessionContext.EventLogContainerStartIndexMap["DummyEventLog"] == 0);
- Assert.IsTrue(_eventLogSessionContext.EventLogContainerEndIndexMap["DummyEventLog"] == -1);
+ Assert.AreEqual(0, _eventLogSessionContext.EventLogContainerStartIndexMap["DummyEventLog"]);
+ Assert.AreEqual(-1, _eventLogSessionContext.EventLogContainerEndIndexMap["DummyEventLog"]);
}
}
diff --git a/test/Directory.Build.props b/test/Directory.Build.props
index b93c6783d2..f98e859cc3 100644
--- a/test/Directory.Build.props
+++ b/test/Directory.Build.props
@@ -3,13 +3,18 @@
true
+
+ $(NoWarn);MSTEST0001
true
true
+ Recommended
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/BlameDataCollectorTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/BlameDataCollectorTests.cs
index e551f33c05..40c56b9dce 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/BlameDataCollectorTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/BlameDataCollectorTests.cs
@@ -98,7 +98,7 @@ public void BlameDataCollectorShouldNotOutputDumpFileWhenNoCrashOccurs(RunnerInf
InvokeVsTest(arguments, env);
- Assert.IsFalse(StdOut.Contains(".dmp"), "it should not collect a dump, because nothing crashed");
+ Assert.DoesNotContain(".dmp", StdOut, "it should not collect a dump, because nothing crashed");
}
[TestMethod]
@@ -122,7 +122,7 @@ public void BlameDataCollectorShouldOutputDumpFileWhenNoCrashOccursButCollectAlw
InvokeVsTest(arguments, env);
- StringAssert.Matches(StdOut, new Regex("\\.dmp"), "it should collect dump, even if nothing crashed");
+ Assert.MatchesRegex(new Regex("\\.dmp"), StdOut, "it should collect dump, even if nothing crashed");
}
[TestMethod]
@@ -260,7 +260,7 @@ public void BlameDataCollectorAeDebuggerShouldCollectDump(RunnerInfo runnerInfo)
out string standardTestOutput,
out string standardErrorTestOutput,
out int _);
- Assert.IsTrue(standardErrorTestOutput.Trim().Length == 0);
+ Assert.AreEqual(0, standardErrorTestOutput.Trim().Length);
// Run test under postmortem monitoring
var assemblyPaths = GetAssetFullPath("BlameUnitTestProject.dll");
@@ -274,12 +274,12 @@ public void BlameDataCollectorAeDebuggerShouldCollectDump(RunnerInfo runnerInfo)
out standardTestOutput,
out standardErrorTestOutput,
out int _);
- Assert.IsTrue(standardErrorTestOutput.Trim().Length == 0);
+ Assert.AreEqual(0, standardErrorTestOutput.Trim().Length);
// We cannot be precise here procdump is at machine level so we can have more than one dump and not only the one for our test
// We look for "at least" one dump file, is the best we can do without locking all tests.
- Assert.IsTrue(Directory.GetFiles(TempDirectory.Path, "*.dmp", SearchOption.AllDirectories)
- .Where(x => Path.GetFileNameWithoutExtension(x).StartsWith("testhost")).Count() > 0);
+ Assert.IsNotEmpty(Directory.GetFiles(TempDirectory.Path, "*.dmp", SearchOption.AllDirectories)
+ .Where(x => Path.GetFileNameWithoutExtension(x).StartsWith("testhost")));
}
private static bool IsAdministrator()
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/Build.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/Build.cs
index 6665e1cdbc..fcb06b3119 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/Build.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/Build.cs
@@ -7,7 +7,7 @@
namespace Microsoft.TestPlatform.Acceptance.IntegrationTests;
[TestClass]
-public class Build : IntegrationTestBase
+public static class Build
{
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext testContext)
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/CodeCoverageTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/CodeCoverageTests.cs
index 9bad647034..e996c95a06 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/CodeCoverageTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/CodeCoverageTests.cs
@@ -310,7 +310,7 @@ private static void AssertSkippedMethod(CoverageReport coverageReport)
Assert.IsNotNull(module);
var coverage = double.Parse(module.BlockCoverage, CultureInfo.InvariantCulture);
- Assert.IsTrue(coverage > ExpectedMinimalModuleCoverage);
+ Assert.IsGreaterThan(ExpectedMinimalModuleCoverage, coverage);
var testSignFunction = module.SkippedFunctions.FirstOrDefault(f => f.Name.Equals("TestSign()"));
Assert.IsNotNull(testSignFunction);
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectionTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectionTests.cs
index 2ff6512274..d355b8f63b 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectionTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectionTests.cs
@@ -140,7 +140,7 @@ public void DataCollectorAttachmentProcessor(RunnerInfo runnerInfo)
while (!streamReader.EndOfStream)
{
string? line = streamReader.ReadLine();
- Assert.IsTrue(line!.StartsWith("SessionEnded_Handler_"));
+ Assert.StartsWith("SessionEnded_Handler_", line!);
fileContent.Add(line);
}
}
@@ -152,8 +152,8 @@ public void DataCollectorAttachmentProcessor(RunnerInfo runnerInfo)
foreach (var dataCollectorLogFile in dataCollectorsLogs)
{
string dataCollectorLog = File.ReadAllText(dataCollectorLogFile);
- Assert.IsTrue(dataCollectorLog.Contains("MetadataReaderExtensionsHelper: Valid extension found: extension type 'DataCollector' identifier 'my://sample/datacollector' implementation 'AttachmentProcessorDataCollector.SampleDataCollectorV1' version '1'"));
- Assert.IsTrue(dataCollectorLog.Contains("MetadataReaderExtensionsHelper: Valid extension found: extension type 'DataCollector' identifier 'my://sample/datacollector' implementation 'AttachmentProcessorDataCollector.SampleDataCollectorV2' version '2'"));
+ Assert.Contains("MetadataReaderExtensionsHelper: Valid extension found: extension type 'DataCollector' identifier 'my://sample/datacollector' implementation 'AttachmentProcessorDataCollector.SampleDataCollectorV1' version '1'", dataCollectorLog);
+ Assert.Contains("MetadataReaderExtensionsHelper: Valid extension found: extension type 'DataCollector' identifier 'my://sample/datacollector' implementation 'AttachmentProcessorDataCollector.SampleDataCollectorV2' version '2'", dataCollectorLog);
Assert.IsTrue(Regex.IsMatch(dataCollectorLog, @"GetTestExtensionFromType: Discovered multiple test extensions with identifier data 'my://sample/datacollector' and type 'AttachmentProcessorDataCollector\.SampleDataCollectorV1, AttachmentProcessorDataCollector, Version=.*, Culture=neutral, PublicKeyToken=null' inside file '.*AttachmentProcessorDataCollector\.dll'; keeping the first one 'AttachmentProcessorDataCollector\.SampleDataCollectorV2, AttachmentProcessorDataCollector, Version=.*, Culture=neutral, PublicKeyToken=null'\."));
}
}
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectorAttachmentsProcessorsFactoryTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectorAttachmentsProcessorsFactoryTests.cs
index 0c72b79fa5..91d5102608 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectorAttachmentsProcessorsFactoryTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectorAttachmentsProcessorsFactoryTests.cs
@@ -52,11 +52,11 @@ public void Create_ShouldReturnListOfAttachmentProcessors()
var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null);
// assert
- Assert.AreEqual(3, dataCollectorAttachmentsProcessors.Length);
+ Assert.HasCount(3, dataCollectorAttachmentsProcessors);
- Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Count(x => x.FriendlyName == "Sample"));
- Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Count(x => x.FriendlyName == "SampleData3"));
- Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Count(x => x.FriendlyName == "Code Coverage"));
+ Assert.ContainsSingle(dataCollectorAttachmentsProcessors.Where(x => x.FriendlyName == "Sample"));
+ Assert.ContainsSingle(dataCollectorAttachmentsProcessors.Where(x => x.FriendlyName == "SampleData3"));
+ Assert.ContainsSingle(dataCollectorAttachmentsProcessors.Where(x => x.FriendlyName == "Code Coverage"));
Assert.AreEqual(typeof(DataCollectorAttachmentProcessor).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName);
Assert.AreEqual(typeof(DataCollectorAttachmentProcessor2).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[1].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName);
@@ -72,7 +72,7 @@ public void Create_EmptyOrNullInvokedDataCollector_ShouldReturnCodeCoverageDataA
var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(empty ? [] : null, null);
//assert
- Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Length);
+ Assert.ContainsSingle(dataCollectorAttachmentsProcessors);
Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName);
}
@@ -91,7 +91,7 @@ public void Create_ShouldNotFailIfWrongDataCollectorAttachmentProcessor()
var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null);
// assert
- Assert.AreEqual(1, dataCollectorAttachmentsProcessors.Length);
+ Assert.ContainsSingle(dataCollectorAttachmentsProcessors);
Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName);
}
@@ -108,7 +108,7 @@ public void Create_ShouldAddTwoTimeCodeCoverageDataAttachmentsHandler()
var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null);
// assert
- Assert.AreEqual(2, dataCollectorAttachmentsProcessors.Length);
+ Assert.HasCount(2, dataCollectorAttachmentsProcessors);
Assert.AreEqual(typeof(DataCollectorAttachmentProcessor).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName);
Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[1].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName);
}
@@ -141,7 +141,7 @@ public void Create_ShouldLoadOrderingByFilePath()
var dataCollectorAttachmentsProcessors = _dataCollectorAttachmentsProcessorsFactory.Create(invokedDataCollectors.ToArray(), null);
// assert
- Assert.AreEqual(2, dataCollectorAttachmentsProcessors.Length);
+ Assert.HasCount(2, dataCollectorAttachmentsProcessors);
Assert.IsTrue(Regex.IsMatch(dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName!, @"AttachmentProcessorDataCollector\.SampleDataCollectorAttachmentProcessor, AttachmentProcessorDataCollector, Version=.*, Culture=neutral, PublicKeyToken=null"));
Assert.AreEqual(Path.Combine(version2, Path.GetFileName(dataCollectorFilePath)), dataCollectorAttachmentsProcessors[0].DataCollectorAttachmentProcessorInstance.GetType().Assembly.Location);
Assert.AreEqual(typeof(CodeCoverageDataAttachmentsHandler).AssemblyQualifiedName, dataCollectorAttachmentsProcessors[1].DataCollectorAttachmentProcessorInstance.GetType().AssemblyQualifiedName);
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectorTests.Coverlet.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectorTests.Coverlet.cs
index 9931acf617..bef9bd5c77 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectorTests.Coverlet.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DataCollectorTests.Coverlet.cs
@@ -41,15 +41,15 @@ public void RunCoverletCoverage()
// This assert check that we're sure that we've updated collector setting code base with full path,
// otherwise without "custom coverlet code" inside ProxyExecutionManager coverlet dll won't be resolved inside testhost.
var log = Directory.GetFiles(logPathDirectory, $"coverletcoverage.{logId}.log").Single();
- Assert.IsTrue(File.ReadAllText(log).Contains("CoverletDataCollector in-process codeBase path"));
+ Assert.Contains("CoverletDataCollector in-process codeBase path", File.ReadAllText(log));
// Verify out-of-proc coverlet collector load
var dataCollectorLog = Directory.GetFiles(logPathDirectory, $"coverletcoverage.{logId}.datacollector*log").Single();
- Assert.IsTrue(File.ReadAllText(dataCollectorLog).Contains("[coverlet]Initializing CoverletCoverageDataCollector"));
+ Assert.Contains("[coverlet]Initializing CoverletCoverageDataCollector", File.ReadAllText(dataCollectorLog));
// Verify in-proc coverlet collector load
var hostLog = Directory.GetFiles(logPathDirectory, $"coverletcoverage.{logId}.host*log").Single();
- Assert.IsTrue(File.ReadAllText(hostLog).Contains("[coverlet]Initialize CoverletInProcDataCollector"));
+ Assert.Contains("[coverlet]Initialize CoverletInProcDataCollector", File.ReadAllText(hostLog));
// Verify default coverage file is generated
StdOutputContains("coverage.cobertura.xml");
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DebugAssertTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DebugAssertTests.cs
index abff214c4a..d6578bb9d8 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DebugAssertTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DebugAssertTests.cs
@@ -25,6 +25,6 @@ public void RunningTestWithAFailingDebugAssertDoesNotCrashTheHostingProcess(Runn
// this will have failed tests when our trace listener works and crash the testhost process when it does not
// because crashing processes is what a failed TPDebug.Assert does by default, unless you have a debugger attached
ValidateSummaryStatus(passed: 4, failed: 4, 0);
- StringAssert.Contains(StdOut, "threw exception: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException:");
+ Assert.Contains("threw exception: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException:", StdOut);
}
}
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DiscoveryTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DiscoveryTests.cs
index fc536f97b4..3680b3c9bc 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DiscoveryTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DiscoveryTests.cs
@@ -87,8 +87,8 @@ public void DiscoverTestsShouldShowProperWarningIfNoTestsOnTestCaseFilter(Runner
arguments = string.Concat(arguments, " /logger:\"console;prefix=true\"");
InvokeVsTest(arguments);
- StringAssert.Contains(StdOut, "Warning: No test matches the given testcase filter `NonExistTestCaseName` in");
- StringAssert.Contains(StdOut, "SimpleTestProject2.dll");
+ Assert.Contains("Warning: No test matches the given testcase filter `NonExistTestCaseName` in", StdOut);
+ Assert.Contains("SimpleTestProject2.dll", StdOut);
ExitCodeEquals(0);
}
@@ -136,7 +136,7 @@ public void DiscoverTestsShouldSucceedWhenAtLeastOneDllFindsRuntimeProvider(Runn
arguments = string.Concat(arguments, " /logger:\"console;prefix=true\"");
InvokeVsTest(arguments);
- StringAssert.Contains(StdOut, $"Skipping source: {nonTestDll} (.NETStandard,Version=v2.0,");
+ Assert.Contains($"Skipping source: {nonTestDll} (.NETStandard,Version=v2.0,", StdOut);
ExitCodeEquals(0);
}
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetArchitectureSwitchTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetArchitectureSwitchTests.cs
index b0d18da897..c0504923c6 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetArchitectureSwitchTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/DotnetArchitectureSwitchTests.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#if !NETFRAMEWORK
@@ -40,13 +40,9 @@ public static void ClassCleanup()
}
[TestMethod]
+ [OSCondition(OperatingSystems.Windows | OperatingSystems.OSX)]
public void GlobalInstallation()
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- {
- return;
- }
-
var projectName = "ArchitectureSwitch.csproj";
var projectPath = GetProjectFullPath(projectName);
var projectDirectory = Path.GetDirectoryName(projectPath);
@@ -60,14 +56,14 @@ public void GlobalInstallation()
ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework net8.0", out string stdOut, out _, out _, env, projectDirectory);
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
- Assert.IsTrue(stdOut.Contains("Runtime location: /usr/local/share/dotnet/shared/Microsoft.NETCore.App"));
+ Assert.Contains("Runtime location: /usr/local/share/dotnet/shared/Microsoft.NETCore.App", stdOut);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- Assert.IsTrue(stdOut.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\shared\Microsoft.NETCore.App"));
+ Assert.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\shared\Microsoft.NETCore.App", stdOut);
}
- Assert.IsTrue(stdOut.Contains("OSArchitecture: ARM64"));
- Assert.IsTrue(stdOut.Contains("ProcessArchitecture: ARM64"));
+ Assert.Contains("OSArchitecture: ARM64", stdOut);
+ Assert.Contains("ProcessArchitecture: ARM64", stdOut);
// Verify switch using csproj
@@ -83,27 +79,23 @@ static void AssertSwitch(string output)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
- Assert.IsTrue(output.Contains("Runtime location: /usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App"));
+ Assert.Contains("Runtime location: /usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App", output);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- Assert.IsTrue(output.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\x64\shared\Microsoft.NETCore.App"));
+ Assert.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\x64\shared\Microsoft.NETCore.App", output);
}
- Assert.IsTrue(output.Contains("OSArchitecture: X64"));
- Assert.IsTrue(output.Contains("ProcessArchitecture: X64"));
+ Assert.Contains("OSArchitecture: X64", output);
+ Assert.Contains("ProcessArchitecture: X64", output);
}
}
[TestMethod]
[DataRow(true, false)]
[DataRow(false, true)]
+ [OSCondition(OperatingSystems.Windows | OperatingSystems.OSX)]
public void DOTNET_ROOTS_EnvironmentVariables(bool dotnetRoot, bool dotnetRootX64)
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- {
- return;
- }
-
var env = new Dictionary
{
["DOTNET_ROOT"] = null
@@ -117,14 +109,14 @@ public void DOTNET_ROOTS_EnvironmentVariables(bool dotnetRoot, bool dotnetRootX6
ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework net8.0", out string stdOut, out _, out _, env, projectDirectory);
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
- Assert.IsTrue(stdOut.Contains("Runtime location: /usr/local/share/dotnet/shared/Microsoft.NETCore.App"), "Unexpected runtime location");
+ Assert.Contains("Runtime location: /usr/local/share/dotnet/shared/Microsoft.NETCore.App", stdOut, "Unexpected runtime location");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- Assert.IsTrue(stdOut.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\shared\Microsoft.NETCore.App"));
+ Assert.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\shared\Microsoft.NETCore.App", stdOut);
}
- Assert.IsTrue(stdOut.Contains("OSArchitecture: ARM64"), "Unexpected OSArchitecture");
- Assert.IsTrue(stdOut.Contains("ProcessArchitecture: ARM64"), "Unexpected ProcessArchitecture");
+ Assert.Contains("OSArchitecture: ARM64", stdOut, "Unexpected OSArchitecture");
+ Assert.Contains("ProcessArchitecture: ARM64", stdOut, "Unexpected ProcessArchitecture");
env.Clear();
env["DOTNET_ROOT"] = null;
@@ -150,21 +142,17 @@ public void DOTNET_ROOTS_EnvironmentVariables(bool dotnetRoot, bool dotnetRootX6
void AssertSwitch(string output)
{
Assert.IsTrue(Regex.IsMatch(output.Replace(@"\", "/"), $"Runtime location: .*{s_privateX64Installation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location");
- Assert.IsTrue(output.Contains("OSArchitecture: X64"), "Unexpected OSArchitecture");
- Assert.IsTrue(output.Contains("ProcessArchitecture: X64"), "Unexpected ProcessArchitecture");
+ Assert.Contains("OSArchitecture: X64", output, "Unexpected OSArchitecture");
+ Assert.Contains("ProcessArchitecture: X64", output, "Unexpected ProcessArchitecture");
Assert.IsTrue(!dotnetRoot || output.Contains($"DOTNET_ROOT: {s_privateX64Installation}"), "Unexpected DOTNET_ROOT var");
Assert.IsTrue(!dotnetRootX64 || output.Contains($"DOTNET_ROOT_X64: {s_privateX64Installation}"), "Unexpected DOTNET_ROOT_X64 var");
}
}
[TestMethod]
+ [OSCondition(OperatingSystems.Windows | OperatingSystems.OSX)]
public void PrivateX64BuildToGlobalArmInstallation()
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- {
- return;
- }
-
var env = new Dictionary
{
["DOTNET_ROOT"] = null
@@ -178,8 +166,8 @@ public void PrivateX64BuildToGlobalArmInstallation()
// Verify native architecture
ExecuteApplication(privateInstallationMuxer, $"test {projectPath} --framework net8.0", out string stdOut, out _, out _, env, projectDirectory);
Assert.IsTrue(Regex.IsMatch(stdOut.Replace(@"\", "/"), $"Runtime location: .*{s_privateX64Installation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location");
- Assert.IsTrue(stdOut.Contains("OSArchitecture: X64"), "Unexpected OSArchitecture");
- Assert.IsTrue(stdOut.Contains("ProcessArchitecture: X64"), "Unexpected ProcessArchitecture");
+ Assert.Contains("OSArchitecture: X64", stdOut, "Unexpected OSArchitecture");
+ Assert.Contains("ProcessArchitecture: X64", stdOut, "Unexpected ProcessArchitecture");
// Verify switch using csproj
ExecuteApplication($"{s_privateX64Installation}/{GetMuxerName}", $"test {projectPath} --framework net8.0 --arch arm64", out stdOut, out _, out _, env, projectDirectory);
@@ -193,21 +181,17 @@ public void PrivateX64BuildToGlobalArmInstallation()
static void AssertSwitch(string output)
{
Assert.IsTrue(Regex.IsMatch(output.Replace(@"\", "/"), $"Runtime location: .*{GetDefaultLocation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location");
- Assert.IsTrue(output.Contains("OSArchitecture: ARM64"), "Unexpected OSArchitecture");
- Assert.IsTrue(output.Contains("ProcessArchitecture: ARM64"), "Unexpected ProcessArchitecture");
+ Assert.Contains("OSArchitecture: ARM64", output, "Unexpected OSArchitecture");
+ Assert.Contains("ProcessArchitecture: ARM64", output, "Unexpected ProcessArchitecture");
}
}
[TestMethod]
[DataRow(true, false)]
[DataRow(false, true)]
+ [OSCondition(OperatingSystems.Windows | OperatingSystems.OSX)]
public void PrivateX64BuildToDOTNET_ROOTS_EnvironmentVariables(bool dotnetRoot, bool dotnetRootArm64)
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- {
- return;
- }
-
var env = new Dictionary
{
["DOTNET_ROOT"] = null
@@ -221,8 +205,8 @@ public void PrivateX64BuildToDOTNET_ROOTS_EnvironmentVariables(bool dotnetRoot,
// Verify native architecture
ExecuteApplication(privateInstallationMuxer, $"test {projectPath} --framework net8.0", out string stdOut, out _, out _, env, projectDirectory);
Assert.IsTrue(Regex.IsMatch(stdOut.Replace(@"\", "/"), $"Runtime location: .*{s_privateX64Installation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location");
- Assert.IsTrue(stdOut.Contains("OSArchitecture: X64"), "Unexpected OSArchitecture");
- Assert.IsTrue(stdOut.Contains("ProcessArchitecture: X64"), "Unexpected ProcessArchitecture");
+ Assert.Contains("OSArchitecture: X64", stdOut, "Unexpected OSArchitecture");
+ Assert.Contains("ProcessArchitecture: X64", stdOut, "Unexpected ProcessArchitecture");
env.Clear();
env["DOTNET_ROOT"] = null;
@@ -248,21 +232,17 @@ public void PrivateX64BuildToDOTNET_ROOTS_EnvironmentVariables(bool dotnetRoot,
void AssertSwitch(string output)
{
Assert.IsTrue(Regex.IsMatch(output.Replace(@"\", "/"), $"Runtime location: .*{GetDefaultLocation.Replace(@"\", "/")}.*shared.*Microsoft.NETCore.App"), "Unexpected runtime location");
- Assert.IsTrue(output.Contains("OSArchitecture: ARM64"), "Unexpected OSArchitecture");
- Assert.IsTrue(output.Contains("ProcessArchitecture: ARM64"), "Unexpected ProcessArchitecture");
+ Assert.Contains("OSArchitecture: ARM64", output, "Unexpected OSArchitecture");
+ Assert.Contains("ProcessArchitecture: ARM64", output, "Unexpected ProcessArchitecture");
Assert.IsTrue(!dotnetRoot || output.Contains($"DOTNET_ROOT: {GetDefaultLocation}"), "Unexpected DOTNET_ROOT var");
Assert.IsTrue(!dotnetRootArm64 || output.Contains($"DOTNET_ROOT_ARM64: {GetDefaultLocation}"), "Unexpected DOTNET_ROOT_ARM64 var");
}
}
[TestMethod]
+ [OSCondition(OperatingSystems.Windows | OperatingSystems.OSX)]
public void SilentlyForceX64()
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- {
- return;
- }
-
var projectName = "ArchitectureSwitch.csproj";
var projectPath = GetProjectFullPath(projectName);
var projectDirectory = Path.GetDirectoryName(projectPath);
@@ -274,14 +254,14 @@ public void SilentlyForceX64()
ExecuteApplication(GetDefaultDotnetMuxerLocation, $"test {projectPath} --framework {GetFrameworkVersionToForceToX64}", out string stdOut, out _, out _, env, projectDirectory);
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
- Assert.IsTrue(stdOut.Contains("Runtime location: /usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App"));
+ Assert.Contains("Runtime location: /usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App", stdOut);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- Assert.IsTrue(stdOut.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\x64\shared\Microsoft.NETCore.App"));
+ Assert.Contains($@"Runtime location: {Environment.ExpandEnvironmentVariables("%ProgramFiles%")}\dotnet\x64\shared\Microsoft.NETCore.App", stdOut);
}
- Assert.IsTrue(stdOut.Contains("OSArchitecture: X64"));
- Assert.IsTrue(stdOut.Contains("ProcessArchitecture: X64"));
+ Assert.Contains("OSArchitecture: X64", stdOut);
+ Assert.Contains("ProcessArchitecture: X64", stdOut);
}
private static string GetMuxerName => RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "dotnet" : "dotnet.exe";
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/EventLogCollectorTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/EventLogCollectorTests.cs
index abadb1e3e5..4eeb03dcfb 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/EventLogCollectorTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/EventLogCollectorTests.cs
@@ -92,7 +92,7 @@ private void VaildateDataCollectorOutput(TempDirectory tempDirectory)
.Select(d => d.FullName)
.ToList();
- Assert.AreEqual(4, resultFiles.Count);
+ Assert.HasCount(4, resultFiles);
StdOutputContains("Event Log.xml");
var fileContent1 = File.ReadAllText(resultFiles[0]);
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/ExecutionTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/ExecutionTests.cs
index 37521595e2..f19d76ad79 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/ExecutionTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/ExecutionTests.cs
@@ -391,7 +391,7 @@ public void ExecuteTestsShouldSucceedWhenAtLeastOneDllFindsRuntimeProvider(Runne
arguments = string.Concat(arguments, " /logger:\"console;prefix=true\"");
InvokeVsTest(arguments);
- StringAssert.Contains(StdOut, $"Skipping source: {nonTestDll} (.NETStandard,Version=v2.0,");
+ Assert.Contains($"Skipping source: {nonTestDll} (.NETStandard,Version=v2.0,", StdOut);
ExitCodeEquals(1);
}
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/LoggerTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/LoggerTests.cs
index 4bf30e4da6..6ff4e474ca 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/LoggerTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/LoggerTests.cs
@@ -122,7 +122,7 @@ public void TrxLoggerWithLogFilePrefixShouldGenerateMultipleTrx(RunnerInfo runne
InvokeVsTest(arguments);
var trxFilePaths = Directory.EnumerateFiles(TempDirectory.Path, trxFileNamePattern + "_net*.trx");
- Assert.IsTrue(trxFilePaths.Count() > 1);
+ Assert.IsGreaterThan(1, trxFilePaths.Count());
}
[TestMethod]
@@ -194,7 +194,7 @@ public void TrxLoggerResultSummaryOutcomeValueShouldNotChangeIfNoTestsExecutedAn
private static void AssertExpectedHtml(XmlElement root)
{
XmlNodeList elementList = root.GetElementsByTagName("details");
- Assert.AreEqual(2, elementList.Count);
+ Assert.HasCount(2, elementList);
foreach (XmlElement element in elementList)
{
@@ -236,7 +236,7 @@ private static void IsFileAndContentEqual(string filePath)
string[] divs = ["Total tests", "Passed", "Failed", "Skipped", "Run duration", "Pass percentage", "PassingTest"];
foreach (string str in divs)
{
- StringAssert.Contains(filePathContent, str);
+ Assert.Contains(str, filePathContent);
}
}
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/ManagedNameTests/SpecialNameTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/ManagedNameTests/SpecialNameTests.cs
index 28a2de5f37..007d4fd4e3 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/ManagedNameTests/SpecialNameTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/ManagedNameTests/SpecialNameTests.cs
@@ -46,7 +46,7 @@ public void VerifyThatInvalidIdentifierNamesAreParsed()
var methodInfo = ManagedNameHelper.GetMethod(assembly, typeName, methodName);
ManagedNameHelper.GetManagedName(methodInfo, out var typeName2, out var methodName2);
- Assert.IsTrue(method == methodInfo);
+ Assert.AreEqual(method, methodInfo);
Assert.AreEqual(typeName, typeName2, $"Type parse roundtrip test failed: {method} ({typeName} != {typeName2})");
Assert.AreEqual(methodName, methodName2, $"Method parse roundtrip test failed: {method} ({methodName} != {methodName2})");
}
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/PostProcessingTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/PostProcessingTests.cs
index 964ddb1b0c..6dbc197592 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/PostProcessingTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/PostProcessingTests.cs
@@ -72,7 +72,7 @@ public void DotnetSDKSimulation_PostProcessing()
while (!streamReader.EndOfStream)
{
string line = streamReader.ReadLine();
- Assert.IsTrue(line.StartsWith("SessionEnded_Handler_"));
+ Assert.StartsWith("SessionEnded_Handler_", line);
fileContent.Add(line);
}
diff --git a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/VideoRecorderTests.cs b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/VideoRecorderTests.cs
index 0c12398d07..9f259f39d9 100644
--- a/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/VideoRecorderTests.cs
+++ b/test/Microsoft.TestPlatform.Acceptance.IntegrationTests/VideoRecorderTests.cs
@@ -27,7 +27,7 @@ public void VideoRecorderDataCollectorShouldRecordVideoWithRunSettings(RunnerInf
// Verify video attachments were created
var resultFiles = Directory.GetFiles(TempDirectory.Path, "*.wmv", SearchOption.AllDirectories);
- Assert.IsTrue(resultFiles.Length > 0,
+ Assert.IsNotEmpty(resultFiles,
$"Expected video attachments (.wmv) in results directory '{TempDirectory.Path}', but found none. "
+ $"All files: [{string.Join(", ", Directory.GetFiles(TempDirectory.Path, "*", SearchOption.AllDirectories).Select(Path.GetFileName))}]");
}
diff --git a/test/Microsoft.TestPlatform.Build.UnitTests/TestTaskUtilsTests.cs b/test/Microsoft.TestPlatform.Build.UnitTests/TestTaskUtilsTests.cs
index a8ed80b8f1..d16be041df 100644
--- a/test/Microsoft.TestPlatform.Build.UnitTests/TestTaskUtilsTests.cs
+++ b/test/Microsoft.TestPlatform.Build.UnitTests/TestTaskUtilsTests.cs
@@ -36,9 +36,9 @@ public void CreateArgumentShouldAddOneEntryForCLIRunSettings()
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, " -- ");
- StringAssert.Contains(commandline, $"\"{arg1}\"");
- StringAssert.Contains(commandline, $"{arg2}");
+ Assert.Contains(" -- ", commandline);
+ Assert.Contains($"\"{arg1}\"", commandline);
+ Assert.Contains($"{arg2}", commandline);
}
[TestMethod]
@@ -58,9 +58,9 @@ public void CreateArgumentShouldAddCLIRunSettingsArgAtEnd()
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, " -- ");
- StringAssert.Contains(commandline, $"\"{arg1}\"");
- StringAssert.Contains(commandline, $"{arg2}");
+ Assert.Contains(" -- ", commandline);
+ Assert.Contains($"\"{arg1}\"", commandline);
+ Assert.Contains($"{arg2}", commandline);
}
[TestMethod]
@@ -71,7 +71,7 @@ public void CreateArgumentShouldPassResultsDirectoryCorrectly()
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, $"--resultsDirectory:\"{_vsTestTask.VSTestResultsDirectory?.ItemSpec}\"");
+ Assert.Contains($"--resultsDirectory:\"{_vsTestTask.VSTestResultsDirectory?.ItemSpec}\"", commandline);
}
[TestMethod]
@@ -82,8 +82,8 @@ public void CreateArgumentShouldNotSetConsoleLoggerVerbosityIfConsoleLoggerIsGiv
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.DoesNotMatch(commandline, new Regex("(--logger:\"Console;Verbosity=normal\")"));
- StringAssert.Contains(commandline, "--logger:\"Console;Verbosity=quiet\"");
+ Assert.DoesNotMatchRegex(new Regex("(--logger:\"Console;Verbosity=normal\")"), commandline);
+ Assert.Contains("--logger:\"Console;Verbosity=quiet\"", commandline);
}
[TestMethod]
@@ -93,7 +93,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLogger
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=normal");
+ Assert.Contains("--logger:Console;Verbosity=normal", commandline);
}
[TestMethod]
@@ -103,7 +103,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLogger
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=normal");
+ Assert.Contains("--logger:Console;Verbosity=normal", commandline);
}
[TestMethod]
@@ -113,7 +113,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLogger
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=normal");
+ Assert.Contains("--logger:Console;Verbosity=normal", commandline);
}
[TestMethod]
@@ -123,7 +123,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLogger
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=normal");
+ Assert.Contains("--logger:Console;Verbosity=normal", commandline);
}
[TestMethod]
@@ -133,7 +133,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLogger
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=normal");
+ Assert.Contains("--logger:Console;Verbosity=normal", commandline);
}
[TestMethod]
@@ -143,7 +143,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLogger
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=normal");
+ Assert.Contains("--logger:Console;Verbosity=normal", commandline);
}
[TestMethod]
@@ -153,7 +153,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToQuietIfConsoleLoggerI
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=quiet");
+ Assert.Contains("--logger:Console;Verbosity=quiet", commandline);
}
[TestMethod]
@@ -163,7 +163,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToQuietIfConsoleLoggerI
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=quiet");
+ Assert.Contains("--logger:Console;Verbosity=quiet", commandline);
}
[TestMethod]
@@ -173,7 +173,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToMinimalIfConsoleLogge
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=minimal");
+ Assert.Contains("--logger:Console;Verbosity=minimal", commandline);
}
[TestMethod]
@@ -183,7 +183,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToMinimalIfConsoleLogge
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=minimal");
+ Assert.Contains("--logger:Console;Verbosity=minimal", commandline);
}
[TestMethod]
@@ -193,7 +193,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLogger
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=normal");
+ Assert.Contains("--logger:Console;Verbosity=normal", commandline);
}
[TestMethod]
@@ -203,7 +203,7 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToQuietIfConsoleLoggerI
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:Console;Verbosity=quiet");
+ Assert.Contains("--logger:Console;Verbosity=quiet", commandline);
}
[TestMethod]
@@ -213,7 +213,7 @@ public void CreateArgumentShouldPreserveWhiteSpaceInLogger()
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:\"trx;LogFileName=foo bar.trx\"");
+ Assert.Contains("--logger:\"trx;LogFileName=foo bar.trx\"", commandline);
}
[TestMethod]
@@ -226,8 +226,8 @@ public void CreateArgumentShouldAddOneCollectArgumentForEachCollect()
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--collect:name1");
- StringAssert.Contains(commandline, "--collect:\"name 2\"");
+ Assert.Contains("--collect:name1", commandline);
+ Assert.Contains("--collect:\"name 2\"", commandline);
}
[TestMethod]
@@ -237,8 +237,8 @@ public void CreateArgumentShouldAddMultipleTestAdapterPaths()
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--testAdapterPath:path1");
- StringAssert.Contains(commandline, "--testAdapterPath:path2");
+ Assert.Contains("--testAdapterPath:path1", commandline);
+ Assert.Contains("--testAdapterPath:path2", commandline);
}
[TestMethod]
@@ -247,8 +247,8 @@ public void CreateArgumentShouldAddMultipleLoggers()
_vsTestTask.VSTestLogger = ["trx;LogFileName=foo bar.trx", "console"];
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--logger:\"trx;LogFileName=foo bar.trx\"");
- StringAssert.Contains(commandline, "--logger:console");
+ Assert.Contains("--logger:\"trx;LogFileName=foo bar.trx\"", commandline);
+ Assert.Contains("--logger:console", commandline);
}
[TestMethod]
@@ -261,7 +261,7 @@ public void CreateArgumentShouldAddTraceCollectorDirectoryPathAsTestAdapterForCo
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
string expectedArg = $"--testAdapterPath:\"{_vsTestTask.VSTestTraceDataCollectorDirectoryPath?.ItemSpec}\"";
- StringAssert.Contains(commandline, expectedArg);
+ Assert.Contains(expectedArg, commandline);
}
[TestMethod]
@@ -274,7 +274,7 @@ public void CreateArgumentShouldNotAddTraceCollectorDirectoryPathAsTestAdapterFo
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
string notExpectedArg = $"--testAdapterPath:\"{_vsTestTask.VSTestTraceDataCollectorDirectoryPath?.ItemSpec}\"";
- StringAssert.DoesNotMatch(commandline, new Regex(Regex.Escape(notExpectedArg)));
+ Assert.DoesNotMatchRegex(new Regex(Regex.Escape(notExpectedArg)), commandline);
}
[TestMethod]
@@ -287,7 +287,7 @@ public void CreateArgumentShouldAddTraceCollectorDirectoryPathAsTestAdapterIfSet
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
string expectedArg = $"--testAdapterPath:{_vsTestTask.VSTestTraceDataCollectorDirectoryPath?.ItemSpec}";
- StringAssert.Contains(commandline, expectedArg);
+ Assert.Contains(expectedArg, commandline);
}
[TestMethod]
@@ -299,7 +299,7 @@ public void CreateArgumentShouldNotAddTestAdapterPathIfVSTestTraceDataCollectorD
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.DoesNotMatch(commandline, new Regex(@"(--testAdapterPath:)"));
+ Assert.DoesNotMatchRegex(new Regex(@"(--testAdapterPath:)"), commandline);
}
[TestMethod]
@@ -309,6 +309,6 @@ public void CreateArgumentShouldAddNoLogoOptionIfSpecifiedByUser()
var commandline = TestTaskUtils.CreateCommandLineArguments(_vsTestTask);
- StringAssert.Contains(commandline, "--nologo");
+ Assert.Contains("--nologo", commandline);
}
}
diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeClientTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeClientTests.cs
index 0eb5640f24..fbf6fe4eee 100644
--- a/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeClientTests.cs
+++ b/test/Microsoft.TestPlatform.Client.UnitTests/DesignMode/DesignModeClientTests.cs
@@ -42,6 +42,8 @@ public class DesignModeClientTests
private readonly AutoResetEvent _completeEvent;
private readonly Mock _mockPlatformEnvironment;
+ public TestContext TestContext { get; set; }
+
public DesignModeClientTests()
{
_mockTestRequestManager = new Mock();
@@ -198,7 +200,7 @@ public void DesignModeClientWithGetTestRunnerProcessStartInfoShouldDeserializeTe
// Assert.
Assert.IsNotNull(receivedTestRunPayload);
Assert.IsNotNull(receivedTestRunPayload.TestCases);
- Assert.AreEqual(1, receivedTestRunPayload.TestCases.Count);
+ Assert.HasCount(1, receivedTestRunPayload.TestCases);
// Validate traits
var traits = receivedTestRunPayload.TestCases.ToArray()[0].Traits;
@@ -259,7 +261,7 @@ public void DesignModeClientWithRunSelectedTestCasesShouldDeserializeTestsWithTr
// Assert.
Assert.IsNotNull(receivedTestRunPayload);
Assert.IsNotNull(receivedTestRunPayload.TestCases);
- Assert.AreEqual(1, receivedTestRunPayload.TestCases.Count);
+ Assert.HasCount(1, receivedTestRunPayload.TestCases);
// Validate traits
var traits = receivedTestRunPayload.TestCases.ToArray()[0].Traits;
@@ -300,7 +302,7 @@ public void DesignModeClientLaunchCustomHostMustReturnIfAckComes()
Action sendMessageAction = () => testableDesignModeClient.InvokeCustomHostLaunchAckCallback(expectedProcessId, null);
_mockCommunicationManager.Setup(cm => cm.SendMessage(MessageType.CustomTestHostLaunch, It.IsAny