-
Notifications
You must be signed in to change notification settings - Fork 509
Expand file tree
/
Copy pathSA1137CSharp12UnitTests.cs
More file actions
63 lines (60 loc) · 2.41 KB
/
SA1137CSharp12UnitTests.cs
File metadata and controls
63 lines (60 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules;
using Xunit;
using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier<
StyleCop.Analyzers.ReadabilityRules.SA1137ElementsShouldHaveTheSameIndentation>;
public partial class SA1137CSharp12UnitTests : SA1137CSharp11UnitTests
{
[Fact]
[WorkItem(3904, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3904")]
public async Task TestCollectionInitializationAsync()
{
var csharp = new CSharpTest()
{
TestSources =
{
@"
class FirstCase
{
private readonly System.Collections.Generic.List<string> example1 =
[
""a"",
""b"",
""c"",
];
}",
@"
class SecondCase
{
private readonly System.Collections.Generic.List<int> example2 =
[
1,
2,
3,
4,
];
}",
@"
class ThirdCase
{
private readonly System.Collections.Generic.List<int> example3 = [1, 2, 3, 4];
}",
},
ExpectedDiagnostics =
{
DiagnosticResult.CompilerWarning("SA1137").WithLocation("/0/Test0.cs", 7, 1),
DiagnosticResult.CompilerWarning("SA1137").WithLocation("/0/Test0.cs", 8, 1),
DiagnosticResult.CompilerWarning("SA1137").WithLocation("/0/Test1.cs", 8, 1),
DiagnosticResult.CompilerWarning("SA1137").WithLocation("/0/Test1.cs", 9, 1),
},
};
await csharp.RunAsync(CancellationToken.None).ConfigureAwait(false);
}
}
}