@@ -284,7 +284,7 @@ public VerifiableResponse Cookie(string name, IMatcher<string> matcher)
284284 /// <exception cref="ResponseVerificationException">Thrown when the actual response body does not match the expected one.</exception>
285285 public VerifiableResponse Body ( string expectedResponseBody )
286286 {
287- string actualResponseBody = this . Response . Content . ReadAsStringAsync ( ) . Result ;
287+ string actualResponseBody = this . Response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
288288
289289 if ( ! actualResponseBody . Equals ( expectedResponseBody ) )
290290 {
@@ -302,7 +302,7 @@ public VerifiableResponse Body(string expectedResponseBody)
302302 /// <exception cref="ResponseVerificationException">Thrown when the actual response body does not match the expected one.</exception>
303303 public VerifiableResponse Body ( IMatcher < string > matcher )
304304 {
305- string actualResponseBody = this . Response . Content . ReadAsStringAsync ( ) . Result ;
305+ string actualResponseBody = this . Response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
306306
307307 if ( ! matcher . Matches ( actualResponseBody ) )
308308 {
@@ -322,7 +322,7 @@ public VerifiableResponse Body(IMatcher<string> matcher)
322322 /// <returns>The current <see cref="VerifiableResponse"/> object.</returns>
323323 public VerifiableResponse Body < T > ( string path , IMatcher < T > matcher , VerifyAs verifyAs = VerifyAs . UseResponseContentTypeHeaderValue )
324324 {
325- string responseBodyAsString = this . Response . Content . ReadAsStringAsync ( ) . Result ;
325+ string responseBodyAsString = this . Response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
326326
327327 string ? responseMediaType = string . Empty ;
328328
@@ -449,7 +449,7 @@ public VerifiableResponse Body<T>(string path, IMatcher<IEnumerable<T>> matcher,
449449 {
450450 List < T > elementValues = new List < T > ( ) ;
451451
452- string responseBodyAsString = this . Response . Content . ReadAsStringAsync ( ) . Result ;
452+ string responseBodyAsString = this . Response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
453453
454454 string responseMediaType = this . Response . Content . Headers . ContentType ? . MediaType ?? string . Empty ;
455455
@@ -538,15 +538,12 @@ public VerifiableResponse MatchesJsonSchema(string jsonSchema)
538538
539539 try
540540 {
541- JsonSchema parsedSchema = JsonSchema . FromJsonAsync ( jsonSchema ) . Result ;
541+ JsonSchema parsedSchema = JsonSchema . FromJsonAsync ( jsonSchema ) . GetAwaiter ( ) . GetResult ( ) ;
542542 return this . MatchesJsonSchema ( parsedSchema ) ;
543543 }
544- catch ( AggregateException ae )
544+ catch ( JsonException je )
545545 {
546- foreach ( Exception ex in ae . InnerExceptions )
547- {
548- this . FailVerification ( $ "Could not parse supplied JSON schema. Error: { ex . Message } ") ;
549- }
546+ this . FailVerification ( $ "Could not parse supplied JSON schema. Error: { je . Message } ") ;
550547 }
551548
552549 return this ;
@@ -567,7 +564,7 @@ public VerifiableResponse MatchesJsonSchema(JsonSchema jsonSchema)
567564 this . FailVerification ( $ "Expected response Content-Type header to contain 'json', but was '{ responseMediaType } '") ;
568565 }
569566
570- string responseBodyAsString = this . Response . Content . ReadAsStringAsync ( ) . Result ;
567+ string responseBodyAsString = this . Response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
571568
572569 ICollection < ValidationError > schemaValidationErrors = jsonSchema . Validate ( responseBodyAsString ) ;
573570
@@ -618,7 +615,7 @@ public VerifiableResponse MatchesXsd(XmlSchemaSet schemas)
618615 settings . ValidationType = ValidationType . Schema ;
619616 settings . Schemas = schemas ;
620617
621- string responseXmlAsString = this . Response . Content . ReadAsStringAsync ( ) . Result ;
618+ string responseXmlAsString = this . Response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
622619 XmlReader reader = XmlReader . Create ( new StringReader ( responseXmlAsString ) , settings ) ;
623620
624621 try
@@ -652,7 +649,7 @@ public VerifiableResponse MatchesInlineDtd()
652649 settings . DtdProcessing = DtdProcessing . Parse ;
653650 settings . ValidationType = ValidationType . DTD ;
654651
655- string responseXmlAsString = this . Response . Content . ReadAsStringAsync ( ) . Result ;
652+ string responseXmlAsString = this . Response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
656653 XmlReader reader = XmlReader . Create ( new StringReader ( responseXmlAsString ) , settings ) ;
657654
658655 try
@@ -691,7 +688,7 @@ public VerifiableResponse ResponseTime(IMatcher<TimeSpan> matcher)
691688 /// <returns>The current <see cref="VerifiableResponse"/> object.</returns>
692689 public VerifiableResponse ResponseBodyLength ( IMatcher < int > matcher )
693690 {
694- string responseContentAsString = this . Response . Content . ReadAsStringAsync ( ) . Result ;
691+ string responseContentAsString = this . Response . Content . ReadAsStringAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
695692
696693 if ( ! matcher . Matches ( responseContentAsString . Length ) )
697694 {
0 commit comments