66namespace RelogicLabs . JsonSchema ;
77
88/// <summary>
9- /// Provides assertion functionalities to validate Json document against a Schema or Json .
9+ /// Provides assertion functionalities to validate JSON document against a Schema or JSON .
1010/// </summary>
1111public class JsonAssert
1212{
1313 public RuntimeContext Runtime { get ; }
14- public IDataTree DataTree { get ; }
14+ public IDataTree ExpectedTree { get ; }
1515
1616 /// <summary>
1717 /// Initializes a new instance of the <see cref="JsonAssert"/> class for the
@@ -22,57 +22,57 @@ public JsonAssert(string schema) : this(schema, SCHEMA_TREE) { }
2222
2323 /// <summary>
2424 /// Initializes a new instance of the <see cref="JsonAssert"/> class for the
25- /// specified <paramref name="expected"/> string which can be either a Schema or a Json
25+ /// specified <paramref name="expected"/> string which can be either a Schema or a JSON
2626 /// representation.
2727 /// </summary>
28- /// <param name="expected">An expected Schema or Json string for validation or conformation.</param>
28+ /// <param name="expected">An expected Schema or JSON string for validation or conformation.</param>
2929 /// <param name="type">The type of string provided by <paramref name="expected"/>, indicating
30- /// whether it represents a Schema or Json . Use <see cref="TreeType.SCHEMA_TREE"/> for Schema
31- /// and <see cref="TreeType.JSON_TREE"/> for Json .</param>
30+ /// whether it represents a Schema or JSON . Use <see cref="TreeType.SCHEMA_TREE"/> for Schema
31+ /// and <see cref="TreeType.JSON_TREE"/> for JSON .</param>
3232 public JsonAssert ( string expected , TreeType type )
3333 {
3434 if ( type == SCHEMA_TREE )
3535 {
3636 Runtime = new RuntimeContext ( MessageFormatter . SchemaAssertion , true ) ;
37- DataTree = new SchemaTree ( Runtime , expected ) ;
37+ ExpectedTree = new SchemaTree ( Runtime , expected ) ;
3838 }
3939 else
4040 {
4141 Runtime = new RuntimeContext ( MessageFormatter . JsonAssertion , true ) ;
42- DataTree = new JsonTree ( Runtime , expected ) ;
42+ ExpectedTree = new JsonTree ( Runtime , expected ) ;
4343 }
4444 }
4545
4646 /// <summary>
47- /// Tests whether the input JSON string conforms to the Schema specified
48- /// in the <see cref="JsonAssert"/> constructor.
47+ /// Tests whether the input JSON string conforms to the expected Schema or JSON
48+ /// specified in the <see cref="JsonAssert"/> constructor.
4949 /// </summary>
50- /// <param name="jsonActual ">The actual JSON to conform or validate.</param>
51- public void IsValid ( string jsonActual )
50+ /// <param name="json ">The actual JSON to conform or validate.</param>
51+ public void IsValid ( string json )
5252 {
5353 Runtime . Clear ( ) ;
54- JsonTree jsonTree = new ( Runtime , jsonActual ) ;
55- DebugUtilities . Print ( DataTree , jsonTree ) ;
56- if ( ! DataTree . Match ( jsonTree ) )
54+ JsonTree jsonTree = new ( Runtime , json ) ;
55+ DebugUtilities . Print ( ExpectedTree , jsonTree ) ;
56+ if ( ! ExpectedTree . Match ( jsonTree ) )
5757 throw new InvalidOperationException ( "Invalid runtime state" ) ;
5858 }
5959
6060 /// <summary>
6161 /// Tests whether the specified JSON string conforms to the given Schema string
6262 /// and throws an exception if the JSON string does not conform to the Schema.
6363 /// </summary>
64- /// <param name="schemaExpected ">The expected Schema to conform or validate.</param>
65- /// <param name="jsonActual ">The actual JSON to conform or validate.</param>
66- public static void IsValid ( string schemaExpected , string jsonActual )
67- => new JsonAssert ( schemaExpected ) . IsValid ( jsonActual ) ;
64+ /// <param name="schema ">The expected Schema to conform or validate.</param>
65+ /// <param name="json ">The actual JSON to conform or validate.</param>
66+ public static void IsValid ( string schema , string json )
67+ => new JsonAssert ( schema ) . IsValid ( json ) ;
6868
6969 /// <summary>
7070 /// Tests if the provided JSON strings are logically equivalent, meaning their structural
7171 /// composition and internal data are identical. If the JSON strings are not equivalent,
7272 /// an exception is thrown.
7373 /// </summary>
74- /// <param name="jsonExpected ">The expected JSON to compare.</param>
75- /// <param name="jsonActual ">The actual JSON to compare.</param>
76- public static void AreEqual ( string jsonExpected , string jsonActual )
77- => new JsonAssert ( jsonExpected , JSON_TREE ) . IsValid ( jsonActual ) ;
74+ /// <param name="expected ">The expected JSON to compare.</param>
75+ /// <param name="actual ">The actual JSON to compare.</param>
76+ public static void AreEqual ( string expected , string actual )
77+ => new JsonAssert ( expected , JSON_TREE ) . IsValid ( actual ) ;
7878}
0 commit comments