@@ -47,6 +47,24 @@ public void JsonSchemaCanBeSuppliedAndVerifiedAsString()
4747 . MatchesJsonSchema ( JsonSchemaDefinitions . MatchingJsonSchema ) ;
4848 }
4949
50+ /// <summary>
51+ /// A test demonstrating RestAssuredNet syntax for validating a response
52+ /// against a JSON schema supplied as a string representing a file location.
53+ /// </summary>
54+ [ Test ]
55+ public void JsonSchemaCanBeSuppliedAndVerifiedAsStringPointingToFile ( )
56+ {
57+ this . CreateStubForJsonSchemaValidation ( ) ;
58+
59+ Given ( )
60+ . When ( )
61+ . Get ( $ "{ MOCK_SERVER_BASE_URL } /json-schema-validation")
62+ . Then ( )
63+ . StatusCode ( 200 )
64+ . And ( )
65+ . MatchesJsonSchema ( @"../../../Schemas/matching.schema.json" ) ;
66+ }
67+
5068 /// <summary>
5169 /// A test demonstrating RestAssuredNet syntax for validating a response
5270 /// against a JSON schema supplied as a JsonSchema.
@@ -111,6 +129,50 @@ public void SupplyingInvalidJsonSchemaThrowsTheExpectedException()
111129 Assert . That ( rve ? . Message , Does . Contain ( "Could not parse supplied JSON schema. Error:" ) ) ;
112130 }
113131
132+ /// <summary>
133+ /// A test checking that supplying an invalid JSON schema throws the expected exception.
134+ /// </summary>
135+ [ Test ]
136+ public void SupplyingInvalidJsonSchemaAsFileThrowsTheExpectedException ( )
137+ {
138+ this . CreateStubForJsonSchemaValidationMismatch ( ) ;
139+
140+ var rve = Assert . Throws < ResponseVerificationException > ( ( ) =>
141+ {
142+ Given ( )
143+ . When ( )
144+ . Get ( $ "{ MOCK_SERVER_BASE_URL } /json-schema-validation-mismatch")
145+ . Then ( )
146+ . StatusCode ( 200 )
147+ . And ( )
148+ . MatchesJsonSchema ( @"../../../Schemas/invalid.schema.json" ) ;
149+ } ) ;
150+
151+ Assert . That ( rve ? . Message , Does . Contain ( "Could not parse supplied JSON schema. Error:" ) ) ;
152+ }
153+
154+ /// <summary>
155+ /// A test checking that supplying an invalid JSON schema throws the expected exception.
156+ /// </summary>
157+ [ Test ]
158+ public void SupplyingNonsenseInputThrowsTheExpectedException ( )
159+ {
160+ this . CreateStubForJsonSchemaValidation ( ) ;
161+
162+ var rve = Assert . Throws < ResponseVerificationException > ( ( ) =>
163+ {
164+ Given ( )
165+ . When ( )
166+ . Get ( $ "{ MOCK_SERVER_BASE_URL } /json-schema-validation")
167+ . Then ( )
168+ . StatusCode ( 200 )
169+ . And ( )
170+ . MatchesJsonSchema ( "not-a-schema-not-a-file" ) ;
171+ } ) ;
172+
173+ Assert . That ( rve ? . Message , Does . Contain ( "Could not parse supplied JSON schema. Error:" ) ) ;
174+ }
175+
114176 /// <summary>
115177 /// A test checking that a response with an unexpected Content-Type throws the expected exception.
116178 /// </summary>
0 commit comments