|
1 | 1 | using System; |
2 | 2 | using System.CodeDom.Compiler; |
3 | | -using System.IO; |
4 | 3 | using Microsoft.CodeDom.Providers.DotNetCompilerPlatform; |
5 | | -using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 4 | +using Xunit; |
6 | 5 |
|
7 | 6 | namespace Microsoft.CodeDom.Providers.DotNetCompilerPlatformTest { |
8 | 7 |
|
9 | | - [TestClass] |
10 | 8 | public class CSharpProviderTest { |
11 | 9 |
|
12 | 10 | private CommonCodeDomProviderTests commonTests = new CommonCodeDomProviderTests(); |
13 | 11 | private static CodeDomProvider csharpCodeProvider; |
14 | 12 |
|
15 | | - [ClassInitialize] |
16 | | - public static void ClassInitialize(TestContext testContext) { |
| 13 | + static CSharpProviderTest() { |
17 | 14 | #pragma warning disable CS0618 |
18 | 15 | csharpCodeProvider = new CSharpCodeProvider(compilerSettings: CompilerSettingsHelper.CSC); |
19 | 16 | #pragma warning restore CS0618 |
20 | 17 | AppContext.SetSwitch("Switch.System.DisableTempFileCollectionDirectoryFeature", true); |
21 | 18 | } |
22 | 19 |
|
23 | | - [TestMethod] |
| 20 | + [Fact] |
| 21 | + public void AssemblyVersion() |
| 22 | + { |
| 23 | + commonTests.AssemblyVersion(csharpCodeProvider); |
| 24 | + } |
| 25 | + |
| 26 | + [Fact] |
24 | 27 | public void FileExtension() { |
25 | 28 | commonTests.FileExtension(csharpCodeProvider, "cs"); |
26 | 29 | } |
27 | 30 |
|
28 | | - [TestMethod] |
| 31 | + [Fact] |
29 | 32 | public void CompileAssemblyFromSource_Parse_Error() { |
30 | 33 | commonTests.CompileAssemblyFromSource_Parse_Error(csharpCodeProvider); |
31 | 34 | } |
32 | 35 |
|
33 | | - [TestMethod] |
| 36 | + [Fact] |
34 | 37 | public void CompileAssemblyFromSource_WarningAsError() { |
35 | 38 | commonTests.CompileAssemblyFromSource_WarningAsError(csharpCodeProvider, |
36 | 39 | // the variable a is declared but not used |
37 | 40 | "public class FooClass { public string Execute() { int a; return \"output\"; }}", |
38 | 41 | "CS0168"/*errorNumber*/); |
39 | 42 | } |
40 | 43 |
|
41 | | - [TestMethod] |
| 44 | + [Fact] |
42 | 45 | public void CompileAssemblyFromSource_ReferenceAssembly_AssemblyNameOnly() { |
43 | 46 | commonTests.CompileAssemblyFromSource_ReferenceAssembly_AssemblyNameOnly(csharpCodeProvider); |
44 | 47 | } |
45 | 48 |
|
46 | | - [TestMethod] |
| 49 | + [Fact] |
47 | 50 | public void CompileAssemblyFromSource_ReferenceAssembly_NameCannotBeResolved() { |
48 | 51 | commonTests.CompileAssemblyFromSource_ReferenceAssembly_NameCannotBeResolved(csharpCodeProvider); |
49 | 52 | } |
50 | 53 |
|
51 | | - [TestMethod] |
| 54 | + [Fact] |
52 | 55 | public void CompileAssemblyFromSource_ReferenceAssembly_LocalReference() { |
53 | 56 | commonTests.CompileAssemblyFromSource_ReferenceAssembly_LocalReference(csharpCodeProvider); |
54 | 57 | } |
55 | 58 |
|
56 | | - [TestMethod] |
| 59 | + [Fact] |
57 | 60 | public void CompileAssemblyFromSource_ReferenceAssembly_PathWithComma() { |
58 | 61 | commonTests.CompileAssemblyFromSource_ReferenceAssembly_PathWithComma(csharpCodeProvider); |
59 | 62 | } |
60 | 63 |
|
61 | | - [TestMethod] |
| 64 | + [Fact] |
62 | 65 | public void CompileAssemblyFromSource_GenerateInMemory_True() { |
63 | 66 | commonTests.CompileAssemblyFromSource_GenerateInMemory_True(csharpCodeProvider); |
64 | 67 | } |
65 | 68 |
|
66 | | - [TestMethod] |
| 69 | + [Fact] |
67 | 70 | public void CompileAssemblyFromSource_GenerateInMemory_False() { |
68 | 71 | commonTests.CompileAssemblyFromSource_GenerateInMemory_False(csharpCodeProvider, |
69 | 72 | "public class FooClass { public string Execute() { return \"output\";}}"); |
70 | 73 | } |
71 | 74 |
|
72 | | - [TestMethod] |
| 75 | + [Fact] |
73 | 76 | public void CompileAssemblyFromSource_InvalidOutputPath() { |
74 | 77 | commonTests.CompileAssemblyFromSource_InvalidOutputPath(csharpCodeProvider); |
75 | 78 | } |
76 | 79 |
|
77 | | - [TestMethod] |
| 80 | + [Fact] |
78 | 81 | public void CompileAssemblyFromSource_GenerateExecutable_True() { |
79 | 82 | commonTests.CompileAssemblyFromSource_GenerateExecutable_True(csharpCodeProvider); |
80 | 83 | } |
81 | 84 |
|
82 | | - [TestMethod] |
| 85 | + [Fact] |
83 | 86 | public void CompileAssemblyFromSource_GenerateExecutable_True_Failed() { |
84 | 87 | commonTests.CompileAssemblyFromSource_GenerateExecutable_True_Failed(csharpCodeProvider); |
85 | 88 | } |
86 | 89 |
|
87 | | - [TestMethod] |
| 90 | + [Fact] |
88 | 91 | public void CompileAssemblyFromSource_CreateOutputFileFailed() { |
89 | 92 | commonTests.CompileAssemblyFromSource_CreateOutputFileFailed(csharpCodeProvider); |
90 | 93 | } |
91 | 94 |
|
92 | | - [TestMethod] |
| 95 | + [Fact] |
93 | 96 | public void CompileAssemblyFromSource_CreatePDBFileFailed() { |
94 | 97 | commonTests.CompileAssemblyFromSource_CreatePDBFileFailed(csharpCodeProvider); |
95 | 98 | } |
96 | 99 |
|
97 | | - [TestMethod] |
| 100 | + [Fact] |
98 | 101 | public void CompileAssemblyFromSource_IncludeDebugInformation_True() { |
99 | 102 | commonTests.CompileAssemblyFromSource_IncludeDebugInformation_True(csharpCodeProvider); |
100 | 103 | } |
101 | 104 |
|
102 | | - [TestMethod] |
| 105 | + [Fact] |
103 | 106 | public void CompileAssemblyFromSource_IncludeDebugInformation_False() { |
104 | 107 | commonTests.CompileAssemblyFromSource_IncludeDebugInformation_False(csharpCodeProvider); |
105 | 108 | } |
106 | 109 |
|
107 | | - [TestMethod] |
| 110 | + [Fact] |
108 | 111 | public void CompileAssemblyFromDom() { |
109 | 112 | commonTests.CompileAssemblyFromDom(csharpCodeProvider); |
110 | 113 | } |
111 | 114 |
|
112 | | - [TestMethod] |
| 115 | + [Fact] |
113 | 116 | public void CompileAssemblyFromFile() { |
114 | 117 | commonTests.CompileAssemblyFromFile(csharpCodeProvider); |
115 | 118 | } |
116 | 119 |
|
117 | | - [TestMethod] |
| 120 | + [Fact] |
118 | 121 | public void CompileAssemblyFromFile_ASPNet_Magic() |
119 | 122 | { |
120 | 123 | // Complete added frippery is: "/nowarn:1659;1699;1701;612;618" |
121 | 124 | ProviderOptions opts = new ProviderOptions(CompilerSettingsHelper.CSC) { UseAspNetSettings = true }; |
122 | 125 | commonTests.CompileAssemblyFromFile_CheckArgs(new CSharpCodeProvider(opts), "/nowarn:1659;1699;1701;612;618", true); |
123 | 126 | } |
124 | 127 |
|
125 | | - [TestMethod] |
| 128 | + [Fact] |
126 | 129 | public void CompileAssemblyFromFile_No_ASPNet_Magic() |
127 | 130 | { |
128 | 131 | // _codeProvider uses options (aka CompilerSettingsHelper.VB) created via constructor, so it should |
|
0 commit comments