@@ -36,6 +36,18 @@ collection.Any().Should().BeTrue();
36
36
collection .Should ().NotBeEmpty ();
37
37
```
38
38
39
+ #### Failure messages
40
+
41
+ ``` cs
42
+ // arrange
43
+
44
+ // old assertion:
45
+ collection .Any ().Should ().BeTrue (); // fail message: Expected collection.Any() to be true, but found False.
46
+
47
+ // new assertion:
48
+ collection .Should ().NotBeEmpty (); // fail message: Expected collection not to be empty.
49
+ ```
50
+
39
51
### scenario: CollectionShouldBeEmpty
40
52
41
53
``` cs
@@ -52,6 +64,21 @@ collection.Should().HaveCount(0);
52
64
collection .Should ().BeEmpty ();
53
65
```
54
66
67
+ #### Failure messages
68
+
69
+ ``` cs
70
+ // arrange
71
+
72
+ // old assertion:
73
+ collection .Any ().Should ().BeFalse (); // fail message: Expected collection.Any() to be false, but found True.
74
+ collection .Count ().Should ().Be (0 ); // fail message: Expected collection.Count() to be 0, but found 3 (difference of 3).
75
+ collection .Count .Should ().Be (0 ); // fail message: Expected collection.Count to be 0, but found 3 (difference of 3).
76
+ collection .Should ().HaveCount (0 ); // fail message: Expected collection to contain 0 item(s), but found 3: {1, 2, 3}.
77
+
78
+ // new assertion:
79
+ collection .Should ().BeEmpty (); // fail message: Expected collection to be empty, but found {1, 2, 3}.
80
+ ```
81
+
55
82
### scenario: CollectionShouldNotContainCondition
56
83
57
84
``` cs
@@ -66,6 +93,19 @@ collection.Where(i => i == 4).Should().BeEmpty();
66
93
collection .Should ().NotContain (i => i == 4 );
67
94
```
68
95
96
+ #### Failure messages
97
+
98
+ ``` cs
99
+ // arrange
100
+
101
+ // old assertion:
102
+ collection .Any (i => i == 4 ).Should ().BeFalse (); // fail message: Expected collection.Any(i => i == 4) to be false, but found True.
103
+ collection .Where (i => i == 4 ).Should ().BeEmpty (); // fail message: Expected collection.Where(i => i == 4) to be empty, but found {4}.
104
+
105
+ // new assertion:
106
+ 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}.
107
+ ```
108
+
69
109
### scenario: CollectionShouldNotContainItem
70
110
71
111
``` cs
@@ -79,6 +119,18 @@ collection.Contains(4).Should().BeFalse();
79
119
collection .Should ().NotContain (4 );
80
120
```
81
121
122
+ #### Failure messages
123
+
124
+ ``` cs
125
+ // arrange
126
+
127
+ // old assertion:
128
+ collection .Contains (4 ).Should ().BeFalse (); // fail message: Expected collection.Contains(4) to be false, but found True.
129
+
130
+ // new assertion:
131
+ collection .Should ().NotContain (4 ); // fail message: Expected collection {1, 2, 3, 4, 5} to not contain 4.
132
+ ```
133
+
82
134
### scenario: CollectionShouldOnlyContainProperty
83
135
84
136
``` cs
@@ -92,6 +144,18 @@ collection.All(x => x > 0).Should().BeTrue();
92
144
collection .Should ().OnlyContain (x => x > 0 );
93
145
```
94
146
147
+ #### Failure messages
148
+
149
+ ``` cs
150
+ // arrange
151
+
152
+ // old assertion:
153
+ collection .All (x => x > 0 ).Should ().BeTrue (); // fail message: Expected collection.All(x => x > 0) to be true, but found False.
154
+
155
+ // new assertion:
156
+ collection .Should ().OnlyContain (x => x > 0 ); // fail message: Expected collection to contain only items matching (x > 0), but {-1} do(es) not match.
157
+ ```
158
+
95
159
### scenario: CollectionShouldContainItem
96
160
97
161
``` cs
@@ -105,6 +169,18 @@ collection.Contains(2).Should().BeTrue();
105
169
collection .Should ().Contain (2 );
106
170
```
107
171
172
+ #### Failure messages
173
+
174
+ ``` cs
175
+ // arrange
176
+
177
+ // old assertion:
178
+ collection .Contains (2 ).Should ().BeTrue (); // fail message: Expected collection.Contains(2) to be true, but found False.
179
+
180
+ // new assertion:
181
+ collection .Should ().Contain (2 ); // fail message: Expected collection {1, 3, 4, 5} to contain 2.
182
+ ```
183
+
108
184
### scenario: CollectionShouldContainCondition
109
185
110
186
``` cs
@@ -119,6 +195,19 @@ collection.Where(i => i == 2).Should().NotBeEmpty();
119
195
collection .Should ().Contain (i => i == 2 );
120
196
```
121
197
198
+ #### Failure messages
199
+
200
+ ``` cs
201
+ // arrange
202
+
203
+ // old assertion:
204
+ collection .Any (i => i == 2 ).Should ().BeTrue (); // fail message: Expected collection.Any(i => i == 2) to be true, but found False.
205
+ collection .Where (i => i == 2 ).Should ().NotBeEmpty (); // fail message: Expected collection.Where(i => i == 2) not to be empty.
206
+
207
+ // new assertion:
208
+ collection .Should ().Contain (i => i == 2 ); // fail message: Expected collection {3, 4, 5} to have an item matching (i == 2).
209
+ ```
210
+
122
211
### scenario: CollectionShouldHaveCount_Count
123
212
124
213
``` cs
@@ -133,6 +222,19 @@ collection.Count.Should().Be(3);
133
222
collection .Should ().HaveCount (3 );
134
223
```
135
224
225
+ #### Failure messages
226
+
227
+ ``` cs
228
+ // arrange
229
+
230
+ // old assertion:
231
+ collection .Count ().Should ().Be (3 ); // fail message: Expected collection.Count() to be 3, but found 5.
232
+ collection .Count .Should ().Be (3 ); // fail message: Expected collection.Count to be 3, but found 5.
233
+
234
+ // new assertion:
235
+ collection .Should ().HaveCount (3 ); // fail message: Expected collection to contain 3 item(s), but found 5: {1, 2, 3, 4, 5}.
236
+ ```
237
+
136
238
### scenario: CollectionShouldHaveCount_Length
137
239
138
240
``` cs
@@ -146,6 +248,18 @@ collection.Length.Should().Be(3);
146
248
collection .Should ().HaveCount (3 );
147
249
```
148
250
251
+ #### Failure messages
252
+
253
+ ``` cs
254
+ // arrange
255
+
256
+ // old assertion:
257
+ collection .Length .Should ().Be (3 ); // fail message: Expected collection.Length to be 3, but found 5.
258
+
259
+ // new assertion:
260
+ collection .Should ().HaveCount (3 ); // fail message: Expected collection to contain 3 item(s), but found 5: {1, 2, 3, 4, 5}.
261
+ ```
262
+
149
263
### scenario: CollectionShouldNotHaveCount_Count
150
264
151
265
``` cs
@@ -159,6 +273,18 @@ collection.Count().Should().NotBe(4);
159
273
collection .Should ().NotHaveCount (4 );
160
274
```
161
275
276
+ #### Failure messages
277
+
278
+ ``` cs
279
+ // arrange
280
+
281
+ // old assertion:
282
+ collection .Count ().Should ().NotBe (4 ); // fail message: Did not expect collection.Count() to be 4.
283
+
284
+ // new assertion:
285
+ collection .Should ().NotHaveCount (4 ); // fail message: Expected collection to not contain 4 item(s), but found 4.
286
+ ```
287
+
162
288
### scenario: CollectionShouldContainSingle
163
289
164
290
``` cs
@@ -174,6 +300,20 @@ collection.Should().HaveCount(1);
174
300
collection .Should ().ContainSingle ();
175
301
```
176
302
303
+ #### Failure messages
304
+
305
+ ``` cs
306
+ // arrange
307
+
308
+ // old assertion:
309
+ collection .Count ().Should ().Be (1 ); // fail message: Expected collection.Count() to be 1, but found 3.
310
+ collection .Count .Should ().Be (1 ); // fail message: Expected collection.Count to be 1, but found 3.
311
+ collection .Should ().HaveCount (1 ); // fail message: Expected collection to contain 1 item(s), but found 3: {1, 2, 3}.
312
+
313
+ // new assertion:
314
+ collection .Should ().ContainSingle (); // fail message: Expected collection to contain a single item, but found {1, 2, 3}.
315
+ ```
316
+
177
317
### scenario: CollectionShouldHaveCountGreaterThan_CountShouldBeGreaterThan
178
318
179
319
``` cs
@@ -187,6 +327,18 @@ collection.Count().Should().BeGreaterThan(2);
187
327
collection .Should ().HaveCountGreaterThan (2 );
188
328
```
189
329
330
+ #### Failure messages
331
+
332
+ ``` cs
333
+ // arrange
334
+
335
+ // old assertion:
336
+ collection .Count ().Should ().BeGreaterThan (2 ); // fail message: Expected collection.Count() to be greater than 2, but found 1.
337
+
338
+ // new assertion:
339
+ collection .Should ().HaveCountGreaterThan (2 ); // fail message: Expected collection to contain more than 2 item(s), but found 1: {1}.
340
+ ```
341
+
190
342
### scenario: CollectionShouldHaveCountGreaterOrEqualTo_CountShouldBeGreaterOrEqualTo
191
343
192
344
``` cs
@@ -200,6 +352,18 @@ collection.Count().Should().BeGreaterOrEqualTo(3);
200
352
collection .Should ().HaveCountGreaterOrEqualTo (3 );
201
353
```
202
354
355
+ #### Failure messages
356
+
357
+ ``` cs
358
+ // arrange
359
+
360
+ // old assertion:
361
+ collection .Count ().Should ().BeGreaterOrEqualTo (3 ); // fail message: Expected collection.Count() to be greater than or equal to 3, but found 2.
362
+
363
+ // new assertion:
364
+ collection .Should ().HaveCountGreaterOrEqualTo (3 ); // fail message: Expected collection to contain at least 3 item(s), but found 2: {1, 2}.
365
+ ```
366
+
203
367
### scenario: CollectionShouldHaveCountLessThan_CountShouldBeLessThan
204
368
205
369
``` cs
@@ -213,6 +377,18 @@ collection.Count().Should().BeLessThan(4);
213
377
collection .Should ().HaveCountLessThan (4 );
214
378
```
215
379
380
+ #### Failure messages
381
+
382
+ ``` cs
383
+ // arrange
384
+
385
+ // old assertion:
386
+ collection .Count ().Should ().BeLessThan (4 ); // fail message: Expected collection.Count() to be less than 4, but found 5.
387
+
388
+ // new assertion:
389
+ collection .Should ().HaveCountLessThan (4 ); // fail message: Expected collection to contain fewer than 4 item(s), but found 5: {1, 2, 3, 4, 5}.
390
+ ```
391
+
216
392
### scenario: CollectionShouldHaveCountLessOrEqualTo_CountShouldBeLessOrEqualTo
217
393
218
394
``` cs
@@ -226,6 +402,18 @@ collection.Count().Should().BeLessOrEqualTo(3);
226
402
collection .Should ().HaveCountLessOrEqualTo (3 );
227
403
```
228
404
405
+ #### Failure messages
406
+
407
+ ``` cs
408
+ // arrange
409
+
410
+ // old assertion:
411
+ collection .Count ().Should ().BeLessOrEqualTo (3 ); // fail message: Expected collection.Count() to be less than or equal to 3, but found 4.
412
+
413
+ // new assertion:
414
+ collection .Should ().HaveCountLessOrEqualTo (3 ); // fail message: Expected collection to contain at most 3 item(s), but found 4: {1, 2, 3, 4}.
415
+ ```
416
+
229
417
### scenario: CollectionShouldHaveSameCount_ShouldHaveCountOtherCollectionCount
230
418
231
419
``` cs
@@ -240,6 +428,18 @@ collection.Should().HaveCount(otherCollection.Count());
240
428
collection .Should ().HaveSameCount (otherCollection );
241
429
```
242
430
431
+ #### Failure messages
432
+
433
+ ``` cs
434
+ // arrange
435
+
436
+ // old assertion:
437
+ collection .Should ().HaveCount (otherCollection .Count ()); // fail message: Expected collection to contain 4 item(s), but found 3: {1, 2, 3}.
438
+
439
+ // new assertion:
440
+ collection .Should ().HaveSameCount (otherCollection ); // fail message: Expected collection to have 4 item(s), but found 3.
441
+ ```
442
+
243
443
### scenario: CollectionShouldNotHaveSameCount_CountShouldNotBeOtherCollectionCount
244
444
245
445
``` cs
@@ -254,6 +454,18 @@ collection.Count().Should().NotBe(otherCollection.Count());
254
454
collection .Should ().NotHaveSameCount (otherCollection );
255
455
```
256
456
457
+ #### Failure messages
458
+
459
+ ``` cs
460
+ // arrange
461
+
462
+ // old assertion:
463
+ collection .Count ().Should ().NotBe (otherCollection .Count ()); // fail message: Did not expect collection.Count() to be 3.
464
+
465
+ // new assertion:
466
+ collection .Should ().NotHaveSameCount (otherCollection ); // fail message: Expected collection to not have 3 item(s), but found 3.
467
+ ```
468
+
257
469
### scenario: CollectionShouldContainSingle_WhereShouldHaveCount1
258
470
259
471
``` cs
@@ -267,6 +479,18 @@ collection.Where(i => i == 1).Should().HaveCount(1);
267
479
collection .Should ().ContainSingle (i => i == 1 );
268
480
```
269
481
482
+ #### Failure messages
483
+
484
+ ``` cs
485
+ // arrange
486
+
487
+ // old assertion:
488
+ collection .Where (i => i == 1 ).Should ().HaveCount (1 ); // fail message: Expected collection.Where(i => i == 1) to contain 1 item(s), but found 2: {1, 1}.
489
+
490
+ // new assertion:
491
+ collection .Should ().ContainSingle (i => i == 1 ); // fail message: Expected collection to contain a single item matching (i == 1), but 2 such items were found.
492
+ ```
493
+
270
494
### scenario: CollectionShouldNotBeNullOrEmpty
271
495
272
496
``` cs
@@ -281,4 +505,17 @@ collection.Should().NotBeNull().And.NotBeEmpty();
281
505
collection .Should ().NotBeNullOrEmpty ();
282
506
```
283
507
508
+ #### Failure messages
509
+
510
+ ``` cs
511
+ // arrange
512
+
513
+ // old assertion:
514
+ collection .Should ().NotBeEmpty ().And .NotBeNull (); // fail message: Expected collection not to be empty.
515
+ collection .Should ().NotBeNull ().And .NotBeEmpty (); // fail message: Expected collection not to be empty.
516
+
517
+ // new assertion:
518
+ collection .Should ().NotBeNullOrEmpty (); // fail message: Expected collection not to be empty.
519
+ ```
520
+
284
521
0 commit comments