Skip to content

Commit 67504a0

Browse files
committed
Added tests to improve coverage in SA1015 (ClosingGenericBracketsMustBeSpacedCorrectly)
1 parent 26fe7ca commit 67504a0

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1015UnitTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace StyleCop.Analyzers.Test.SpacingRules
66
using System.Collections.Generic;
77
using System.Threading;
88
using System.Threading.Tasks;
9+
using Microsoft.CodeAnalysis;
910
using Microsoft.CodeAnalysis.CodeFixes;
1011
using Microsoft.CodeAnalysis.Diagnostics;
1112
using StyleCop.Analyzers.SpacingRules;
@@ -34,6 +35,8 @@ public class TestClass<T> where T : IEnumerable<object>
3435
public void TestMethod<TModel>() {
3536
var x = typeof(Action<,,>);
3637
TestMethod<TModel>();
38+
TestMethod<TModel
39+
>();
3740
}
3841
}
3942
";
@@ -365,6 +368,34 @@ public void TestMethod()
365368
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
366369
}
367370

371+
[Fact]
372+
public async Task TestMissingTokenAsync()
373+
{
374+
string testCode = @"
375+
using System;
376+
class ClassName
377+
{
378+
void Method()
379+
{
380+
Type x = typeof(Action<int);
381+
}
382+
}
383+
";
384+
385+
DiagnosticResult[] expected =
386+
{
387+
new DiagnosticResult
388+
{
389+
Id = "CS1003",
390+
Severity = DiagnosticSeverity.Error,
391+
Message = "Syntax error, '>' expected",
392+
Locations = new[] { new DiagnosticResultLocation("Test0.cs", 7, 35) }
393+
}
394+
};
395+
396+
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
397+
}
398+
368399
/// <inheritdoc/>
369400
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
370401
{

0 commit comments

Comments
 (0)