View runsettings.xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<MSTest>
<Parallelize>
<Workers>8</Workers>
<Scope>MethodLevel</Scope>
</Parallelize>
</MSTest>
</RunSettings>
View MsTest.cs
[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)]
View MsTest.cs
Assert.AreEqual(28, _actualFuel); // Tests whether the specified values are equal.
Assert.AreNotEqual(28, _actualFuel); // Tests whether the specified values are unequal. Same as AreEqual for numeric values.
Assert.AreSame(_expectedRocket, _actualRocket); // Tests whether the specified objects both refer to the same object
Assert.AreNotSame(_expectedRocket, _actualRocket); // Tests whether the specified objects refer to different objects
Assert.IsTrue(_isThereEnoughFuel); // Tests whether the specified condition is true
Assert.IsFalse(_isThereEnoughFuel); // Tests whether the specified condition is false
Assert.IsNull(_actualRocket); // Tests whether the specified object is null
Assert.IsNotNull(_actualRocket); // Tests whether the specified object is non-null
Assert.IsInstanceOfType(_actualRocket, typeof(Falcon9Rocket)); // Tests whether the specified object is an instance of the expected type
Assert.IsNotInstanceOfType(_actualRocket, typeof(Falcon9Rocket)); // Tests whether the specified object is not an i
View MsTest.cs
[DataTestMethod]
[DynamicData(nameof(GetData), DynamicDataSourceType.Method)]
public void TestAddDynamicDataMethod(int a, int b, int expected)
{
var actual = _calculator.Add(a, b);
Assert.AreEqual(expected, actual);
}
public static IEnumerable<object[]> GetData()
{
View MsTest.cs
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "TestsData.csv", "TestsData#csv", DataAccessMethod.Sequential)]
[TestMethod]
public void DataDrivenTest()
{
int valueA = Convert.ToInt32(this.TestContext.DataRow["valueA"]);
int valueB = Convert.ToInt32(this.TestContext.DataRow["valueB"]);
int expected = Convert.ToInt32(this.TestContext.DataRow["expectedResult"]);
}
View MsTest.cs
[DataRow(0, 0)]
[DataRow(1, 1)]
[DataRow(2, 1)]
[DataRow(80, 23416728348467685)]
[DataTestMethod]
public void GivenDataFibonacciReturnsResultsOk(int number, int result)
{
var fib = new Fib();
var actual = fib.Fibonacci(number);
Assert.AreEqual(result, actual);
View MsTest.cs
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MSTestUnitTests
{
// A class that contains MSTest unit tests. (Required)
[TestClass]
public class YourUnitTests
{
[AssemblyInitialize]
public static void AssemblyInit(TestContext context)
View MsTest.cs
Install-Package MSTest.TestFramework
Install-Package MSTest.TestAdapter
Install-Package Microsoft.NET.Test.Sdk
View StyleCop.cs
public const string secretSaturnBaseName = "Titan Chocolate Corns 2.1";
public const string SECRET_SATURN_BASE_NAME = "Titan Chocolate Corns 2.1";
View StyleCop.cs
public const string SecretSaturnBaseName = "Titan Chocolate Corns 2.1";