Skip to content

Commit 996a3db

Browse files
committed
Update to Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit 1.0.0-beta1-63812-02
1 parent ac7d7c9 commit 996a3db

5 files changed

Lines changed: 21 additions & 49 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1119CSharp7UnitTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules
99
using StyleCop.Analyzers.Test.MaintainabilityRules;
1010
using TestHelper;
1111
using Xunit;
12-
using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier<StyleCop.Analyzers.MaintainabilityRules.SA1119StatementMustNotUseUnnecessaryParenthesis>;
12+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
13+
StyleCop.Analyzers.MaintainabilityRules.SA1119StatementMustNotUseUnnecessaryParenthesis,
14+
StyleCop.Analyzers.MaintainabilityRules.SA1119CodeFixProvider>;
1315

1416
public class SA1119CSharp7UnitTests : SA1119UnitTests
1517
{

StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1119UnitTests.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ namespace StyleCop.Analyzers.Test.MaintainabilityRules
77
using System.Threading.Tasks;
88
using Microsoft.CodeAnalysis.Testing;
99
using StyleCop.Analyzers.MaintainabilityRules;
10-
using StyleCop.Analyzers.Test.Verifiers;
1110
using Xunit;
12-
using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier<StyleCop.Analyzers.MaintainabilityRules.SA1119StatementMustNotUseUnnecessaryParenthesis>;
11+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
12+
StyleCop.Analyzers.MaintainabilityRules.SA1119StatementMustNotUseUnnecessaryParenthesis,
13+
StyleCop.Analyzers.MaintainabilityRules.SA1119CodeFixProvider>;
1314

1415
public class SA1119UnitTests
1516
{
@@ -1436,20 +1437,5 @@ public static void Main(string[] args)
14361437

14371438
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
14381439
}
1439-
1440-
protected static async Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken)
1441-
{
1442-
var test = new StyleCopCodeFixVerifier<SA1119StatementMustNotUseUnnecessaryParenthesis, SA1119CodeFixProvider>.CSharpTest
1443-
{
1444-
TestCode = source,
1445-
FixedCode = fixedSource,
1446-
};
1447-
1448-
// Workaround for https://github.com/dotnet/roslyn-sdk/pull/252
1449-
test.Exclusions &= ~AnalysisExclusions.Suppression;
1450-
1451-
test.ExpectedDiagnostics.AddRange(expected);
1452-
await test.RunAsync(cancellationToken).ConfigureAwait(false);
1453-
}
14541440
}
14551441
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1412UnitTests.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ public async Task TestFileWithWrongEncodingAsync(int codepage)
4646
FixedSources = { fixedCode },
4747
};
4848

49-
// Workaround for https://github.com/dotnet/roslyn-sdk/pull/251
50-
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInherit;
51-
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInherit;
52-
5349
test.Exclusions &= ~AnalysisExclusions.Suppression;
5450
await test.RunAsync(CancellationToken.None).ConfigureAwait(false);
5551
}
@@ -69,10 +65,6 @@ public async Task TestFileWithUtf8EncodingWithoutBOMAsync()
6965
FixedSources = { fixedCode },
7066
};
7167

72-
// Workaround for https://github.com/dotnet/roslyn-sdk/pull/251
73-
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInherit;
74-
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInherit;
75-
7668
test.Exclusions &= ~AnalysisExclusions.Suppression;
7769
await test.RunAsync(CancellationToken.None).ConfigureAwait(false);
7870
}
@@ -112,10 +104,6 @@ public async Task TestFixAllWithMultipleEncodingsAsync()
112104
NumberOfFixAllInDocumentIterations = 3,
113105
};
114106

115-
// Workaround for https://github.com/dotnet/roslyn-sdk/pull/251
116-
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInherit;
117-
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInherit;
118-
119107
test.Exclusions &= ~AnalysisExclusions.Suppression;
120108
await test.RunAsync(CancellationToken.None).ConfigureAwait(false);
121109
}
@@ -143,10 +131,6 @@ private async Task TestFixAllExecuterAsync(int codepage, FixAllScope scope)
143131
NumberOfFixAllInDocumentIterations = 2,
144132
};
145133

146-
// Workaround for https://github.com/dotnet/roslyn-sdk/pull/251
147-
test.FixedState.InheritanceMode = StateInheritanceMode.AutoInherit;
148-
test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInherit;
149-
150134
test.Exclusions &= ~AnalysisExclusions.Suppression;
151135
await test.RunAsync(CancellationToken.None).ConfigureAwait(false);
152136
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<ItemGroup>
2020
<PackageReference Include="Microsoft.CodeAnalysis" Version="1.2.1" />
21-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.0.0-beta1-63810-01" />
21+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.0.0-beta1-63812-02" />
2222
<PackageReference Include="Microsoft.VisualStudio.Composition" Version="15.6.36" />
2323
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
2424
<PackageReference Include="xunit" Version="2.3.1" />

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/DiagnosticVerifierTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void MethodName()
4141
{
4242
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
4343
}).ConfigureAwait(false);
44-
Assert.StartsWith("Mismatch between number of diagnostics returned, expected \"1\" actual \"0\"", ex.Message);
44+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"1\" actual \"0\"", ex.Message);
4545
}
4646

4747
[Fact]
@@ -104,7 +104,7 @@ int PropertyName
104104
{
105105
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
106106
}).ConfigureAwait(false);
107-
Assert.StartsWith("Expected:\nA project diagnostic with No location\nActual:\n", ex.Message);
107+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected:\nA project diagnostic with No location\nActual:\n", ex.Message);
108108
}
109109

110110
[Fact]
@@ -126,7 +126,7 @@ int PropertyName
126126
{
127127
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
128128
}).ConfigureAwait(false);
129-
Assert.StartsWith("Mismatch between number of diagnostics returned, expected \"0\" actual \"1\"", ex.Message);
129+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"0\" actual \"1\"", ex.Message);
130130
Assert.Contains("warning SA1002", ex.Message);
131131
}
132132

@@ -148,7 +148,7 @@ void MethodName()
148148
{
149149
await CSharpCodeFixVerifier<ErrorThrowingAnalyzer, EmptyCodeFixProvider, XUnitVerifier>.VerifyAnalyzerAsync(testCode, DiagnosticResult.EmptyDiagnosticResults).ConfigureAwait(false);
150150
}).ConfigureAwait(false);
151-
Assert.StartsWith("Mismatch between number of diagnostics returned, expected \"0\" actual \"2\"", ex.Message);
151+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"0\" actual \"2\"", ex.Message);
152152
Assert.Contains("error AD0001", ex.Message);
153153
}
154154

@@ -173,7 +173,7 @@ Int32 PropertyName
173173
{
174174
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
175175
}).ConfigureAwait(false);
176-
Assert.StartsWith("Mismatch between number of diagnostics returned, expected \"1\" actual \"2\"", ex.Message);
176+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"1\" actual \"2\"", ex.Message);
177177
Assert.Contains("error CS0246", ex.Message);
178178
}
179179

@@ -199,7 +199,7 @@ Int32 PropertyName
199199
{
200200
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
201201
}).ConfigureAwait(false);
202-
Assert.StartsWith("Mismatch between number of diagnostics returned, expected \"1\" actual \"2\"", ex.Message);
202+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"1\" actual \"2\"", ex.Message);
203203
Assert.Contains("error CS0246", ex.Message);
204204
}
205205

@@ -225,7 +225,7 @@ int PropertyName
225225
{
226226
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
227227
}).ConfigureAwait(false);
228-
Assert.StartsWith("Expected diagnostic id to be \"SA9999\" was \"SA1002\"", ex.Message);
228+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic id to be \"SA9999\" was \"SA1002\"", ex.Message);
229229
}
230230

231231
[Fact]
@@ -249,7 +249,7 @@ int PropertyName
249249
{
250250
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
251251
}).ConfigureAwait(false);
252-
Assert.StartsWith("Expected diagnostic severity to be \"Error\" was \"Warning\"", ex.Message);
252+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic severity to be \"Error\" was \"Warning\"", ex.Message);
253253
}
254254

255255
[Fact]
@@ -273,7 +273,7 @@ int PropertyName
273273
{
274274
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
275275
}).ConfigureAwait(false);
276-
Assert.StartsWith("Expected diagnostic to start on line \"8\" was actually on line \"7\"", ex.Message);
276+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic to start on line \"8\" was actually on line \"7\"", ex.Message);
277277
}
278278

279279
[Fact]
@@ -302,7 +302,7 @@ int PropertyName
302302
{
303303
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
304304
}).ConfigureAwait(false);
305-
Assert.StartsWith("Expected diagnostic to start on line \"7\" was actually on line \"8\"", ex.Message);
305+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic to start on line \"7\" was actually on line \"8\"", ex.Message);
306306
}
307307

308308
[Fact]
@@ -326,7 +326,7 @@ int PropertyName
326326
{
327327
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
328328
}).ConfigureAwait(false);
329-
Assert.StartsWith("Expected diagnostic to start at column \"34\" was actually at column \"33\"", ex.Message);
329+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic to start at column \"34\" was actually at column \"33\"", ex.Message);
330330
}
331331

332332
[Fact]
@@ -350,7 +350,7 @@ int PropertyName
350350
{
351351
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
352352
}).ConfigureAwait(false);
353-
Assert.StartsWith("Expected diagnostic to end at column \"35\" was actually at column \"34\"", ex.Message);
353+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic to end at column \"35\" was actually at column \"34\"", ex.Message);
354354
}
355355

356356
[Fact]
@@ -374,7 +374,7 @@ int PropertyName
374374
{
375375
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
376376
}).ConfigureAwait(false);
377-
Assert.StartsWith("Expected diagnostic message to be ", ex.Message);
377+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic message to be ", ex.Message);
378378
}
379379

380380
[Fact]
@@ -398,7 +398,7 @@ int PropertyName
398398
{
399399
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
400400
}).ConfigureAwait(false);
401-
Assert.StartsWith("Expected 1 additional locations but got 0 for Diagnostic", ex.Message);
401+
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected 1 additional locations but got 0 for Diagnostic", ex.Message);
402402
}
403403

404404
private class ErrorThrowingAnalyzer : SA1002SemicolonsMustBeSpacedCorrectly

0 commit comments

Comments
 (0)