Skip to content

Commit 5754710

Browse files
committed
Fixed unit test to properly use the 'systemUsingDirectivesFirst' setting
1 parent af431f3 commit 5754710

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1217UnitTests.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ public class SA1217UnitTests
1919
{
2020
""settings"": {
2121
""orderingRules"": {
22-
""systemUsingDirectivesFirst"": ""true""
22+
""systemUsingDirectivesFirst"": true
23+
}
24+
}
25+
}
26+
";
27+
28+
private const string TestSettingsNoSystemDirectivesFirst = @"
29+
{
30+
""settings"": {
31+
""orderingRules"": {
32+
""systemUsingDirectivesFirst"": false
2333
}
2434
}
2535
}
@@ -203,8 +213,8 @@ public async Task TestInvalidUsingDirectivesWithGlobalPrefixAsync()
203213
public async Task TestPreprocessorDirectivesAsync()
204214
{
205215
var testCode = @"
206-
using System;
207216
using Microsoft.Win32;
217+
using System;
208218
using MyList = System.Collections.Generic.List<int>;
209219
using static System.Tuple;
210220
@@ -217,8 +227,8 @@ public async Task TestPreprocessorDirectivesAsync()
217227
#endif";
218228

219229
var fixedTestCode = @"
220-
using System;
221230
using Microsoft.Win32;
231+
using System;
222232
using static System.Tuple;
223233
using MyList = System.Collections.Generic.List<int>;
224234
@@ -295,7 +305,7 @@ private Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expec
295305
var test = new StyleCopCodeFixVerifier<SA1217UsingStaticDirectivesMustBeOrderedAlphabetically, UsingCodeFixProvider>.CSharpTest
296306
{
297307
TestCode = source,
298-
Settings = this.useSystemUsingDirectivesFirst ? TestSettings : null,
308+
Settings = this.useSystemUsingDirectivesFirst ? TestSettings : TestSettingsNoSystemDirectivesFirst,
299309
};
300310

301311
test.ExpectedDiagnostics.AddRange(expected);
@@ -308,7 +318,7 @@ private Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, st
308318
{
309319
TestCode = source,
310320
FixedCode = fixedSource,
311-
Settings = this.useSystemUsingDirectivesFirst ? TestSettings : null,
321+
Settings = this.useSystemUsingDirectivesFirst ? TestSettings : TestSettingsNoSystemDirectivesFirst,
312322
};
313323

314324
test.ExpectedDiagnostics.AddRange(expected);

0 commit comments

Comments
 (0)