diff --git a/.azuredevops/pipelines/pr-ci.yml b/.azuredevops/pipelines/pr-ci.yml index 3ba705f..f09eed2 100644 --- a/.azuredevops/pipelines/pr-ci.yml +++ b/.azuredevops/pipelines/pr-ci.yml @@ -59,7 +59,7 @@ jobs: inputs: command: test projects: $(Build.SourcesDirectory)/MSBuildCache.sln - arguments: -restore:false --no-build --configuration $(BuildConfiguration) -- --report-trx --results-directory $(Agent.TempDirectory) + arguments: -restore:false --no-build --configuration $(BuildConfiguration) - publish: $(ArtifactsDirectory) displayName: Publish Artifacts diff --git a/global.json b/global.json index a63e1bd..7819a7e 100644 --- a/global.json +++ b/global.json @@ -4,6 +4,9 @@ "rollForward": "latestFeature" }, "msbuild-sdks": { - "MSTest.Sdk": "3.9.1" + "MSTest.Sdk": "3.11.1" + }, + "test": { + "runner": "Microsoft.Testing.Platform" } } diff --git a/src/Common.Tests/Hashing/DirectoryFileHasherTests.cs b/src/Common.Tests/Hashing/DirectoryFileHasherTests.cs index 37f1dd4..341c143 100644 --- a/src/Common.Tests/Hashing/DirectoryFileHasherTests.cs +++ b/src/Common.Tests/Hashing/DirectoryFileHasherTests.cs @@ -19,7 +19,7 @@ public class DirectoryFileHasherTests public TestContext TestContext { get; set; } #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - [DataTestMethod] + [TestMethod] [DataRow(@"X:\Dir\Foo\1.0.0\lib\Foo.dll", true)] [DataRow(@"x:\dIR\Foo\1.0.0\lib\Foo.dll", true)] [DataRow(@"x:\OtherDir\foo.txt", false)] @@ -30,7 +30,7 @@ public void ContainsPath(string path, bool expectedResult) Assert.AreEqual(expectedResult, hasher.ContainsPath(path)); } - [DataTestMethod] + [TestMethod] [DataRow(@"Dir\Foo\1.0.0\lib\Foo.dll", true)] [DataRow(@"dIR\Foo\2.0.0\lib\Foo.dll", true)] [DataRow(@"OtherDir\foo.txt", false)] diff --git a/src/Common.Tests/Hashing/OutputHasherTests.cs b/src/Common.Tests/Hashing/OutputHasherTests.cs index b112dcf..ed046b2 100644 --- a/src/Common.Tests/Hashing/OutputHasherTests.cs +++ b/src/Common.Tests/Hashing/OutputHasherTests.cs @@ -50,7 +50,7 @@ public async Task ComputeHashFileNotFound() string file = Path.Combine(dir, "file.txt"); // Ensure exceptions are propagated correctly. - await Assert.ThrowsExceptionAsync(async () => await hasher.ComputeHashAsync(file, CancellationToken.None)); + await Assert.ThrowsExactlyAsync(async () => await hasher.ComputeHashAsync(file, CancellationToken.None)); } [TestMethod] diff --git a/src/Common.Tests/HexUtilitiesTests.cs b/src/Common.Tests/HexUtilitiesTests.cs index 72e04b4..d292a95 100644 --- a/src/Common.Tests/HexUtilitiesTests.cs +++ b/src/Common.Tests/HexUtilitiesTests.cs @@ -10,7 +10,7 @@ namespace Microsoft.MSBuildCache.Tests; [TestClass] public class HexUtilitiesTests { - [DataTestMethod] + [TestMethod] [DataRow("0123456789ABCDEFabcdef", new byte[] { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0xAB, 0xCD, 0xEF, })] [DataRow("", null)] [DataRow(null, null)] @@ -29,12 +29,12 @@ public void HexToBytes(string hex, byte[]? expectedBytes) Assert.AreEqual(expectedBytes.Length, bytes.Length); for (int i = 0; i < expectedBytes.Length; i++) { - Assert.AreEqual(expectedBytes[i], bytes[i], "Index {0}", i); + Assert.AreEqual(expectedBytes[i], bytes[i], $"Index {i}"); } } [TestMethod] - public void HexToBytesOddChars() => Assert.ThrowsException(() => HexUtilities.HexToBytes("fAbCd")); + public void HexToBytesOddChars() => Assert.ThrowsExactly(() => HexUtilities.HexToBytes("fAbCd")); [TestMethod] public void HexToBytesBadChars() diff --git a/src/Common.Tests/PathHelperTests.cs b/src/Common.Tests/PathHelperTests.cs index bf4c008..e5f4601 100644 --- a/src/Common.Tests/PathHelperTests.cs +++ b/src/Common.Tests/PathHelperTests.cs @@ -8,7 +8,7 @@ namespace Microsoft.MSBuildCache.Tests; [TestClass] public class PathHelperTests { - [DataTestMethod] + [TestMethod] [DataRow(@"X:\A\B\C", @"X:\A", @"B\C")] // Lots of .. and . [DataRow(@"X:\Z\..\A\B\.\C", @"X:\Y\..\D\..\A\.\.", @"B\C")] @@ -27,7 +27,7 @@ public class PathHelperTests public void MakePathRelative(string path, string basePath, string? expectedResult) => Assert.AreEqual(expectedResult, path.MakePathRelativeTo(basePath)); - [DataTestMethod] + [TestMethod] [DataRow(@"X:\A\B\C\file.txt", @"X:\A", true)] // Lots of .. and . [DataRow(@"X:\Z\..\A\B\.\C\file.txt", @"X:\Y\..\D\..\A\.\.", true)] diff --git a/src/Repack.Tests/RepackTests.cs b/src/Repack.Tests/RepackTests.cs index b2e2504..3ef2789 100644 --- a/src/Repack.Tests/RepackTests.cs +++ b/src/Repack.Tests/RepackTests.cs @@ -16,7 +16,7 @@ namespace Microsoft.MSBuildCache.Repack.Tests; [TestClass] public class RepackTests { - [DataTestMethod] + [TestMethod] [DataRow(typeof(MSBuildCacheAzureBlobStoragePlugin))] [DataRow(typeof(MSBuildCacheAzurePipelinesPlugin))] [DataRow(typeof(MSBuildCacheLocalPlugin))]