Skip to content

Commit d1ef224

Browse files
Updated tests for SA1402 to not contain any blank lines between declarations. Tests for enum and delegate had them, but not tests for class, interface and struct.
1 parent 15cd12e commit d1ef224

2 files changed

Lines changed: 16 additions & 53 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForDelegateUnitTests.cs

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,18 @@ public async Task TestOneElementAsync()
2424
public async Task TestTwoElementsAsync()
2525
{
2626
var testCode = @"public delegate void Foo();
27-
2827
public delegate void Bar();
2928
";
3029

3130
var fixedCode = new[]
3231
{
3332
@"public delegate void Foo();
3433
",
35-
36-
// There should be no leading whitespace here... Why are there?
37-
@"
38-
public delegate void Bar();
34+
@"public delegate void Bar();
3935
"
4036
};
4137

42-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(3, 22);
38+
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(2, 22);
4339

4440
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
4541
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
@@ -50,22 +46,18 @@ public async Task TestTwoElementsAsync()
5046
public async Task TestTwoGenericElementsAsync()
5147
{
5248
var testCode = @"public delegate void Foo();
53-
5449
public delegate void Bar<T1, T2, T3>(T1 x, T2 y, T3 z);
5550
";
5651

5752
var fixedCode = new[]
5853
{
5954
@"public delegate void Foo();
6055
",
61-
62-
// There should be no leading whitespace here... Why are there?
63-
@"
64-
public delegate void Bar<T1, T2, T3>(T1 x, T2 y, T3 z);
56+
@"public delegate void Bar<T1, T2, T3>(T1 x, T2 y, T3 z);
6557
"
6658
};
6759

68-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(3, 22);
60+
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(2, 22);
6961

7062
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
7163
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
@@ -78,7 +70,6 @@ public async Task TestTwoElementsWithRuleDisabledAsync()
7870
this.ConfigureAsNonTopLevelType = true;
7971

8072
var testCode = @"public delegate void Foo();
81-
8273
public delegate void Bar();
8374
";
8475

@@ -89,32 +80,24 @@ public async Task TestTwoElementsWithRuleDisabledAsync()
8980
public async Task TestThreeElementsAsync()
9081
{
9182
var testCode = @"public delegate void Foo();
92-
9383
public delegate void Bar();
94-
9584
public delegate void FooBar();
9685
";
9786

9887
var fixedCode = new[]
9988
{
10089
@"public delegate void Foo();
10190
",
102-
103-
// There should be no leading whitespace here... Why are there?
104-
@"
105-
public delegate void Bar();
91+
@"public delegate void Bar();
10692
",
107-
108-
// There should be no leading whitespace here... Why are there?
109-
@"
110-
public delegate void FooBar();
93+
@"public delegate void FooBar();
11194
"
11295
};
11396

11497
DiagnosticResult[] expected =
11598
{
116-
this.CSharpDiagnostic().WithLocation(3, 22),
117-
this.CSharpDiagnostic().WithLocation(5, 22)
99+
this.CSharpDiagnostic().WithLocation(2, 22),
100+
this.CSharpDiagnostic().WithLocation(3, 22)
118101
};
119102

120103
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -126,17 +109,13 @@ public async Task TestThreeElementsAsync()
126109
public async Task TestPreferFilenameTypeAsync()
127110
{
128111
var testCode = @"public delegate void Foo();
129-
130112
public delegate void Test0();
131113
";
132114

133115
var fixedCode = new[]
134116
{
135-
// There should be no leading whitespace here... Why are there?
136-
$@"
137-
public delegate void Test0();
117+
$@"public delegate void Test0();
138118
",
139-
140119
$@"public delegate void Foo();
141120
"
142121
};

StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForEnumUnitTests.cs

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public async Task TestTwoElementsAsync()
3131
{
3232
A, B, C
3333
}
34-
3534
enum Bar
3635
{
3736
D, E
@@ -45,17 +44,14 @@ enum Bar
4544
A, B, C
4645
}
4746
",
48-
49-
// There should be no leading whitespace here... Why are there?
50-
@"
51-
enum Bar
47+
@"enum Bar
5248
{
5349
D, E
5450
}
5551
"
5652
};
5753

58-
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(6, 6);
54+
DiagnosticResult expected = this.CSharpDiagnostic().WithLocation(5, 6);
5955

6056
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
6157
await this.VerifyCSharpDiagnosticAsync(fixedCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
@@ -71,7 +67,6 @@ public async Task TestTwoElementsWithRuleDisabledAsync()
7167
{
7268
A, B, C
7369
}
74-
7570
enum Bar
7671
{
7772
D, E
@@ -88,12 +83,10 @@ public async Task TestThreeElementsAsync()
8883
{
8984
A, B, C
9085
}
91-
9286
enum Bar
9387
{
9488
D, E
9589
}
96-
9790
enum FooBar
9891
{
9992
F, G, H
@@ -107,18 +100,12 @@ enum FooBar
107100
A, B, C
108101
}
109102
",
110-
111-
// There should be no leading whitespace here... Why are there?
112-
@"
113-
enum Bar
103+
@"enum Bar
114104
{
115105
D, E
116106
}
117107
",
118-
119-
// There should be no leading whitespace here... Why are there?
120-
@"
121-
enum FooBar
108+
@"enum FooBar
122109
{
123110
F, G, H
124111
}
@@ -127,8 +114,8 @@ enum FooBar
127114

128115
DiagnosticResult[] expected =
129116
{
130-
this.CSharpDiagnostic().WithLocation(6, 6),
131-
this.CSharpDiagnostic().WithLocation(11, 6)
117+
this.CSharpDiagnostic().WithLocation(5, 6),
118+
this.CSharpDiagnostic().WithLocation(9, 6)
132119
};
133120

134121
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -143,7 +130,6 @@ public async Task TestPreferFilenameTypeAsync()
143130
{
144131
A, B, C
145132
}
146-
147133
enum Test0
148134
{
149135
D, E
@@ -152,9 +138,7 @@ enum Test0
152138

153139
var fixedCode = new[]
154140
{
155-
// There should be no leading whitespace here... Why are there?
156-
@"
157-
enum Test0
141+
@"enum Test0
158142
{
159143
D, E
160144
}

0 commit comments

Comments
 (0)