Skip to content

Commit b0a3cb8

Browse files
Move away from MSTest to Xunit. (#136)
1 parent e21e889 commit b0a3cb8

6 files changed

Lines changed: 216 additions & 204 deletions

RoslynCodeProvider.msbuild

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<!-- Composite targets -->
1919
<Target Name="BuildCI" DependsOnTargets="Clean;Build" />
2020

21-
<Target Name="Build" DependsOnTargets="BuildAssemblies;BuildTests;BuildPackages" />
21+
<Target Name="Build" DependsOnTargets="BuildAssemblies;UnitTest;BuildPackages" />
2222
<Target Name="Clean" DependsOnTargets="CleanPackages;CleanTests;CleanAssemblies" />
2323
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
2424

@@ -58,5 +58,8 @@
5858
<Exec Command=".nuget\NuGet.exe restore" />
5959
</Target>
6060

61-
<Import Project="tools\RoslynCodeProvider.targets" />
61+
<Target Name="UnitTest" DependsOnTargets="BuildTests">
62+
<MSBuild Targets="XunitTest" Projects="@(TestProject)" />
63+
</Target>
64+
6265
</Project>

RoslynCodeProviderTest/CSharpProviderTest.cs

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,131 @@
11
using System;
22
using System.CodeDom.Compiler;
3-
using System.IO;
43
using Microsoft.CodeDom.Providers.DotNetCompilerPlatform;
5-
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
using Xunit;
65

76
namespace Microsoft.CodeDom.Providers.DotNetCompilerPlatformTest {
87

9-
[TestClass]
108
public class CSharpProviderTest {
119

1210
private CommonCodeDomProviderTests commonTests = new CommonCodeDomProviderTests();
1311
private static CodeDomProvider csharpCodeProvider;
1412

15-
[ClassInitialize]
16-
public static void ClassInitialize(TestContext testContext) {
13+
static CSharpProviderTest() {
1714
#pragma warning disable CS0618
1815
csharpCodeProvider = new CSharpCodeProvider(compilerSettings: CompilerSettingsHelper.CSC);
1916
#pragma warning restore CS0618
2017
AppContext.SetSwitch("Switch.System.DisableTempFileCollectionDirectoryFeature", true);
2118
}
2219

23-
[TestMethod]
20+
[Fact]
21+
public void AssemblyVersion()
22+
{
23+
commonTests.AssemblyVersion(csharpCodeProvider);
24+
}
25+
26+
[Fact]
2427
public void FileExtension() {
2528
commonTests.FileExtension(csharpCodeProvider, "cs");
2629
}
2730

28-
[TestMethod]
31+
[Fact]
2932
public void CompileAssemblyFromSource_Parse_Error() {
3033
commonTests.CompileAssemblyFromSource_Parse_Error(csharpCodeProvider);
3134
}
3235

33-
[TestMethod]
36+
[Fact]
3437
public void CompileAssemblyFromSource_WarningAsError() {
3538
commonTests.CompileAssemblyFromSource_WarningAsError(csharpCodeProvider,
3639
// the variable a is declared but not used
3740
"public class FooClass { public string Execute() { int a; return \"output\"; }}",
3841
"CS0168"/*errorNumber*/);
3942
}
4043

41-
[TestMethod]
44+
[Fact]
4245
public void CompileAssemblyFromSource_ReferenceAssembly_AssemblyNameOnly() {
4346
commonTests.CompileAssemblyFromSource_ReferenceAssembly_AssemblyNameOnly(csharpCodeProvider);
4447
}
4548

46-
[TestMethod]
49+
[Fact]
4750
public void CompileAssemblyFromSource_ReferenceAssembly_NameCannotBeResolved() {
4851
commonTests.CompileAssemblyFromSource_ReferenceAssembly_NameCannotBeResolved(csharpCodeProvider);
4952
}
5053

51-
[TestMethod]
54+
[Fact]
5255
public void CompileAssemblyFromSource_ReferenceAssembly_LocalReference() {
5356
commonTests.CompileAssemblyFromSource_ReferenceAssembly_LocalReference(csharpCodeProvider);
5457
}
5558

56-
[TestMethod]
59+
[Fact]
5760
public void CompileAssemblyFromSource_ReferenceAssembly_PathWithComma() {
5861
commonTests.CompileAssemblyFromSource_ReferenceAssembly_PathWithComma(csharpCodeProvider);
5962
}
6063

61-
[TestMethod]
64+
[Fact]
6265
public void CompileAssemblyFromSource_GenerateInMemory_True() {
6366
commonTests.CompileAssemblyFromSource_GenerateInMemory_True(csharpCodeProvider);
6467
}
6568

66-
[TestMethod]
69+
[Fact]
6770
public void CompileAssemblyFromSource_GenerateInMemory_False() {
6871
commonTests.CompileAssemblyFromSource_GenerateInMemory_False(csharpCodeProvider,
6972
"public class FooClass { public string Execute() { return \"output\";}}");
7073
}
7174

72-
[TestMethod]
75+
[Fact]
7376
public void CompileAssemblyFromSource_InvalidOutputPath() {
7477
commonTests.CompileAssemblyFromSource_InvalidOutputPath(csharpCodeProvider);
7578
}
7679

77-
[TestMethod]
80+
[Fact]
7881
public void CompileAssemblyFromSource_GenerateExecutable_True() {
7982
commonTests.CompileAssemblyFromSource_GenerateExecutable_True(csharpCodeProvider);
8083
}
8184

82-
[TestMethod]
85+
[Fact]
8386
public void CompileAssemblyFromSource_GenerateExecutable_True_Failed() {
8487
commonTests.CompileAssemblyFromSource_GenerateExecutable_True_Failed(csharpCodeProvider);
8588
}
8689

87-
[TestMethod]
90+
[Fact]
8891
public void CompileAssemblyFromSource_CreateOutputFileFailed() {
8992
commonTests.CompileAssemblyFromSource_CreateOutputFileFailed(csharpCodeProvider);
9093
}
9194

92-
[TestMethod]
95+
[Fact]
9396
public void CompileAssemblyFromSource_CreatePDBFileFailed() {
9497
commonTests.CompileAssemblyFromSource_CreatePDBFileFailed(csharpCodeProvider);
9598
}
9699

97-
[TestMethod]
100+
[Fact]
98101
public void CompileAssemblyFromSource_IncludeDebugInformation_True() {
99102
commonTests.CompileAssemblyFromSource_IncludeDebugInformation_True(csharpCodeProvider);
100103
}
101104

102-
[TestMethod]
105+
[Fact]
103106
public void CompileAssemblyFromSource_IncludeDebugInformation_False() {
104107
commonTests.CompileAssemblyFromSource_IncludeDebugInformation_False(csharpCodeProvider);
105108
}
106109

107-
[TestMethod]
110+
[Fact]
108111
public void CompileAssemblyFromDom() {
109112
commonTests.CompileAssemblyFromDom(csharpCodeProvider);
110113
}
111114

112-
[TestMethod]
115+
[Fact]
113116
public void CompileAssemblyFromFile() {
114117
commonTests.CompileAssemblyFromFile(csharpCodeProvider);
115118
}
116119

117-
[TestMethod]
120+
[Fact]
118121
public void CompileAssemblyFromFile_ASPNet_Magic()
119122
{
120123
// Complete added frippery is: "/nowarn:1659;1699;1701;612;618"
121124
ProviderOptions opts = new ProviderOptions(CompilerSettingsHelper.CSC) { UseAspNetSettings = true };
122125
commonTests.CompileAssemblyFromFile_CheckArgs(new CSharpCodeProvider(opts), "/nowarn:1659;1699;1701;612;618", true);
123126
}
124127

125-
[TestMethod]
128+
[Fact]
126129
public void CompileAssemblyFromFile_No_ASPNet_Magic()
127130
{
128131
// _codeProvider uses options (aka CompilerSettingsHelper.VB) created via constructor, so it should

0 commit comments

Comments
 (0)