@@ -11,7 +11,7 @@ public class StringTests
1111 [ AssertionDiagnostic ( "actual.StartsWith(expected).Should().BeTrue({0});" ) ]
1212 [ AssertionDiagnostic ( "actual.ToString().StartsWith(expected).Should().BeTrue({0}).And.ToString();" ) ]
1313 [ Implemented ]
14- public void StringShouldStartWith_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldStartWithAnalyzer > ( assertion ) ;
14+ public void StringShouldStartWith_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldStartWith_StartsWithShouldBeTrue ) ;
1515
1616 [ DataTestMethod ]
1717 [ AssertionCodeFix (
@@ -21,13 +21,13 @@ public class StringTests
2121 oldAssertion : "actual.ToString().StartsWith(expected).Should().BeTrue({0}).And.ToString();" ,
2222 newAssertion : "actual.ToString().Should().StartWith(expected{0}).And.ToString();" ) ]
2323 [ Implemented ]
24- public void StringShouldStartWith_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < StringShouldStartWithCodeFix , StringShouldStartWithAnalyzer > ( oldAssertion , newAssertion ) ;
24+ public void StringShouldStartWith_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
2525
2626 [ DataTestMethod ]
2727 [ AssertionDiagnostic ( "actual.EndsWith(expected).Should().BeTrue({0});" ) ]
2828 [ AssertionDiagnostic ( "actual.ToString().EndsWith(expected).Should().BeTrue({0}).And.ToString();" ) ]
2929 [ Implemented ]
30- public void StringShouldEndWith_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldEndWithAnalyzer > ( assertion ) ;
30+ public void StringShouldEndWith_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldEndWith_EndsWithShouldBeTrue ) ;
3131
3232 [ DataTestMethod ]
3333 [ AssertionCodeFix (
@@ -37,18 +37,29 @@ public class StringTests
3737 oldAssertion : "actual.ToString().EndsWith(expected).Should().BeTrue({0}).And.ToString();" ,
3838 newAssertion : "actual.ToString().Should().EndWith(expected{0}).And.ToString();" ) ]
3939 [ Implemented ]
40- public void StringShouldEndWith_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < StringShouldEndWithCodeFix , StringShouldEndWithAnalyzer > ( oldAssertion , newAssertion ) ;
40+ public void StringShouldEndWith_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
41+
42+ [ DataTestMethod ]
43+ [ AssertionDiagnostic ( "string.IsNullOrEmpty(actual).Should().BeFalse({0});" ) ]
44+ [ AssertionDiagnostic ( "string.IsNullOrEmpty(actual.ToString()).Should().BeFalse({0}).And.ToString();" ) ]
45+ [ Implemented ]
46+ public void StringShouldNotBeNullOrEmpty_StringIsNullOrEmptyShouldBeFalse_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldNotBeNullOrEmpty_StringIsNullOrEmptyShouldBeFalse ) ;
47+
48+ [ DataTestMethod ]
49+ [ AssertionDiagnostic ( "actual.Should().NotBeEmpty().And.NotBeNull({0});" ) ]
50+ [ AssertionDiagnostic ( "actual.Should().NotBeEmpty({0}).And.NotBeNull();" ) ]
51+ [ AssertionDiagnostic ( "actual.ToString().Should().NotBeEmpty({0}).And.NotBeNull().And.ToString();" ) ]
52+ [ AssertionDiagnostic ( "actual.ToString().Should().NotBeEmpty().And.NotBeNull({0}).And.ToString();" ) ]
53+ [ Implemented ]
54+ public void StringShouldNotBeNullOrEmpty_StringShouldNotBeEmptyAndNotBeNull_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldNotBeNullOrEmpty_StringShouldNotBeEmptyAndNotBeNull ) ;
4155
4256 [ DataTestMethod ]
4357 [ AssertionDiagnostic ( "actual.Should().NotBeNull().And.NotBeEmpty({0});" ) ]
4458 [ AssertionDiagnostic ( "actual.Should().NotBeNull({0}).And.NotBeEmpty();" ) ]
45- [ AssertionDiagnostic ( "string.IsNullOrEmpty(actual).Should().BeFalse({0});" ) ]
4659 [ AssertionDiagnostic ( "actual.ToString().Should().NotBeNull().And.NotBeEmpty({0}).And.ToString();" ) ]
4760 [ AssertionDiagnostic ( "actual.ToString().Should().NotBeNull({0}).And.NotBeEmpty().And.ToString();" ) ]
48- [ AssertionDiagnostic ( "actual.ToString().Should().NotBeEmpty({0}).And.NotBeNull({0}).And.ToString();" ) ]
49- [ AssertionDiagnostic ( "string.IsNullOrEmpty(actual.ToString()).Should().BeFalse({0}).And.ToString();" ) ]
5061 [ Implemented ]
51- public void StringShouldNotBeNullOrEmpty_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldNotBeNullOrEmptyAnalyzer > ( assertion ) ;
62+ public void StringShouldNotBeNullOrEmpty_StringShouldNotBeNullAndNotBeEmpty_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldNotBeNullOrEmpty_StringShouldNotBeNullAndNotBeEmpty ) ;
5263
5364 [ DataTestMethod ]
5465 [ AssertionCodeFix (
@@ -82,13 +93,13 @@ public class StringTests
8293 oldAssertion : "string.IsNullOrEmpty(actual.ToString()).Should().BeFalse({0}).And.ToString();" ,
8394 newAssertion : "actual.ToString().Should().NotBeNullOrEmpty({0}).And.ToString();" ) ]
8495 [ Implemented ]
85- public void StringShouldNotBeNullOrEmpty_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < StringShouldNotBeNullOrEmptyCodeFix , StringShouldNotBeNullOrEmptyAnalyzer > ( oldAssertion , newAssertion ) ;
96+ public void StringShouldNotBeNullOrEmpty_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
8697
8798 [ DataTestMethod ]
8899 [ AssertionDiagnostic ( "string.IsNullOrEmpty(actual).Should().BeTrue({0});" ) ]
89100 [ AssertionDiagnostic ( "string.IsNullOrEmpty(actual.ToString()).Should().BeTrue({0}).And.ToString();" ) ]
90101 [ Implemented ]
91- public void StringShouldBeNullOrEmpty_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldBeNullOrEmptyAnalyzer > ( assertion ) ;
102+ public void StringShouldBeNullOrEmpty_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldBeNullOrEmpty_StringIsNullOrEmptyShouldBeTrue ) ;
92103
93104 [ DataTestMethod ]
94105 [ AssertionCodeFix (
@@ -98,15 +109,15 @@ public class StringTests
98109 oldAssertion : "string.IsNullOrEmpty(actual.ToString()).Should().BeTrue({0}).And.ToString();" ,
99110 newAssertion : "actual.ToString().Should().BeNullOrEmpty({0}).And.ToString();" ) ]
100111 [ Implemented ]
101- public void StringShouldBeNullOrEmpty_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < StringShouldBeNullOrEmptyCodeFix , StringShouldBeNullOrEmptyAnalyzer > ( oldAssertion , newAssertion ) ;
112+ public void StringShouldBeNullOrEmpty_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
102113
103114 [ DataTestMethod ]
104115 [ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual).Should().BeTrue({0});" ) ]
105116 [ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual).Should().BeTrue({0}).And.ToString();" ) ]
106117 [ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeTrue({0});" ) ]
107118 [ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeTrue({0}).And.ToString();" ) ]
108119 [ Implemented ]
109- public void StringShouldBeNullOrWhiteSpace_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldBeNullOrWhiteSpaceAnalyzer > ( assertion ) ;
120+ public void StringShouldBeNullOrWhiteSpace_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldBeNullOrWhiteSpace_StringIsNullOrWhiteSpaceShouldBeTrue ) ;
110121
111122 [ DataTestMethod ]
112123 [ AssertionCodeFix (
@@ -122,15 +133,15 @@ public class StringTests
122133 oldAssertion : "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeTrue({0}).And.ToString();" ,
123134 newAssertion : "actual.ToString().Should().BeNullOrWhiteSpace({0}).And.ToString();" ) ]
124135 [ Implemented ]
125- public void StringShouldBeNullOrWhiteSpace_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < StringShouldBeNullOrWhiteSpaceCodeFix , StringShouldBeNullOrWhiteSpaceAnalyzer > ( oldAssertion , newAssertion ) ;
136+ public void StringShouldBeNullOrWhiteSpace_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
126137
127138 [ DataTestMethod ]
128139 [ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual).Should().BeFalse({0});" ) ]
129140 [ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual).Should().BeFalse({0}).And.ToString();" ) ]
130141 [ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeFalse({0});" ) ]
131142 [ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeFalse({0}).And.ToString();" ) ]
132143 [ Implemented ]
133- public void StringShouldNotBeNullOrWhiteSpace_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldNotBeNullOrWhiteSpaceAnalyzer > ( assertion ) ;
144+ public void StringShouldNotBeNullOrWhiteSpace_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldNotBeNullOrWhiteSpace_StringShouldNotBeNullOrWhiteSpace ) ;
134145
135146 [ DataTestMethod ]
136147 [ AssertionCodeFix (
@@ -146,13 +157,13 @@ public class StringTests
146157 oldAssertion : "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeFalse({0}).And.ToString();" ,
147158 newAssertion : "actual.ToString().Should().NotBeNullOrWhiteSpace({0}).And.ToString();" ) ]
148159 [ Implemented ]
149- public void StringShouldNotBeNullOrWhiteSpace_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < StringShouldNotBeNullOrWhiteSpaceCodeFix , StringShouldNotBeNullOrWhiteSpaceAnalyzer > ( oldAssertion , newAssertion ) ;
160+ public void StringShouldNotBeNullOrWhiteSpace_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
150161
151162 [ DataTestMethod ]
152163 [ AssertionDiagnostic ( "actual.Length.Should().Be(k{0});" ) ]
153164 [ AssertionDiagnostic ( "actual.ToString().Length.Should().Be(k{0}).And.ToString();" ) ]
154165 [ Implemented ]
155- public void StringShouldHaveLength_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldHaveLengthAnalyzer > ( assertion ) ;
166+ public void StringShouldHaveLength_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldHaveLength_LengthShouldBe ) ;
156167
157168 [ DataTestMethod ]
158169 [ AssertionCodeFix (
@@ -162,20 +173,17 @@ public class StringTests
162173 oldAssertion : "actual.ToString().Length.Should().Be(k{0}).And.ToString();" ,
163174 newAssertion : "actual.ToString().Should().HaveLength(k{0}).And.ToString();" ) ]
164175 [ Implemented ]
165- public void StringShouldHaveLength_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < StringShouldHaveLengthCodeFix , StringShouldHaveLengthAnalyzer > ( oldAssertion , newAssertion ) ;
176+ public void StringShouldHaveLength_TestCodeFix ( string oldAssertion , string newAssertion ) => VerifyCSharpFix < FluentAssertionsCodeFix , FluentAssertionsOperationAnalyzer > ( oldAssertion , newAssertion ) ;
166177
167- private void VerifyCSharpDiagnostic < TDiagnosticAnalyzer > ( string sourceAssertion ) where TDiagnosticAnalyzer : Microsoft . CodeAnalysis . Diagnostics . DiagnosticAnalyzer , new ( )
178+ private void VerifyCSharpDiagnostic ( string sourceAssertion , DiagnosticMetadata metadata )
168179 {
169180 var source = GenerateCode . StringAssertion ( sourceAssertion ) ;
170181
171- var type = typeof ( TDiagnosticAnalyzer ) ;
172- var diagnosticId = ( string ) type . GetField ( "DiagnosticId" ) . GetValue ( null ) ;
173- var message = ( string ) type . GetField ( "Message" ) . GetValue ( null ) ;
174-
175182 DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
176183 {
177- Id = diagnosticId ,
178- Message = message ,
184+ Id = FluentAssertionsOperationAnalyzer . DiagnosticId ,
185+ Message = metadata . Message ,
186+ VisitorName = metadata . Name ,
179187 Locations = new DiagnosticResultLocation [ ]
180188 {
181189 new DiagnosticResultLocation ( "Test0.cs" , 9 , 13 )
0 commit comments