Skip to content

Commit 5f1e37d

Browse files
authored
tests: generate test project as DynamicallyLinkedLibrary (#266)
1 parent 593b7b8 commit 5f1e37d

File tree

3 files changed

+1
-28
lines changed

3 files changed

+1
-28
lines changed

src/FluentAssertions.Analyzers.TestUtils/GenerateCode.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public static string GenericArrayExpressionBodyAssertion(string assertion) => Ge
2929
.AppendLine(" public bool BooleanProperty { get; set; }")
3030
.AppendLine(" public string Message { get; set; }")
3131
.AppendLine(" }")
32-
.AppendMainMethod()
3332
.AppendLine("}")
3433
.ToString();
3534

@@ -57,7 +56,6 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
5756
.AppendLine(" public bool BooleanProperty { get; set; }")
5857
.AppendLine(" public string Message { get; set; }")
5958
.AppendLine(" }")
60-
.AppendMainMethod()
6159
.AppendLine("}")
6260
.ToString();
6361

@@ -75,7 +73,6 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
7573
.AppendLine($" {assertion}")
7674
.AppendLine(" }")
7775
.AppendLine(" }")
78-
.AppendMainMethod()
7976
.AppendLine("}")
8077
.ToString();
8178

@@ -98,7 +95,6 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
9895
.AppendLine(" {")
9996
.AppendLine(" public bool BooleanProperty { get; set; }")
10097
.AppendLine(" }")
101-
.AppendMainMethod()
10298
.AppendLine("}")
10399
.ToString();
104100

@@ -115,7 +111,6 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
115111
.AppendLine($" {assertion}")
116112
.AppendLine(" }")
117113
.AppendLine(" }")
118-
.AppendMainMethod()
119114
.AppendLine("}")
120115
.ToString();
121116

@@ -132,7 +127,6 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
132127
.AppendLine($" {assertion}")
133128
.AppendLine(" }")
134129
.AppendLine(" }")
135-
.AppendMainMethod()
136130
.AppendLine("}")
137131
.ToString();
138132

@@ -148,7 +142,6 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
148142
.AppendLine($" {assertion}")
149143
.AppendLine(" }")
150144
.AppendLine(" }")
151-
.AppendMainMethod()
152145
.AppendLine("}")
153146
.ToString();
154147

@@ -164,7 +157,6 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
164157
.AppendLine($" {assertion}")
165158
.AppendLine(" }")
166159
.AppendLine(" }")
167-
.AppendMainMethod()
168160
.AppendLine("}")
169161
.ToString();
170162

@@ -182,7 +174,6 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
182174
.AppendLine(" }")
183175
.AppendLine(" async void AsyncVoidMethod() { await Task.CompletedTask; }")
184176
.AppendLine(" }")
185-
.AppendMainMethod()
186177
.AppendLine("}")
187178
.ToString();
188179

@@ -199,7 +190,6 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
199190
.AppendLine($" {statement}")
200191
.AppendLine(" }")
201192
.AppendLine(" }")
202-
.AppendMainMethod()
203193
.AppendLine("}")
204194
.ToString();
205195

@@ -218,7 +208,6 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
218208
.AppendLine($" {assertion}")
219209
.AppendLine(" }")
220210
.AppendLine(" }")
221-
.AppendMainMethod()
222211
.AppendLine("}")
223212
.ToString();
224213

@@ -240,16 +229,7 @@ public static string GenericIListExpressionBodyAssertion(string assertion) => Ge
240229
.AppendLine($" {assertion}")
241230
.AppendLine(" }")
242231
.AppendLine(" }")
243-
.AppendMainMethod()
244232
.AppendLine("}")
245233
.ToString();
246-
247-
public static StringBuilder AppendMainMethod(this StringBuilder builder) => builder
248-
.AppendLine(" class Program")
249-
.AppendLine(" {")
250-
.AppendLine(" public static void Main()")
251-
.AppendLine(" {")
252-
.AppendLine(" }")
253-
.AppendLine(" }");
254234
}
255235
}

src/FluentAssertions.Analyzers.Tests/DiagnosticVerifier.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ private static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer
227227
var compilation = project.GetCompilationAsync().Result;
228228
var compilationWithAnalyzers = compilation
229229
.WithOptions(compilation.Options
230+
.WithOutputKind(OutputKind.DynamicallyLinkedLibrary)
230231
.WithSpecificDiagnosticOptions(new Dictionary<string, ReportDiagnostic>
231232
{
232233
["CS1701"] = ReportDiagnostic.Suppress, // Binding redirects

src/FluentAssertions.Analyzers.Tests/Tips/MsTestTests.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public void AssertIsTrue_NestedUsingInNamespace1_TestAnalyzer(string assertion)
3838
.AppendLine($" {assertion}")
3939
.AppendLine(" }")
4040
.AppendLine(" }")
41-
.AppendMainMethod()
4241
.AppendLine("}")
4342
.ToString());
4443

@@ -62,7 +61,6 @@ public void AssertIsTrue_NestedUsingInNamespace2_TestAnalyzer(string assertion)
6261
.AppendLine($" {assertion}")
6362
.AppendLine(" }")
6463
.AppendLine(" }")
65-
.AppendMainMethod()
6664
.AppendLine("}")
6765
.ToString());
6866

@@ -86,7 +84,6 @@ public void AssertIsTrue_NestedUsingInNamespace3_TestAnalyzer(string assertion)
8684
.AppendLine($" {assertion}")
8785
.AppendLine(" }")
8886
.AppendLine(" }}")
89-
.AppendMainMethod()
9087
.AppendLine("}")
9188
.ToString());
9289

@@ -110,7 +107,6 @@ public void AssertIsTrue_NestedUsingInNamespace4_TestAnalyzer(string assertion)
110107
.AppendLine($" {assertion}")
111108
.AppendLine(" }")
112109
.AppendLine(" }}")
113-
.AppendMainMethod()
114110
.AppendLine("}")
115111
.ToString());
116112

@@ -134,7 +130,6 @@ public void AssertIsTrue_NestedUsingInNamespace5_TestAnalyzer(string assertion)
134130
.AppendLine($" {assertion}")
135131
.AppendLine(" }")
136132
.AppendLine(" }")
137-
.AppendMainMethod()
138133
.AppendLine("}")
139134
.ToString());
140135

@@ -158,7 +153,6 @@ public void AssertIsTrue_NestedUsingInNamespace6_TestAnalyzer(string assertion)
158153
.AppendLine($" {assertion}")
159154
.AppendLine(" }")
160155
.AppendLine(" }")
161-
.AppendMainMethod()
162156
.AppendLine("}")
163157
.ToString());
164158

@@ -182,7 +176,6 @@ public void AssertIsTrue_NestedUsingInNamespace7_TestAnalyzer(string assertion)
182176
.AppendLine($" {assertion}")
183177
.AppendLine(" }")
184178
.AppendLine(" }")
185-
.AppendMainMethod()
186179
.AppendLine("}")
187180
.ToString());
188181

@@ -206,7 +199,6 @@ public void AssertIsTrue_NestedUsingInNamespace8_TestAnalyzer(string assertion)
206199
.AppendLine($" {assertion}")
207200
.AppendLine(" }")
208201
.AppendLine(" }")
209-
.AppendMainMethod()
210202
.AppendLine("}")
211203
.ToString());
212204

0 commit comments

Comments
 (0)