@@ -27,10 +27,11 @@ static JTokenAssertions()
2727 /// Initializes a new instance of the <see cref="JTokenAssertions" /> class.
2828 /// </summary>
2929 /// <param name="subject">The subject</param>
30- public JTokenAssertions ( JToken subject )
31- : base ( subject )
30+ /// <param name="orCreate"></param>
31+ public JTokenAssertions ( JToken subject , AssertionChain assertionChain )
32+ : base ( subject , assertionChain )
3233 {
33- EnumerableSubject = new GenericCollectionAssertions < JToken > ( subject ) ;
34+ EnumerableSubject = new GenericCollectionAssertions < JToken > ( subject , assertionChain ) ;
3435 }
3536
3637 /// <summary>
@@ -126,7 +127,7 @@ private AndConstraint<JTokenAssertions> BeEquivalentTo(JToken expected, bool ign
126127 $ "{ Format ( expected , true ) . EscapePlaceholders ( ) } { Environment . NewLine } " +
127128 "{reason}." ;
128129
129- Execute . Assertion
130+ CurrentAssertionChain
130131 . ForCondition ( difference == null )
131132 . BecauseOf ( because , becauseArgs )
132133 . FailWith ( message ) ;
@@ -180,7 +181,7 @@ public AndConstraint<JTokenAssertions> NotBeEquivalentTo(string unexpected, stri
180181 /// </param>
181182 public AndConstraint < JTokenAssertions > NotBeEquivalentTo ( JToken unexpected , string because = "" , params object [ ] becauseArgs )
182183 {
183- Execute . Assertion
184+ CurrentAssertionChain
184185 . ForCondition ( ( Subject is null && unexpected is not null ) ||
185186 ! JToken . DeepEquals ( Subject , unexpected ) )
186187 . BecauseOf ( because , becauseArgs )
@@ -211,12 +212,12 @@ public AndConstraint<JTokenAssertions> HaveValue(string expected)
211212 /// </param>
212213 public AndConstraint < JTokenAssertions > HaveValue ( string expected , string because , params object [ ] becauseArgs )
213214 {
214- Execute . Assertion
215+ CurrentAssertionChain
215216 . ForCondition ( Subject is not null )
216217 . BecauseOf ( because , becauseArgs )
217218 . FailWith ( "Expected JSON token to have value {0}, but the element was <null>." , expected ) ;
218219
219- Execute . Assertion
220+ CurrentAssertionChain
220221 . ForCondition ( Subject . Value < string > ( ) == expected )
221222 . BecauseOf ( because , becauseArgs )
222223 . FailWith ( "Expected JSON property {0} to have value {1}{reason}, but found {2}." ,
@@ -238,12 +239,12 @@ public AndConstraint<JTokenAssertions> HaveValue(string expected, string because
238239 /// </param>
239240 public AndConstraint < JTokenAssertions > NotHaveValue ( string unexpected , string because = "" , params object [ ] becauseArgs )
240241 {
241- Execute . Assertion
242+ CurrentAssertionChain
242243 . ForCondition ( Subject is not null )
243244 . BecauseOf ( because , becauseArgs )
244245 . FailWith ( "Did not expect the JSON property to have value {0}, but the token was <null>." , unexpected ) ;
245246
246- Execute . Assertion
247+ CurrentAssertionChain
247248 . ForCondition ( Subject . Value < string > ( ) != unexpected )
248249 . BecauseOf ( because , becauseArgs )
249250 . FailWith ( "Did not expect JSON property {0} to have value {1}{reason}." ,
@@ -279,7 +280,7 @@ public AndConstraint<JTokenAssertions> MatchRegex(string regularExpression, stri
279280 throw new ArgumentNullException ( nameof ( regularExpression ) , "MatchRegex does not support <null> pattern" ) ;
280281 }
281282
282- Execute . Assertion
283+ CurrentAssertionChain
283284 . ForCondition ( Regex . IsMatch ( Subject . Value < string > ( ) , regularExpression ) )
284285 . BecauseOf ( because , becauseArgs )
285286 . FailWith ( "Expected {context:JSON property} {0} to match regex pattern {1}{reason}, but found {2}." ,
@@ -306,7 +307,7 @@ public AndConstraint<JTokenAssertions> NotMatchRegex(string regularExpression, s
306307 throw new ArgumentNullException ( nameof ( regularExpression ) , "MatchRegex does not support <null> pattern" ) ;
307308 }
308309
309- Execute . Assertion
310+ CurrentAssertionChain
310311 . ForCondition ( ! Regex . IsMatch ( Subject . Value < string > ( ) , regularExpression ) )
311312 . BecauseOf ( because , becauseArgs )
312313 . FailWith ( "Did not expect {context:JSON property} {0} to match regex pattern {1}{reason}." ,
@@ -341,7 +342,8 @@ public AndWhichConstraint<JTokenAssertions, JToken> HaveElement(string expected,
341342 params object [ ] becauseArgs )
342343 {
343344 JToken jToken = Subject [ expected ] ;
344- Execute . Assertion
345+
346+ CurrentAssertionChain
345347 . ForCondition ( jToken != null )
346348 . BecauseOf ( because , becauseArgs )
347349 . FailWith ( "Expected JSON document {0} to have element \" " + expected . EscapePlaceholders ( ) + "\" {reason}" +
@@ -366,7 +368,8 @@ public AndWhichConstraint<JTokenAssertions, JToken> NotHaveElement(string unexpe
366368 params object [ ] becauseArgs )
367369 {
368370 JToken jToken = Subject [ unexpected ] ;
369- Execute . Assertion
371+
372+ CurrentAssertionChain
370373 . ForCondition ( jToken == null )
371374 . BecauseOf ( because , becauseArgs )
372375 . FailWith ( "Did not expect JSON document {0} to have element \" " + unexpected . EscapePlaceholders ( ) + "\" {reason}." , Subject ) ;
0 commit comments