@@ -4,6 +4,13 @@ This is a generated file, please edit src\FluentAssertions.Analyzers.FluentAsser
44
55# FluentAssertions Analyzer Docs
66
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); `
714- [ CollectionShouldNotBeEmpty] ( #scenario-collectionshouldnotbeempty ) - ` collection.Should().NotBeEmpty(); `
815- [ CollectionShouldBeEmpty] ( #scenario-collectionshouldbeempty ) - ` collection.Should().BeEmpty(); `
916- [ CollectionShouldNotContainCondition] ( #scenario-collectionshouldnotcontaincondition ) - ` collection.Should().NotContain(i => i == 4); `
@@ -44,6 +51,198 @@ This is a generated file, please edit src\FluentAssertions.Analyzers.FluentAsser
4451
4552## Scenarios
4653
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+
47246### scenario: CollectionShouldNotBeEmpty
48247
49248``` cs
@@ -64,7 +263,7 @@ collection.Should().NotBeEmpty();
64263var collection = new List <int > { };
65264
66265// 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.
68267
69268// new assertion:
70269collection .Should ().NotBeEmpty (); // fail message: Expected collection not to be empty.
@@ -93,13 +292,13 @@ collection.Should().BeEmpty();
93292var collection = new List <int > { 1 , 2 , 3 };
94293
95294// 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.
97296collection .Count ().Should ().Be (0 ); // fail message: Expected collection.Count() to be 0, but found 3 (difference of 3).
98297collection .Count .Should ().Be (0 ); // fail message: Expected collection.Count to be 0, but found 3 (difference of 3).
99298collection .Should ().HaveCount (0 ); // fail message: Expected collection to contain 0 item(s), but found 3: {1, 2, 3}.
100299
101300// 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 }.
103302```
104303
105304### scenario: CollectionShouldNotContainCondition
@@ -123,8 +322,8 @@ collection.Should().NotContain(i => i == 4);
123322var collection = new List <int > { 1 , 2 , 3 , 4 , 5 };
124323
125324// 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}.
128327
129328// new assertion:
130329collection .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);
150349var collection = new List <int > { 1 , 2 , 3 , 4 , 5 };
151350
152351// 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.
154353
155354// new assertion:
156355collection .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);
176375var collection = new List <int > { 1 , 2 , 3 , - 1 };
177376
178377// 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.
180379
181380// new assertion:
182381collection .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);
202401var collection = new List <int > { 1 , 3 , 4 , 5 };
203402
204403// 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.
206405
207406// new assertion:
208407collection .Should ().Contain (2 ); // fail message: Expected collection {1, 3, 4, 5} to contain 2.
@@ -229,7 +428,7 @@ collection.Should().Contain(i => i == 2);
229428var collection = new List <int > { 3 , 4 , 5 };
230429
231430// 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.
233432collection .Where (i => i == 2 ).Should ().NotBeEmpty (); // fail message: Expected collection.Where(i => i == 2) not to be empty.
234433
235434// new assertion:
@@ -580,7 +779,7 @@ dictionary.Should().ContainKey("two");
580779var dictionary = new Dictionary <string , int > { [" one" ] = 1 , [" three" ] = 3 };
581780
582781// 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.
584783
585784// new assertion:
586785dictionary .Should ().ContainKey (" two" ); // fail message: Expected dictionary {["one"] = 1, ["three"] = 3} to contain key "two".
@@ -606,7 +805,7 @@ dictionary.Should().NotContainKey("four");
606805var dictionary = new Dictionary <string , int > { [" one" ] = 1 , [" two" ] = 2 , [" three" ] = 3 , [" four" ] = 4 };
607806
608807// 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.
610809
611810// new assertion:
612811dictionary .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);
632831var dictionary = new Dictionary <string , int > { [" one" ] = 1 , [" two" ] = 2 , [" three" ] = 3 };
633832
634833// 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.
636835
637836// new assertion:
638837dictionary .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);
658857var dictionary = new Dictionary <string , int > { [" one" ] = 1 , [" two" ] = 2 , [" three" ] = 3 , [" four" ] = 4 };
659858
660859// 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.
662861
663862// new assertion:
664863dictionary .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