public void ReadJsonTest()
        {
            const string json = "{\"test1\":\"value1\",\"test2\":\"value2\"}}";
            AttributesTableConverter target = new AttributesTableConverter();
            using (JsonTextReader reader = new JsonTextReader(new StringReader(json)))
            {
                JsonSerializer serializer = new JsonSerializer();

                // read start object token and prepare the next token
                reader.Read();
                AttributesTable result =
                    (AttributesTable)
                    target.ReadJson(reader, typeof(AttributesTable), new AttributesTable(), serializer);
                Assert.IsNotNull(result);
                Assert.AreEqual(2, result.Count);
                Assert.AreEqual("value1", result["test1"]);
                Assert.AreEqual("value2", result["test2"]);
            }
        }
        public void ReadJsonWithInnerObjectTest()
        {
            const string json = "{\"properties\":{\"test1\":\"value1\",\"test2\": { \"innertest1\":\"innervalue1\" }}}";
            AttributesTableConverter target = new AttributesTableConverter();
            using (JsonTextReader reader = new JsonTextReader(new StringReader(json)))
            {
                JsonSerializer serializer = new JsonSerializer();

                // read start object token and prepare the next token
                reader.Read();
                reader.Read();
                AttributesTable result =
                    (AttributesTable)
                    target.ReadJson(reader, typeof(AttributesTable), new AttributesTable(), serializer);
                Assert.IsFalse(reader.Read()); // read the end of object and ensure there are no more tokens available
                Assert.IsNotNull(result);
                Assert.AreEqual(2, result.Count);
                Assert.AreEqual("value1", result["test1"]);
                Assert.IsNotNull(result["test2"]);
                Assert.IsInstanceOf<IAttributesTable>(result["test2"]);
                IAttributesTable inner = (IAttributesTable)result["test2"];
                Assert.AreEqual(1, inner.Count);
                Assert.AreEqual("innervalue1", inner["innertest1"]);
            }
        }
        public void ReadJsonWithArrayWithNestedArrayTest()
        {
            const string json = "{\"test1\":\"value1\",\"test2\": [{ \"innertest1\":\"innervalue1\" }, [{ \"innertest2\":\"innervalue2\", \"innertest3\":\"innervalue3\"}]]}}";
            AttributesTableConverter target = new AttributesTableConverter();
            using (JsonTextReader reader = new JsonTextReader(new StringReader(json)))
            {
                JsonSerializer serializer = new JsonSerializer();

                // read start object token and prepare the next token
                reader.Read();
                AttributesTable result =
                    (AttributesTable)
                        target.ReadJson(reader, typeof (AttributesTable), new AttributesTable(), serializer);
                Assert.IsNotNull(result);
                Assert.AreEqual(2, result.Count);
                Assert.AreEqual("value1", result["test1"]);
                Assert.IsNotNull(result["test2"]);
                Assert.IsInstanceOf<IList<object>>(result["test2"]);
                IList<object> list = (IList<object>) result["test2"];
                Assert.IsNotEmpty(list);
                Assert.AreEqual(2, list.Count);
                Assert.IsInstanceOf<IAttributesTable>(list[0]);
                Assert.IsInstanceOf<IList<object>>(list[1]);
                IAttributesTable first = (IAttributesTable) list[0];
                Assert.AreEqual(1, first.Count);
                Assert.IsTrue(first.Exists("innertest1"));
                Assert.AreEqual("innervalue1", first["innertest1"]);
                IList<object> innerList = (IList<object>) list[1];
                Assert.IsNotNull(innerList);
                Assert.IsNotEmpty(innerList);
                Assert.AreEqual(1, innerList.Count);
                Assert.IsInstanceOf<IAttributesTable>(innerList[0]);
                IAttributesTable inner = (IAttributesTable) innerList[0];
                Assert.AreEqual(2, inner.Count);
                Assert.IsTrue(inner.Exists("innertest2"));
                Assert.AreEqual("innervalue2", inner["innertest2"]);
                Assert.IsTrue(inner.Exists("innertest3"));
                Assert.AreEqual("innervalue3", inner["innertest3"]);
            }
        }