@@ -11,7 +11,7 @@ public class StringTests
11
11
[ AssertionDiagnostic ( "actual.StartsWith(expected).Should().BeTrue({0});" ) ]
12
12
[ AssertionDiagnostic ( "actual.ToString().StartsWith(expected).Should().BeTrue({0}).And.ToString();" ) ]
13
13
[ Implemented ]
14
- public void StringShouldStartWith_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldStartWithAnalyzer > ( assertion ) ;
14
+ public void StringShouldStartWith_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldStartWith_StartsWithShouldBeTrue ) ;
15
15
16
16
[ DataTestMethod ]
17
17
[ AssertionCodeFix (
@@ -21,13 +21,13 @@ public class StringTests
21
21
oldAssertion : "actual.ToString().StartsWith(expected).Should().BeTrue({0}).And.ToString();" ,
22
22
newAssertion : "actual.ToString().Should().StartWith(expected{0}).And.ToString();" ) ]
23
23
[ 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 ) ;
25
25
26
26
[ DataTestMethod ]
27
27
[ AssertionDiagnostic ( "actual.EndsWith(expected).Should().BeTrue({0});" ) ]
28
28
[ AssertionDiagnostic ( "actual.ToString().EndsWith(expected).Should().BeTrue({0}).And.ToString();" ) ]
29
29
[ Implemented ]
30
- public void StringShouldEndWith_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldEndWithAnalyzer > ( assertion ) ;
30
+ public void StringShouldEndWith_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldEndWith_EndsWithShouldBeTrue ) ;
31
31
32
32
[ DataTestMethod ]
33
33
[ AssertionCodeFix (
@@ -37,18 +37,29 @@ public class StringTests
37
37
oldAssertion : "actual.ToString().EndsWith(expected).Should().BeTrue({0}).And.ToString();" ,
38
38
newAssertion : "actual.ToString().Should().EndWith(expected{0}).And.ToString();" ) ]
39
39
[ 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 ) ;
41
55
42
56
[ DataTestMethod ]
43
57
[ AssertionDiagnostic ( "actual.Should().NotBeNull().And.NotBeEmpty({0});" ) ]
44
58
[ AssertionDiagnostic ( "actual.Should().NotBeNull({0}).And.NotBeEmpty();" ) ]
45
- [ AssertionDiagnostic ( "string.IsNullOrEmpty(actual).Should().BeFalse({0});" ) ]
46
59
[ AssertionDiagnostic ( "actual.ToString().Should().NotBeNull().And.NotBeEmpty({0}).And.ToString();" ) ]
47
60
[ 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();" ) ]
50
61
[ Implemented ]
51
- public void StringShouldNotBeNullOrEmpty_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldNotBeNullOrEmptyAnalyzer > ( assertion ) ;
62
+ public void StringShouldNotBeNullOrEmpty_StringShouldNotBeNullAndNotBeEmpty_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldNotBeNullOrEmpty_StringShouldNotBeNullAndNotBeEmpty ) ;
52
63
53
64
[ DataTestMethod ]
54
65
[ AssertionCodeFix (
@@ -82,13 +93,13 @@ public class StringTests
82
93
oldAssertion : "string.IsNullOrEmpty(actual.ToString()).Should().BeFalse({0}).And.ToString();" ,
83
94
newAssertion : "actual.ToString().Should().NotBeNullOrEmpty({0}).And.ToString();" ) ]
84
95
[ 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 ) ;
86
97
87
98
[ DataTestMethod ]
88
99
[ AssertionDiagnostic ( "string.IsNullOrEmpty(actual).Should().BeTrue({0});" ) ]
89
100
[ AssertionDiagnostic ( "string.IsNullOrEmpty(actual.ToString()).Should().BeTrue({0}).And.ToString();" ) ]
90
101
[ Implemented ]
91
- public void StringShouldBeNullOrEmpty_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldBeNullOrEmptyAnalyzer > ( assertion ) ;
102
+ public void StringShouldBeNullOrEmpty_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldBeNullOrEmpty_StringIsNullOrEmptyShouldBeTrue ) ;
92
103
93
104
[ DataTestMethod ]
94
105
[ AssertionCodeFix (
@@ -98,15 +109,15 @@ public class StringTests
98
109
oldAssertion : "string.IsNullOrEmpty(actual.ToString()).Should().BeTrue({0}).And.ToString();" ,
99
110
newAssertion : "actual.ToString().Should().BeNullOrEmpty({0}).And.ToString();" ) ]
100
111
[ 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 ) ;
102
113
103
114
[ DataTestMethod ]
104
115
[ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual).Should().BeTrue({0});" ) ]
105
116
[ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual).Should().BeTrue({0}).And.ToString();" ) ]
106
117
[ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeTrue({0});" ) ]
107
118
[ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeTrue({0}).And.ToString();" ) ]
108
119
[ Implemented ]
109
- public void StringShouldBeNullOrWhiteSpace_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldBeNullOrWhiteSpaceAnalyzer > ( assertion ) ;
120
+ public void StringShouldBeNullOrWhiteSpace_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldBeNullOrWhiteSpace_StringIsNullOrWhiteSpaceShouldBeTrue ) ;
110
121
111
122
[ DataTestMethod ]
112
123
[ AssertionCodeFix (
@@ -122,15 +133,15 @@ public class StringTests
122
133
oldAssertion : "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeTrue({0}).And.ToString();" ,
123
134
newAssertion : "actual.ToString().Should().BeNullOrWhiteSpace({0}).And.ToString();" ) ]
124
135
[ 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 ) ;
126
137
127
138
[ DataTestMethod ]
128
139
[ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual).Should().BeFalse({0});" ) ]
129
140
[ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual).Should().BeFalse({0}).And.ToString();" ) ]
130
141
[ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeFalse({0});" ) ]
131
142
[ AssertionDiagnostic ( "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeFalse({0}).And.ToString();" ) ]
132
143
[ Implemented ]
133
- public void StringShouldNotBeNullOrWhiteSpace_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldNotBeNullOrWhiteSpaceAnalyzer > ( assertion ) ;
144
+ public void StringShouldNotBeNullOrWhiteSpace_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldNotBeNullOrWhiteSpace_StringShouldNotBeNullOrWhiteSpace ) ;
134
145
135
146
[ DataTestMethod ]
136
147
[ AssertionCodeFix (
@@ -146,13 +157,13 @@ public class StringTests
146
157
oldAssertion : "string.IsNullOrWhiteSpace(actual.ToString()).Should().BeFalse({0}).And.ToString();" ,
147
158
newAssertion : "actual.ToString().Should().NotBeNullOrWhiteSpace({0}).And.ToString();" ) ]
148
159
[ 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 ) ;
150
161
151
162
[ DataTestMethod ]
152
163
[ AssertionDiagnostic ( "actual.Length.Should().Be(k{0});" ) ]
153
164
[ AssertionDiagnostic ( "actual.ToString().Length.Should().Be(k{0}).And.ToString();" ) ]
154
165
[ Implemented ]
155
- public void StringShouldHaveLength_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic < StringShouldHaveLengthAnalyzer > ( assertion ) ;
166
+ public void StringShouldHaveLength_TestAnalyzer ( string assertion ) => VerifyCSharpDiagnostic ( assertion , DiagnosticMetadata . StringShouldHaveLength_LengthShouldBe ) ;
156
167
157
168
[ DataTestMethod ]
158
169
[ AssertionCodeFix (
@@ -162,20 +173,17 @@ public class StringTests
162
173
oldAssertion : "actual.ToString().Length.Should().Be(k{0}).And.ToString();" ,
163
174
newAssertion : "actual.ToString().Should().HaveLength(k{0}).And.ToString();" ) ]
164
175
[ 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 ) ;
166
177
167
- private void VerifyCSharpDiagnostic < TDiagnosticAnalyzer > ( string sourceAssertion ) where TDiagnosticAnalyzer : Microsoft . CodeAnalysis . Diagnostics . DiagnosticAnalyzer , new ( )
178
+ private void VerifyCSharpDiagnostic ( string sourceAssertion , DiagnosticMetadata metadata )
168
179
{
169
180
var source = GenerateCode . StringAssertion ( sourceAssertion ) ;
170
181
171
- var type = typeof ( TDiagnosticAnalyzer ) ;
172
- var diagnosticId = ( string ) type . GetField ( "DiagnosticId" ) . GetValue ( null ) ;
173
- var message = ( string ) type . GetField ( "Message" ) . GetValue ( null ) ;
174
-
175
182
DiagnosticVerifier . VerifyCSharpDiagnosticUsingAllAnalyzers ( source , new DiagnosticResult
176
183
{
177
- Id = diagnosticId ,
178
- Message = message ,
184
+ Id = FluentAssertionsOperationAnalyzer . DiagnosticId ,
185
+ Message = metadata . Message ,
186
+ VisitorName = metadata . Name ,
179
187
Locations = new DiagnosticResultLocation [ ]
180
188
{
181
189
new DiagnosticResultLocation ( "Test0.cs" , 9 , 13 )
0 commit comments