@@ -4,12 +4,19 @@ This is a generated file, please edit src\FluentAssertions.Analyzers.FluentAsser
44
55# Nunit4 Analyzer Docs
66
7- - [ BooleanAssertIsTrue] ( #scenario-booleanassertistrue ) - ` flag.Should().BeTrue(); `
7+ - [ AssertIsTrue] ( #scenario-assertistrue ) - ` flag.Should().BeTrue(); `
8+ - [ AssertIsFalse] ( #scenario-assertisfalse ) - ` flag.Should().BeFalse(); `
9+ - [ AssertNull] ( #scenario-assertnull ) - ` obj.Should().BeNull(); `
10+ - [ AssertNotNull] ( #scenario-assertnotnull ) - ` obj.Should().NotBeNull(); `
11+ - [ AssertIsEmpty] ( #scenario-assertisempty ) - ` collection.Should().BeEmpty(); `
12+ - [ AssertIsNotEmpty] ( #scenario-assertisnotempty ) - ` collection.Should().NotBeEmpty(); `
13+ - [ AssertZero] ( #scenario-assertzero ) - ` number.Should().Be(0); `
14+ - [ AssertNotZero] ( #scenario-assertnotzero ) - ` number.Should().NotBe(0); `
815
916
1017## Scenarios
1118
12- ### scenario: BooleanAssertIsTrue
19+ ### scenario: AssertIsTrue
1320
1421``` cs
1522// arrange
@@ -57,4 +64,265 @@ Assert.That(flag, Is.Not.False); /* fail message: Assert.That(flag, Is.Not.Fal
5764flag .Should ().BeTrue (); /* fail message: Expected flag to be true, but found False. */
5865```
5966
67+ ### scenario: AssertIsFalse
68+
69+ ``` cs
70+ // arrange
71+ var flag = false ;
72+
73+ // old assertion:
74+ ClassicAssert .IsFalse (flag );
75+ ClassicAssert .False (flag );
76+ Assert .That (flag , Is .False );
77+ Assert .That (flag , Is .Not .True );
78+
79+ // new assertion:
80+ flag .Should ().BeFalse ();
81+ ```
82+
83+ #### Failure messages
84+
85+ ``` cs
86+ var flag = true ;
87+
88+ // old assertion:
89+ ClassicAssert .False (flag ); /* fail message: Assert.That(condition, Is.False)
90+ Expected: False
91+ But was: True
92+ */
93+ ClassicAssert .IsFalse (flag ); /* fail message: Assert.That(condition, Is.False)
94+ Expected: False
95+ But was: True
96+ */
97+ Assert .That (flag , Is .False ); /* fail message: Assert.That(flag, Is.False)
98+ Expected: False
99+ But was: True
100+ */
101+ Assert .That (flag , Is .Not .True ); /* fail message: Assert.That(flag, Is.Not.True)
102+ Expected: not True
103+ But was: True
104+ */
105+
106+ // new assertion:
107+ flag .Should ().BeFalse (); /* fail message: Expected flag to be false, but found True. */
108+ ```
109+
110+ ### scenario: AssertNull
111+
112+ ``` cs
113+ // arrange
114+ object obj = null ;
115+
116+ // old assertion:
117+ ClassicAssert .IsNull (obj );
118+ ClassicAssert .Null (obj );
119+ Assert .That (obj , Is .Null );
120+
121+ // new assertion:
122+ obj .Should ().BeNull ();
123+ ```
124+
125+ #### Failure messages
126+
127+ ``` cs
128+ object obj = " foo" ;
129+
130+ // old assertion:
131+ ClassicAssert .Null (obj ); /* fail message: Assert.That(anObject, Is.Null)
132+ Expected: null
133+ But was: "foo"
134+ */
135+ ClassicAssert .IsNull (obj ); /* fail message: Assert.That(anObject, Is.Null)
136+ Expected: null
137+ But was: "foo"
138+ */
139+ Assert .That (obj , Is .Null ); /* fail message: Assert.That(obj, Is.Null)
140+ Expected: null
141+ But was: "foo"
142+ */
143+
144+ // new assertion:
145+ obj .Should ().BeNull (); /* fail message: Expected obj to be <null>, but found "foo". */
146+ ```
147+
148+ ### scenario: AssertNotNull
149+
150+ ``` cs
151+ // arrange
152+ object obj = " foo" ;
153+
154+ // old assertion:
155+ ClassicAssert .IsNotNull (obj );
156+ ClassicAssert .NotNull (obj );
157+ Assert .That (obj , Is .Not .Null );
158+
159+ // new assertion:
160+ obj .Should ().NotBeNull ();
161+ ```
162+
163+ #### Failure messages
164+
165+ ``` cs
166+ object obj = null ;
167+
168+ // old assertion:
169+ ClassicAssert .NotNull (obj ); /* fail message: Assert.That(anObject, Is.Not.Null)
170+ Expected: not null
171+ But was: null
172+ */
173+ ClassicAssert .IsNotNull (obj ); /* fail message: Assert.That(anObject, Is.Not.Null)
174+ Expected: not null
175+ But was: null
176+ */
177+ Assert .That (obj , Is .Not .Null ); /* fail message: Assert.That(obj, Is.Not.Null)
178+ Expected: not null
179+ But was: null
180+ */
181+
182+ // new assertion:
183+ obj .Should ().NotBeNull (); /* fail message: Expected obj not to be <null>. */
184+ ```
185+
186+ ### scenario: AssertIsEmpty
187+
188+ ``` cs
189+ // arrange
190+ var collection = new List <int >();
191+
192+ // old assertion:
193+ ClassicAssert .IsEmpty (collection );
194+ Assert .That (collection , Is .Empty );
195+ CollectionAssert .IsEmpty (collection );
196+
197+ // new assertion:
198+ collection .Should ().BeEmpty ();
199+ ```
200+
201+ #### Failure messages
202+
203+ ``` cs
204+ var collection = new List <int > { 1 , 2 , 3 };
205+
206+ // old assertion:
207+ ClassicAssert .IsEmpty (collection ); /* fail message: Assert.That(collection, new EmptyCollectionConstraint())
208+ Expected: <empty>
209+ But was: < 1, 2, 3 >
210+ */
211+ Assert .That (collection , Is .Empty ); /* fail message: Assert.That(collection, Is.Empty)
212+ Expected: <empty>
213+ But was: < 1, 2, 3 >
214+ */
215+ CollectionAssert .IsEmpty (collection ); /* fail message: Assert.That(collection, new EmptyCollectionConstraint())
216+ Expected: <empty>
217+ But was: < 1, 2, 3 >
218+ */
219+
220+ // new assertion:
221+ collection .Should ().BeEmpty (); /* fail message: Expected collection to be empty, but found {1, 2, 3}. */
222+ ```
223+
224+ ### scenario: AssertIsNotEmpty
225+
226+ ``` cs
227+ // arrange
228+ var collection = new List <int > { 1 , 2 , 3 };
229+
230+ // old assertion:
231+ ClassicAssert .IsNotEmpty (collection );
232+ Assert .That (collection , Is .Not .Empty );
233+ CollectionAssert .IsNotEmpty (collection );
234+
235+ // new assertion:
236+ collection .Should ().NotBeEmpty ();
237+ ```
238+
239+ #### Failure messages
240+
241+ ``` cs
242+ var collection = new List <int >();
243+
244+ // old assertion:
245+ ClassicAssert .IsNotEmpty (collection ); /* fail message: Assert.That(collection, Is.Not.Empty)
246+ Expected: not <empty>
247+ But was: <empty>
248+ */
249+ Assert .That (collection , Is .Not .Empty ); /* fail message: Assert.That(collection, Is.Not.Empty)
250+ Expected: not <empty>
251+ But was: <empty>
252+ */
253+ CollectionAssert .IsNotEmpty (collection ); /* fail message: Assert.That(collection, new NotConstraint(new EmptyCollectionConstraint()))
254+ Expected: not <empty>
255+ But was: <empty>
256+ */
257+
258+ // new assertion:
259+ collection .Should ().NotBeEmpty (); /* fail message: Expected collection not to be empty. */
260+ ```
261+
262+ ### scenario: AssertZero
263+
264+ ``` cs
265+ // arrange
266+ var number = 0 ;
267+
268+ // old assertion:
269+ ClassicAssert .Zero (number );
270+ Assert .That (number , Is .Zero );
271+
272+ // new assertion:
273+ number .Should ().Be (0 );
274+ ```
275+
276+ #### Failure messages
277+
278+ ``` cs
279+ var number = 1 ;
280+
281+ // old assertion:
282+ ClassicAssert .Zero (number ); /* fail message: Assert.That(actual, Is.Zero)
283+ Expected: 0
284+ But was: 1
285+ */
286+ Assert .That (number , Is .Zero ); /* fail message: Assert.That(number, Is.Zero)
287+ Expected: 0
288+ But was: 1
289+ */
290+
291+ // new assertion:
292+ number .Should ().Be (0 ); /* fail message: Expected number to be 0, but found 1 (difference of 1). */
293+ ```
294+
295+ ### scenario: AssertNotZero
296+
297+ ``` cs
298+ // arrange
299+ var number = 1 ;
300+
301+ // old assertion:
302+ ClassicAssert .NotZero (number );
303+ Assert .That (number , Is .Not .Zero );
304+
305+ // new assertion:
306+ number .Should ().NotBe (0 );
307+ ```
308+
309+ #### Failure messages
310+
311+ ``` cs
312+ var number = 0 ;
313+
314+ // old assertion:
315+ ClassicAssert .NotZero (number ); /* fail message: Assert.That(actual, Is.Not.Zero)
316+ Expected: not equal to 0
317+ But was: 0
318+ */
319+ Assert .That (number , Is .Not .Zero ); /* fail message: Assert.That(number, Is.Not.Zero)
320+ Expected: not equal to 0
321+ But was: 0
322+ */
323+
324+ // new assertion:
325+ number .Should ().NotBe (0 ); /* fail message: Did not expect number to be 0. */
326+ ```
327+
60328
0 commit comments