@@ -10,6 +10,10 @@ namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules
1010 using StyleCop . Analyzers . Test . CSharp8 . SpacingRules ;
1111 using Xunit ;
1212
13+ using static StyleCop . Analyzers . Test . Verifiers . StyleCopCodeFixVerifier <
14+ StyleCop . Analyzers . SpacingRules . SA1000KeywordsMustBeSpacedCorrectly ,
15+ StyleCop . Analyzers . SpacingRules . TokenSpacingCodeFixProvider > ;
16+
1317 public class SA1000CSharp9UnitTests : SA1000CSharp8UnitTests
1418 {
1519 [ Fact ]
@@ -19,5 +23,49 @@ public async Task TestTargetTypedNewAsync()
1923
2024 await this . TestKeywordStatementAsync ( statementWithoutSpace , DiagnosticResult . EmptyDiagnosticResults , statementWithoutSpace ) . ConfigureAwait ( false ) ;
2125 }
26+
27+ [ Fact ]
28+ [ WorkItem ( 3508 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3508" ) ]
29+ public async Task TestIsBeforeRelationalPatternAsync ( )
30+ {
31+ var statementWithoutSpace = "_ = 1 {|#0:is|}>1;" ;
32+ var statementWithSpace = "_ = 1 is >1;" ;
33+
34+ var expected = Diagnostic ( ) . WithArguments ( "is" , string . Empty , "followed" ) . WithLocation ( 0 ) ;
35+ await this . TestKeywordStatementAsync ( statementWithoutSpace , expected , statementWithSpace ) . ConfigureAwait ( false ) ;
36+ }
37+
38+ [ Fact ]
39+ [ WorkItem ( 3508 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3508" ) ]
40+ public async Task TestNotBeforeRelationalPatternAsync ( )
41+ {
42+ var statementWithoutSpace = "_ = 1 is {|#0:not|}>1;" ;
43+ var statementWithSpace = "_ = 1 is not >1;" ;
44+
45+ var expected = Diagnostic ( ) . WithArguments ( "not" , string . Empty , "followed" ) . WithLocation ( 0 ) ;
46+ await this . TestKeywordStatementAsync ( statementWithoutSpace , expected , statementWithSpace ) . ConfigureAwait ( false ) ;
47+ }
48+
49+ [ Fact ]
50+ [ WorkItem ( 3508 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3508" ) ]
51+ public async Task TestAndBeforeRelationalPatternAsync ( )
52+ {
53+ var statementWithoutSpace = "_ = 1 is 1 {|#0:and|}>0;" ;
54+ var statementWithSpace = "_ = 1 is 1 and >0;" ;
55+
56+ var expected = Diagnostic ( ) . WithArguments ( "and" , string . Empty , "followed" ) . WithLocation ( 0 ) ;
57+ await this . TestKeywordStatementAsync ( statementWithoutSpace , expected , statementWithSpace ) . ConfigureAwait ( false ) ;
58+ }
59+
60+ [ Fact ]
61+ [ WorkItem ( 3508 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3508" ) ]
62+ public async Task TestOrBeforeRelationalPatternAsync ( )
63+ {
64+ var statementWithoutSpace = "_ = 1 is 1 {|#0:or|}>1;" ;
65+ var statementWithSpace = "_ = 1 is 1 or >1;" ;
66+
67+ var expected = Diagnostic ( ) . WithArguments ( "or" , string . Empty , "followed" ) . WithLocation ( 0 ) ;
68+ await this . TestKeywordStatementAsync ( statementWithoutSpace , expected , statementWithSpace ) . ConfigureAwait ( false ) ;
69+ }
2270 }
2371}
0 commit comments