@@ -4,6 +4,13 @@ This is a generated file, please edit src\FluentAssertions.Analyzers.FluentAsser
4
4
5
5
# FluentAssertions Analyzer Docs
6
6
7
+ - [ StringShouldStartWith] ( #scenario-stringshouldstartwith ) - ` actual.Should().StartWith(expected); `
8
+ - [ StringShouldEndWith] ( #scenario-stringshouldendwith ) - ` actual.Should().EndWith(expected); `
9
+ - [ StringShouldNotBeNullOrEmpty] ( #scenario-stringshouldnotbenullorempty ) - ` actual.Should().NotBeNullOrEmpty(); `
10
+ - [ StringShouldBeNullOrEmpty] ( #scenario-stringshouldbenullorempty ) - ` actual.Should().BeNullOrEmpty(); `
11
+ - [ StringShouldBeNullOrWhiteSpace] ( #scenario-stringshouldbenullorwhitespace ) - ` actual.Should().BeNullOrWhiteSpace(); `
12
+ - [ StringShouldNotBeNullOrWhiteSpace] ( #scenario-stringshouldnotbenullorwhitespace ) - ` actual.Should().NotBeNullOrWhiteSpace(); `
13
+ - [ StringShouldHaveLength] ( #scenario-stringshouldhavelength ) - ` actual.Should().HaveLength(expected); `
7
14
- [ CollectionShouldNotBeEmpty] ( #scenario-collectionshouldnotbeempty ) - ` collection.Should().NotBeEmpty(); `
8
15
- [ CollectionShouldBeEmpty] ( #scenario-collectionshouldbeempty ) - ` collection.Should().BeEmpty(); `
9
16
- [ CollectionShouldNotContainCondition] ( #scenario-collectionshouldnotcontaincondition ) - ` collection.Should().NotContain(i => i == 4); `
@@ -44,6 +51,198 @@ This is a generated file, please edit src\FluentAssertions.Analyzers.FluentAsser
44
51
45
52
## Scenarios
46
53
54
+ ### scenario: StringShouldStartWith
55
+
56
+ ``` cs
57
+ // arrange
58
+ var actual = " actual" ;
59
+ var expected = " act" ;
60
+
61
+ // old assertion:
62
+ actual .StartsWith (expected ).Should ().BeTrue ();
63
+
64
+ // new assertion:
65
+ actual .Should ().StartWith (expected );
66
+ ```
67
+
68
+ #### Failure messages
69
+
70
+ ``` cs
71
+ // arrange
72
+ var actual = " actual" ;
73
+ var expected = " wrong" ;
74
+
75
+ // old assertion:
76
+ actual .StartsWith (expected ).Should ().BeTrue (); // fail message: Expected actual.StartsWith(expected) to be True, but found False.
77
+
78
+ // new assertion:
79
+ actual .Should ().StartWith (expected ); // fail message: Expected actual to start with "wrong", but "actual" differs near "act" (index 0).
80
+ ```
81
+
82
+ ### scenario: StringShouldEndWith
83
+
84
+ ``` cs
85
+ // arrange
86
+ var actual = " actual" ;
87
+ var expected = " ual" ;
88
+
89
+ // old assertion:
90
+ actual .EndsWith (expected ).Should ().BeTrue ();
91
+
92
+ // new assertion:
93
+ actual .Should ().EndWith (expected );
94
+ ```
95
+
96
+ #### Failure messages
97
+
98
+ ``` cs
99
+ // arrange
100
+ var actual = " actual" ;
101
+ var expected = " wrong" ;
102
+
103
+ // old assertion:
104
+ actual .EndsWith (expected ).Should ().BeTrue (); // fail message: Expected actual.EndsWith(expected) to be True, but found False.
105
+
106
+ // new assertion:
107
+ actual .Should ().EndWith (expected ); // fail message: Expected actual "actual" to end with "wrong".
108
+ ```
109
+
110
+ ### scenario: StringShouldNotBeNullOrEmpty
111
+
112
+ ``` cs
113
+ // arrange
114
+ var actual = " actual" ;
115
+
116
+ // old assertion:
117
+ string .IsNullOrEmpty (actual ).Should ().BeFalse ();
118
+ actual .Should ().NotBeNull ().And .NotBeEmpty ();
119
+ actual .Should ().NotBeEmpty ().And .NotBeNull ();
120
+
121
+ // new assertion:
122
+ actual .Should ().NotBeNullOrEmpty ();
123
+ ```
124
+
125
+ #### Failure messages
126
+
127
+ ``` cs
128
+ // arrange
129
+ var actual = string .Empty ;
130
+
131
+ // old assertion:
132
+ string .IsNullOrEmpty (actual ).Should ().BeFalse (); // fail message: Expected string.IsNullOrEmpty(actual) to be False, but found True.
133
+ actual .Should ().NotBeNull ().And .NotBeEmpty (); // fail message: Did not expect actual to be empty.
134
+ actual .Should ().NotBeEmpty ().And .NotBeNull (); // fail message: Did not expect actual to be empty.
135
+
136
+ // new assertion:
137
+ actual .Should ().NotBeNullOrEmpty (); // fail message: Expected actual not to be <null> or empty, but found "".
138
+ ```
139
+
140
+ ### scenario: StringShouldBeNullOrEmpty
141
+
142
+ ``` cs
143
+ // arrange
144
+ var actual = string .Empty ;
145
+
146
+ // old assertion:
147
+ string .IsNullOrEmpty (actual ).Should ().BeTrue ();
148
+
149
+ // new assertion:
150
+ actual .Should ().BeNullOrEmpty ();
151
+ ```
152
+
153
+ #### Failure messages
154
+
155
+ ``` cs
156
+ // arrange
157
+ var actual = " actual" ;
158
+
159
+ // old assertion:
160
+ string .IsNullOrEmpty (actual ).Should ().BeTrue (); // fail message: Expected string.IsNullOrEmpty(actual) to be True, but found False.
161
+
162
+ // new assertion:
163
+ actual .Should ().BeNullOrEmpty (); // fail message: Expected actual to be <null> or empty, but found "actual".
164
+ ```
165
+
166
+ ### scenario: StringShouldBeNullOrWhiteSpace
167
+
168
+ ``` cs
169
+ // arrange
170
+ var actual = string .Empty ;
171
+
172
+ // old assertion:
173
+ string .IsNullOrWhiteSpace (actual ).Should ().BeTrue ();
174
+
175
+ // new assertion:
176
+ actual .Should ().BeNullOrWhiteSpace ();
177
+ ```
178
+
179
+ #### Failure messages
180
+
181
+ ``` cs
182
+ // arrange
183
+ var actual = " actual" ;
184
+
185
+ // old assertion:
186
+ string .IsNullOrWhiteSpace (actual ).Should ().BeTrue (); // fail message: Expected string.IsNullOrWhiteSpace(actual) to be True, but found False.
187
+
188
+ // new assertion:
189
+ actual .Should ().BeNullOrWhiteSpace (); // fail message: Expected actual to be <null> or whitespace, but found "actual".
190
+ ```
191
+
192
+ ### scenario: StringShouldNotBeNullOrWhiteSpace
193
+
194
+ ``` cs
195
+ // arrange
196
+ var actual = " actual" ;
197
+
198
+ // old assertion:
199
+ string .IsNullOrWhiteSpace (actual ).Should ().BeFalse ();
200
+
201
+ // new assertion:
202
+ actual .Should ().NotBeNullOrWhiteSpace ();
203
+ ```
204
+
205
+ #### Failure messages
206
+
207
+ ``` cs
208
+ // arrange
209
+ var actual = string .Empty ;
210
+
211
+ // old assertion:
212
+ string .IsNullOrWhiteSpace (actual ).Should ().BeFalse (); // fail message: Expected string.IsNullOrWhiteSpace(actual) to be False, but found True.
213
+
214
+ // new assertion:
215
+ actual .Should ().NotBeNullOrWhiteSpace (); // fail message: Expected actual not to be <null> or whitespace, but found "".
216
+ ```
217
+
218
+ ### scenario: StringShouldHaveLength
219
+
220
+ ``` cs
221
+ // arrange
222
+ var actual = " actual" ;
223
+ var expected = 6 ;
224
+
225
+ // old assertion:
226
+ actual .Length .Should ().Be (expected );
227
+
228
+ // new assertion:
229
+ actual .Should ().HaveLength (expected );
230
+ ```
231
+
232
+ #### Failure messages
233
+
234
+ ``` cs
235
+ // arrange
236
+ var actual = " actual" ;
237
+ var expected = 5 ;
238
+
239
+ // old assertion:
240
+ actual .Length .Should ().Be (expected ); // fail message: Expected actual.Length to be 5, but found 6.
241
+
242
+ // new assertion:
243
+ actual .Should ().HaveLength (expected ); // fail message: Expected actual with length 5, but found string "actual" with length 6.
244
+ ```
245
+
47
246
### scenario: CollectionShouldNotBeEmpty
48
247
49
248
``` cs
@@ -64,7 +263,7 @@ collection.Should().NotBeEmpty();
64
263
var collection = new List <int > { };
65
264
66
265
// old assertion:
67
- collection .Any ().Should ().BeTrue (); // fail message: Expected collection.Any() to be true , but found False.
266
+ collection .Any ().Should ().BeTrue (); // fail message: Expected collection.Any() to be True , but found False.
68
267
69
268
// new assertion:
70
269
collection .Should ().NotBeEmpty (); // fail message: Expected collection not to be empty.
@@ -93,13 +292,13 @@ collection.Should().BeEmpty();
93
292
var collection = new List <int > { 1 , 2 , 3 };
94
293
95
294
// old assertion:
96
- collection .Any ().Should ().BeFalse (); // fail message: Expected collection.Any() to be false , but found True.
295
+ collection .Any ().Should ().BeFalse (); // fail message: Expected collection.Any() to be False , but found True.
97
296
collection .Count ().Should ().Be (0 ); // fail message: Expected collection.Count() to be 0, but found 3 (difference of 3).
98
297
collection .Count .Should ().Be (0 ); // fail message: Expected collection.Count to be 0, but found 3 (difference of 3).
99
298
collection .Should ().HaveCount (0 ); // fail message: Expected collection to contain 0 item(s), but found 3: {1, 2, 3}.
100
299
101
300
// new assertion:
102
- collection .Should ().BeEmpty (); // fail message: Expected collection to be empty, but found {1, 2, 3 }.
301
+ collection .Should ().BeEmpty (); // fail message: Expected collection to be empty, but found at least one item {1 }.
103
302
```
104
303
105
304
### scenario: CollectionShouldNotContainCondition
@@ -123,8 +322,8 @@ collection.Should().NotContain(i => i == 4);
123
322
var collection = new List <int > { 1 , 2 , 3 , 4 , 5 };
124
323
125
324
// old assertion:
126
- collection .Any (i => i == 4 ).Should ().BeFalse (); // fail message: Expected collection.Any(i => i == 4) to be false , but found True.
127
- collection .Where (i => i == 4 ).Should ().BeEmpty (); // fail message: Expected collection.Where(i => i == 4) to be empty, but found {4}.
325
+ collection .Any (i => i == 4 ).Should ().BeFalse (); // fail message: Expected collection.Any(i => i == 4) to be False , but found True.
326
+ collection .Where (i => i == 4 ).Should ().BeEmpty (); // fail message: Expected collection.Where(i => i == 4) to be empty, but found at least one item {4}.
128
327
129
328
// new assertion:
130
329
collection .Should ().NotContain (i => i == 4 ); // fail message: Expected collection {1, 2, 3, 4, 5} to not have any items matching (i == 4), but found {4}.
@@ -150,7 +349,7 @@ collection.Should().NotContain(4);
150
349
var collection = new List <int > { 1 , 2 , 3 , 4 , 5 };
151
350
152
351
// old assertion:
153
- collection .Contains (4 ).Should ().BeFalse (); // fail message: Expected collection.Contains(4) to be false , but found True.
352
+ collection .Contains (4 ).Should ().BeFalse (); // fail message: Expected collection.Contains(4) to be False , but found True.
154
353
155
354
// new assertion:
156
355
collection .Should ().NotContain (4 ); // fail message: Expected collection {1, 2, 3, 4, 5} to not contain 4.
@@ -176,7 +375,7 @@ collection.Should().OnlyContain(x => x > 0);
176
375
var collection = new List <int > { 1 , 2 , 3 , - 1 };
177
376
178
377
// old assertion:
179
- collection .All (x => x > 0 ).Should ().BeTrue (); // fail message: Expected collection.All(x => x > 0) to be true , but found False.
378
+ collection .All (x => x > 0 ).Should ().BeTrue (); // fail message: Expected collection.All(x => x > 0) to be True , but found False.
180
379
181
380
// new assertion:
182
381
collection .Should ().OnlyContain (x => x > 0 ); // fail message: Expected collection to contain only items matching (x > 0), but {-1} do(es) not match.
@@ -202,7 +401,7 @@ collection.Should().Contain(2);
202
401
var collection = new List <int > { 1 , 3 , 4 , 5 };
203
402
204
403
// old assertion:
205
- collection .Contains (2 ).Should ().BeTrue (); // fail message: Expected collection.Contains(2) to be true , but found False.
404
+ collection .Contains (2 ).Should ().BeTrue (); // fail message: Expected collection.Contains(2) to be True , but found False.
206
405
207
406
// new assertion:
208
407
collection .Should ().Contain (2 ); // fail message: Expected collection {1, 3, 4, 5} to contain 2.
@@ -229,7 +428,7 @@ collection.Should().Contain(i => i == 2);
229
428
var collection = new List <int > { 3 , 4 , 5 };
230
429
231
430
// old assertion:
232
- collection .Any (i => i == 2 ).Should ().BeTrue (); // fail message: Expected collection.Any(i => i == 2) to be true , but found False.
431
+ collection .Any (i => i == 2 ).Should ().BeTrue (); // fail message: Expected collection.Any(i => i == 2) to be True , but found False.
233
432
collection .Where (i => i == 2 ).Should ().NotBeEmpty (); // fail message: Expected collection.Where(i => i == 2) not to be empty.
234
433
235
434
// new assertion:
@@ -580,7 +779,7 @@ dictionary.Should().ContainKey("two");
580
779
var dictionary = new Dictionary <string , int > { [" one" ] = 1 , [" three" ] = 3 };
581
780
582
781
// old assertion:
583
- dictionary .ContainsKey (" two" ).Should ().BeTrue (); // fail message: Expected dictionary.ContainsKey("two") to be true , but found False.
782
+ dictionary .ContainsKey (" two" ).Should ().BeTrue (); // fail message: Expected dictionary.ContainsKey("two") to be True , but found False.
584
783
585
784
// new assertion:
586
785
dictionary .Should ().ContainKey (" two" ); // fail message: Expected dictionary {["one"] = 1, ["three"] = 3} to contain key "two".
@@ -606,7 +805,7 @@ dictionary.Should().NotContainKey("four");
606
805
var dictionary = new Dictionary <string , int > { [" one" ] = 1 , [" two" ] = 2 , [" three" ] = 3 , [" four" ] = 4 };
607
806
608
807
// old assertion:
609
- dictionary .ContainsKey (" four" ).Should ().BeFalse (); // fail message: Expected dictionary.ContainsKey("four") to be false , but found True.
808
+ dictionary .ContainsKey (" four" ).Should ().BeFalse (); // fail message: Expected dictionary.ContainsKey("four") to be False , but found True.
610
809
611
810
// new assertion:
612
811
dictionary .Should ().NotContainKey (" four" ); // fail message: Expected dictionary {["one"] = 1, ["two"] = 2, ["three"] = 3, ["four"] = 4} not to contain key "four", but found it anyhow.
@@ -632,7 +831,7 @@ dictionary.Should().ContainValue(2);
632
831
var dictionary = new Dictionary <string , int > { [" one" ] = 1 , [" two" ] = 2 , [" three" ] = 3 };
633
832
634
833
// old assertion:
635
- dictionary .ContainsValue (4 ).Should ().BeTrue (); // fail message: Expected dictionary.ContainsValue(4) to be true , but found False.
834
+ dictionary .ContainsValue (4 ).Should ().BeTrue (); // fail message: Expected dictionary.ContainsValue(4) to be True , but found False.
636
835
637
836
// new assertion:
638
837
dictionary .Should ().ContainValue (4 ); // fail message: Expected dictionary {["one"] = 1, ["two"] = 2, ["three"] = 3} to contain value 4.
@@ -658,7 +857,7 @@ dictionary.Should().NotContainValue(4);
658
857
var dictionary = new Dictionary <string , int > { [" one" ] = 1 , [" two" ] = 2 , [" three" ] = 3 , [" four" ] = 4 };
659
858
660
859
// old assertion:
661
- dictionary .ContainsValue (4 ).Should ().BeFalse (); // fail message: Expected dictionary.ContainsValue(4) to be false , but found True.
860
+ dictionary .ContainsValue (4 ).Should ().BeFalse (); // fail message: Expected dictionary.ContainsValue(4) to be False , but found True.
662
861
663
862
// new assertion:
664
863
dictionary .Should ().NotContainValue (4 ); // fail message: Expected dictionary {["one"] = 1, ["two"] = 2, ["three"] = 3, ["four"] = 4} not to contain value 4, but found it anyhow.
0 commit comments