Skip to content

Commit 9df7897

Browse files
authored
Update Dependencies and Migrate to XUnit (#616)
* Update Dependencies and swap to xunit dependencies instead of mstest * Refactor tests to use Xunit
1 parent c9b3e91 commit 9df7897

25 files changed

Lines changed: 584 additions & 608 deletions

AppInspector.Benchmarks/AppInspector.Benchmarks.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
14-
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.14.0" />
13+
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
14+
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.15.2" />
1515

1616
</ItemGroup>
1717
<ItemGroup>

AppInspector.CLI/AppInspector.CLI.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@
8080
<ItemGroup>
8181
<PackageReference Include="DotLiquid" Version="2.3.197" />
8282
<PackageReference Include="Sarif.Sdk" Version="4.5.4" />
83-
<PackageReference Include="Serilog" Version="4.2.0" />
84-
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.1" />
83+
<PackageReference Include="Serilog" Version="4.3.0" />
84+
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.2" />
8585
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
86-
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
86+
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
8787
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
8888
</ItemGroup>
8989

AppInspector.Common/AppInspector.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</PropertyGroup>
3131

3232
<ItemGroup>
33-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
33+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.6" />
3434

3535

3636
</ItemGroup>

AppInspector.Logging/AppInspector.Logging.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131

3232
<ItemGroup>
3333
<PackageReference Include="CommandLineParser" Version="2.9.1" />
34-
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.1" />
34+
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.2" />
3535
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
36-
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
36+
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
3737

3838
</ItemGroup>
3939

AppInspector.RulesEngine/AppInspector.RulesEngine.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
<ItemGroup>
3333
<PackageReference Include="gstocco.YamlDotNet.YamlPath" Version="1.0.26" />
3434
<PackageReference Include="JsonCons.JsonPath" Version="1.1.0" />
35-
<PackageReference Include="Microsoft.CST.OAT" Version="1.2.77" />
36-
<PackageReference Include="Microsoft.CST.RecursiveExtractor" Version="1.2.40" />
37-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
35+
<PackageReference Include="Microsoft.CST.OAT" Version="1.2.79" />
36+
<PackageReference Include="Microsoft.CST.RecursiveExtractor" Version="1.2.41" />
37+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.6" />
3838
<PackageReference Include="YamlDotNet" Version="16.3.0" />
3939
</ItemGroup>
4040

AppInspector.Tests/AppInspector.Tests.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
54
<Nullable>enable</Nullable>
65
<LangVersion>10.0</LangVersion>
76
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
@@ -150,11 +149,16 @@
150149
</ItemGroup>
151150

152151
<ItemGroup>
153-
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.4" />
154-
<PackageReference Include="MSTest" Version="3.8.3" />
155-
<PackageReference Include="Combinatorial.MSTest" Version="1.0.0" />
152+
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.6" />
156153
<PackageReference Include="System.Reflection" Version="4.3.0" />
157154
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
155+
<PackageReference Include="xunit" Version="2.9.3" />
156+
<PackageReference Include="Xunit.Combinatorial" Version="1.6.24" />
157+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
158+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
159+
<PrivateAssets>all</PrivateAssets>
160+
</PackageReference>
161+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
158162
</ItemGroup>
159163

160164
<ItemGroup>

AppInspector.Tests/Commands/TestAnalyzeCmd.cs

Lines changed: 249 additions & 241 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
using System;
2-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
32
using System.IO;
43
using Microsoft.ApplicationInspector.Commands;
54
using Microsoft.ApplicationInspector.Common;
65
using Microsoft.ApplicationInspector.Logging;
76
using Microsoft.Extensions.Logging;
87
using Microsoft.Extensions.Logging.Abstractions;
9-
using Microsoft.VisualStudio.TestTools.UnitTesting;
8+
using Xunit;
109

1110
namespace AppInspector.Tests.Commands;
1211

13-
[TestClass]
1412
[ExcludeFromCodeCoverage]
1513
public class TestExportTagsCmd
1614
{
1715
private ILoggerFactory factory = new NullLoggerFactory();
1816

1917
private readonly LogOptions logOptions = new();
2018
private string testRulesPath = string.Empty;
21-
22-
[TestInitialize]
23-
public void InitOutput()
19+
public TestExportTagsCmd()
2420
{
2521
factory = logOptions.GetLoggerFactory();
2622
testRulesPath = Path.Combine("TestData","TestExportTagsCmd","Rules", "TestRules.json");
2723
}
2824

29-
[TestMethod]
25+
[Fact]
3026
public void ExportCustom()
3127
{
3228
ExportTagsOptions options = new()
@@ -36,13 +32,13 @@ public void ExportCustom()
3632
};
3733
ExportTagsCommand command = new(options, factory);
3834
var result = command.GetResult();
39-
Assert.IsTrue(result.TagsList.Contains("Test.Tags.Linux"));
40-
Assert.IsTrue(result.TagsList.Contains("Test.Tags.Windows"));
41-
Assert.AreEqual(2, result.TagsList.Count);
42-
Assert.AreEqual(ExportTagsResult.ExitCode.Success, result.ResultCode);
35+
Assert.Contains("Test.Tags.Linux", result.TagsList);
36+
Assert.Contains("Test.Tags.Windows", result.TagsList);
37+
Assert.Equal(2, result.TagsList.Count);
38+
Assert.Equal(ExportTagsResult.ExitCode.Success, result.ResultCode);
4339
}
4440

45-
[TestMethod]
41+
[Fact]
4642
public void ExportDefault()
4743
{
4844
ExportTagsOptions options = new()
@@ -51,16 +47,16 @@ public void ExportDefault()
5147
};
5248
ExportTagsCommand command = new(options, factory);
5349
var result = command.GetResult();
54-
Assert.AreEqual(ExportTagsResult.ExitCode.Success, result.ResultCode);
50+
Assert.Equal(ExportTagsResult.ExitCode.Success, result.ResultCode);
5551
}
5652

57-
[TestMethod]
53+
[Fact]
5854
public void NoDefaultNoCustomRules()
5955
{
6056
ExportTagsOptions options = new()
6157
{
6258
IgnoreDefaultRules = true
6359
};
64-
Assert.ThrowsException<OpException>(() => new ExportTagsCommand(options));
60+
Assert.Throws<OpException>(() => new ExportTagsCommand(options));
6561
}
6662
}

AppInspector.Tests/Commands/TestPackRulesCmd.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22
using System.IO;
33
using Microsoft.ApplicationInspector.Commands;
44
using Microsoft.ApplicationInspector.Common;
5-
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
using Xunit;
66

77
namespace AppInspector.Tests.Commands;
88

9-
[TestClass]
109
[ExcludeFromCodeCoverage]
1110
public class TestPackRulesCmd
1211
{
13-
[TestMethod]
12+
[Fact]
1413
public void NoCustomNoEmbeddedRules()
1514
{
16-
Assert.ThrowsException<OpException>(() => new PackRulesCommand(new PackRulesOptions()));
15+
Assert.Throws<OpException>(() => new PackRulesCommand(new PackRulesOptions()));
1716
}
1817

19-
[TestMethod]
18+
[Fact]
2019
public void PackEmbeddedRules()
2120
{
2221
PackRulesOptions options = new() { PackEmbeddedRules = true };
2322
PackRulesCommand command = new(options);
2423
var result = command.GetResult();
25-
Assert.AreEqual(PackRulesResult.ExitCode.Success, result.ResultCode);
24+
Assert.Equal(PackRulesResult.ExitCode.Success, result.ResultCode);
2625
}
2726
}

AppInspector.Tests/Commands/TestTagDiffCmd.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
using Microsoft.ApplicationInspector.Logging;
77
using Microsoft.Extensions.Logging;
88
using Microsoft.Extensions.Logging.Abstractions;
9-
using Microsoft.VisualStudio.TestTools.UnitTesting;
9+
using Xunit;
1010

1111
namespace AppInspector.Tests.Commands;
1212

1313
/// <summary>
1414
/// Test class for TagDiff Command
1515
/// </summary>
16-
[TestClass]
1716
[ExcludeFromCodeCoverage]
1817
public class TestTagDiffCmd
1918
{
@@ -25,8 +24,7 @@ public class TestTagDiffCmd
2524
private static string testFileFourWindowsOneLinuxPath = string.Empty;
2625
private static string testRulesPath = string.Empty;
2726

28-
[ClassInitialize]
29-
public static void InitOutput(TestContext testContext)
27+
public TestTagDiffCmd()
3028
{
3129
loggerFactory = logOptions.GetLoggerFactory();
3230
testFileFourWindowsOneLinuxPath =
@@ -40,9 +38,9 @@ public static void InitOutput(TestContext testContext)
4038
testRulesPath = Path.Combine("TestData", "TestTagDiffCmd", "Rules", "FindWindows.json");
4139
}
4240

43-
[DataRow(TagTestType.Equality, TagDiffResult.ExitCode.TestPassed)]
44-
[DataRow(TagTestType.Inequality, TagDiffResult.ExitCode.TestFailed)]
45-
[TestMethod]
41+
[InlineData(TagTestType.Equality, TagDiffResult.ExitCode.TestPassed)]
42+
[InlineData(TagTestType.Inequality, TagDiffResult.ExitCode.TestFailed)]
43+
[Theory]
4644
public void Equality(TagTestType tagTestType, TagDiffResult.ExitCode expectedExitCode)
4745
{
4846
TagDiffOptions options = new()
@@ -58,12 +56,12 @@ public void Equality(TagTestType tagTestType, TagDiffResult.ExitCode expectedExi
5856
TagDiffCommand command = new(options, loggerFactory);
5957
var result = command.GetResult();
6058

61-
Assert.AreEqual(expectedExitCode, result.ResultCode);
59+
Assert.Equal(expectedExitCode, result.ResultCode);
6260
}
6361

64-
[DataRow(TagTestType.Equality, TagDiffResult.ExitCode.TestFailed)]
65-
[DataRow(TagTestType.Inequality, TagDiffResult.ExitCode.TestPassed)]
66-
[TestMethod]
62+
[InlineData(TagTestType.Equality, TagDiffResult.ExitCode.TestFailed)]
63+
[InlineData(TagTestType.Inequality, TagDiffResult.ExitCode.TestPassed)]
64+
[Theory]
6765
public void Inequality(TagTestType tagTestType, TagDiffResult.ExitCode expectedExitCode)
6866
{
6967
TagDiffOptions options = new()
@@ -79,10 +77,10 @@ public void Inequality(TagTestType tagTestType, TagDiffResult.ExitCode expectedE
7977
TagDiffCommand command = new(options, loggerFactory);
8078
var result = command.GetResult();
8179

82-
Assert.AreEqual(expectedExitCode, result.ResultCode);
80+
Assert.Equal(expectedExitCode, result.ResultCode);
8381
}
8482

85-
[TestMethod]
83+
[Fact]
8684
public void InvalidSourcePath_Fail()
8785
{
8886
TagDiffOptions options = new()
@@ -92,10 +90,10 @@ public void InvalidSourcePath_Fail()
9290
FilePathExclusions = Array.Empty<string>() //allow source under unittest path
9391
};
9492
var cmd = new TagDiffCommand(options, loggerFactory);
95-
Assert.ThrowsException<OpException>(() => cmd.GetResult());
93+
Assert.Throws<OpException>(() => cmd.GetResult());
9694
}
9795

98-
[TestMethod]
96+
[Fact]
9997
public void NoDefaultNoCustomRules_Fail()
10098
{
10199
TagDiffOptions options = new()
@@ -107,6 +105,6 @@ public void NoDefaultNoCustomRules_Fail()
107105
};
108106

109107
var command = new TagDiffCommand(options, loggerFactory);
110-
Assert.ThrowsException<OpException>(() => command.GetResult());
108+
Assert.Throws<OpException>(() => command.GetResult());
111109
}
112110
}

0 commit comments

Comments
 (0)