/// <summary>
        /// Runs the test by reading both payloads - one with the reordering reader 
        /// the other with the regular reader and comparing the results.
        /// </summary>
        public void RunTest()
        {
            using (TextReader expectedJsonTextReader = new StringReader(this.ExpectedJsonText))
            using (TextReader jsonTextReader = new StringReader(this.JsonText))
            {
                JsonReader expectedJsonReader = new JsonReader(expectedJsonTextReader, this.assert, ODataFormat.Json, isIeee754Compatible: true);
                ReorderingJsonReader reorderingJsonReader = new ReorderingJsonReader(jsonTextReader, /*maxInnerErrorDepth*/int.MaxValue, this.assert, isIeee754Compatible: true);

                while (reorderingJsonReader.Read())
                {
                    this.assert.IsTrue(expectedJsonReader.Read(), "Reordering Json reader reports more nodes than the regular one.");
                    this.assert.AreEqual(expectedJsonReader.NodeType, reorderingJsonReader.NodeType, "Node types don't match.");
                    this.assert.AreEqual(expectedJsonReader.Value, reorderingJsonReader.Value, "Values don't match.");
                }

                this.assert.IsFalse(expectedJsonReader.Read(), "Reordering Json reader reports less nodes than the regular one.");
            }
        }
Beispiel #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="reader">The JsonReader to use.</param>
 /// <param name="assert">The assertion handler for validation.</param>
 public JsonToObjectModelReader(JsonReader reader, AssertionHandler assert)
 {
     this.reader = reader;
     this.assert = assert;
 }
Beispiel #3
0
 /// <summary>
 /// Using JsonReader reads the specified <paramref name="textReader"/> input and returns a JSON OM.
 /// </summary>
 /// <param name="jsonReader">The JSON reader to read from.</param>
 /// <param name="assert">Assertion handler to use for validation.</param>
 /// <returns>The input read into a JSON OM using the JsonReader from the product.</returns>
 public static JsonValue ReadJson(JsonReader jsonReader, AssertionHandler assert)
 {
     JsonToObjectModelReader omReader = new JsonToObjectModelReader(jsonReader, assert);
     return omReader.ReadValue();
 }