Skip to content

Commit de04f82

Browse files
lbussellCopilot
andauthored
Convert ImageBuilder tests from xUnit to MSTest (#2135)
Converts `ImageBuilder.Tests` from xUnit to MSTest. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7b97e73 commit de04f82

61 files changed

Lines changed: 1079 additions & 1089 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/ImageBuilder.Tests/AnnotateEolDigestsCommandTests.cs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
using System.Threading;
1515
using Moq;
1616
using Newtonsoft.Json;
17-
using Xunit.Abstractions;
18-
using Xunit;
17+
using Shouldly;
1918

2019
namespace Microsoft.DotNet.ImageBuilder.Tests
2120
{
21+
[TestClass]
2222
public class AnnotateEolDigestsCommandTests
2323
{
24-
private readonly ITestOutputHelper _outputHelper;
2524
private readonly DateOnly _globalDate = new DateOnly(2024, 6, 10);
2625
private readonly DateOnly _specificDigestDate = new DateOnly(2022, 1, 1);
2726
private const string RepoPrefix = "public/";
@@ -30,12 +29,7 @@ public class AnnotateEolDigestsCommandTests
3029
private const string AnnotationDigest1 = "annotationdigest1";
3130
private const string AnnotationDigest2 = "annotationdigest2";
3231

33-
public AnnotateEolDigestsCommandTests(ITestOutputHelper outputHelper)
34-
{
35-
_outputHelper = outputHelper;
36-
}
37-
38-
[Fact]
32+
[TestMethod]
3933
public async Task AnnotateEolDigestsCommand_AnnotationSuccess()
4034
{
4135
using TempFolderContext tempFolderContext = TestHelper.UseTempFolder();
@@ -61,10 +55,10 @@ public async Task AnnotateEolDigestsCommand_AnnotationSuccess()
6155
$"{AcrName}/{RepoPrefix}@{AnnotationDigest2}"
6256
];
6357
string[] annotationDigests = File.ReadAllLines(Path.Combine(tempFolderContext.Path, AnnotationsOutputPath));
64-
Assert.Equal(expectedAnnotationDigests, annotationDigests);
58+
annotationDigests.ShouldBe(expectedAnnotationDigests);
6559
}
6660

67-
[Fact]
61+
[TestMethod]
6862
public async Task AnnotateEolDigestsCommand_AnnotationFailures()
6963
{
7064
using TempFolderContext tempFolderContext = TestHelper.UseTempFolder();
@@ -78,13 +72,11 @@ public async Task AnnotateEolDigestsCommand_AnnotationFailures()
7872
digestAlreadyAnnotated: false,
7973
digestAnnotationIsSuccessful: false);
8074

81-
InvalidOperationException ex = await Assert.ThrowsAsync<InvalidOperationException>(() => command.ExecuteAsync());
82-
Assert.Contains(
83-
$"(failed: 2, skipped: 0)",
84-
ex.Message);
75+
InvalidOperationException ex = await Should.ThrowAsync<InvalidOperationException>(() => command.ExecuteAsync());
76+
ex.Message.ShouldContain($"(failed: 2, skipped: 0)");
8577
}
8678

87-
[Fact]
79+
[TestMethod]
8880
public async Task AnnotateEolDigestsCommand_CheckAnnotations_AlreadyAnnotated_NonMatchingEolDate()
8981
{
9082
using TempFolderContext tempFolderContext = TestHelper.UseTempFolder();
@@ -99,17 +91,15 @@ public async Task AnnotateEolDigestsCommand_CheckAnnotations_AlreadyAnnotated_No
9991
digestAnnotationIsSuccessful: true,
10092
useNonMatchingDate: true);
10193

102-
InvalidOperationException ex = await Assert.ThrowsAsync<InvalidOperationException>(() => command.ExecuteAsync());
103-
Assert.Contains(
104-
$"(failed: 0, skipped: 2)",
105-
ex.Message);
94+
InvalidOperationException ex = await Should.ThrowAsync<InvalidOperationException>(() => command.ExecuteAsync());
95+
ex.Message.ShouldContain($"(failed: 0, skipped: 2)");
10696

10797
lifecycleMetadataServiceMock.Verify(
10898
o => o.AnnotateEolDigestAsync(It.IsAny<string>(), It.IsAny<DateOnly>(), It.IsAny<CancellationToken>()),
10999
Times.Never());
110100
}
111101

112-
[Fact]
102+
[TestMethod]
113103
public async Task AnnotateEolDigestsCommand_CheckAnnotations_AlreadyAnnotated_MatchingEolDate()
114104
{
115105
using TempFolderContext tempFolderContext = TestHelper.UseTempFolder();

0 commit comments

Comments
 (0)