44using FluentAssertions . Collections ;
55using FluentAssertions . DataSets ;
66using FluentAssertions . DataSets . Common ;
7- using FluentAssertions . Execution ;
87
98// ReSharper disable once CheckNamespace
109namespace FluentAssertions ;
@@ -35,7 +34,7 @@ public static AndConstraint<GenericCollectionAssertions<DataColumn>> BeSameAs(
3534 {
3635 var actualSubject = wrapper . UnderlyingCollection ;
3736
38- Execute . Assertion
37+ assertion . CurrentAssertionChain
3938 . UsingLineBreaks
4039 . ForCondition ( ReferenceEquals ( actualSubject , expected ) )
4140 . BecauseOf ( because , becauseArgs )
@@ -45,7 +44,7 @@ public static AndConstraint<GenericCollectionAssertions<DataColumn>> BeSameAs(
4544 }
4645 else
4746 {
48- Execute . Assertion
47+ assertion . CurrentAssertionChain
4948 . BecauseOf ( because , becauseArgs )
5049 . FailWith (
5150 "Invalid expectation: Expected {context:column collection} to refer to an instance of " +
@@ -80,15 +79,15 @@ public static AndConstraint<GenericCollectionAssertions<DataColumn>> NotBeSameAs
8079 {
8180 var actualSubject = wrapper . UnderlyingCollection ;
8281
83- Execute . Assertion
82+ assertion . CurrentAssertionChain
8483 . UsingLineBreaks
8584 . ForCondition ( ! ReferenceEquals ( actualSubject , unexpected ) )
8685 . BecauseOf ( because , becauseArgs )
8786 . FailWith ( "Did not expect {context:column collection} to refer to {0}{reason}." , unexpected ) ;
8887 }
8988 else
9089 {
91- Execute . Assertion
90+ assertion . CurrentAssertionChain
9291 . BecauseOf ( because , becauseArgs )
9392 . FailWith (
9493 "Invalid expectation: Expected {context:column collection} to refer to a different instance of " +
@@ -119,18 +118,16 @@ public static AndConstraint<GenericCollectionAssertions<DataColumn>> HaveSameCou
119118 Guard . ThrowIfArgumentIsNull (
120119 otherCollection , nameof ( otherCollection ) , "Cannot verify count against a <null> collection." ) ;
121120
122- Execute . Assertion
121+ assertion . CurrentAssertionChain
123122 . BecauseOf ( because , becauseArgs )
124- . WithExpectation ( "Expected {context:collection} to have " )
125- . Given ( ( ) => assertion . Subject )
126- . ForCondition ( subject => subject is not null )
127- . FailWith ( "the same count as {0}{reason}, but found <null>." , otherCollection )
128- . Then
129- . Given ( subject => ( actual : subject . Count ( ) , expected : otherCollection . Count ) )
130- . ForCondition ( count => count . actual == count . expected )
131- . FailWith ( "{0} column(s){reason}, but found {1}." , count => count . expected , count => count . actual )
132- . Then
133- . ClearExpectation ( ) ;
123+ . WithExpectation ( "Expected {context:collection} to have " , chain => chain
124+ . Given ( ( ) => assertion . Subject )
125+ . ForCondition ( subject => subject is not null )
126+ . FailWith ( "the same count as {0}{reason}, but found <null>." , otherCollection )
127+ . Then
128+ . Given ( subject => ( actual : subject . Count ( ) , expected : otherCollection . Count ) )
129+ . ForCondition ( count => count . actual == count . expected )
130+ . FailWith ( "{0} column(s){reason}, but found {1}." , count => count . expected , count => count . actual ) ) ;
134131
135132 return new AndConstraint < GenericCollectionAssertions < DataColumn > > ( assertion ) ;
136133 }
@@ -157,18 +154,16 @@ public static AndConstraint<GenericCollectionAssertions<DataColumn>> NotHaveSame
157154 Guard . ThrowIfArgumentIsNull (
158155 otherCollection , nameof ( otherCollection ) , "Cannot verify count against a <null> collection." ) ;
159156
160- Execute . Assertion
157+ assertion . CurrentAssertionChain
161158 . BecauseOf ( because , becauseArgs )
162- . WithExpectation ( "Expected {context:collection} to not have " )
163- . Given ( ( ) => assertion . Subject )
164- . ForCondition ( subject => subject is not null )
165- . FailWith ( "the same count as {0}{reason}, but found <null>." , otherCollection )
166- . Then
167- . Given ( subject => ( actual : subject . Count ( ) , expected : otherCollection . Count ) )
168- . ForCondition ( count => count . actual != count . expected )
169- . FailWith ( "{0} column(s){reason}, but found {1}." , count => count . expected , count => count . actual )
170- . Then
171- . ClearExpectation ( ) ;
159+ . WithExpectation ( "Expected {context:collection} to not have " , chain => chain
160+ . Given ( ( ) => assertion . Subject )
161+ . ForCondition ( subject => subject is not null )
162+ . FailWith ( "the same count as {0}{reason}, but found <null>." , otherCollection )
163+ . Then
164+ . Given ( subject => ( actual : subject . Count ( ) , expected : otherCollection . Count ) )
165+ . ForCondition ( count => count . actual != count . expected )
166+ . FailWith ( "{0} column(s){reason}, but found {1}." , count => count . expected , count => count . actual ) ) ;
172167
173168 return new AndConstraint < GenericCollectionAssertions < DataColumn > > ( assertion ) ;
174169 }
0 commit comments