public void TestWithExtensionDataDictionary()
        {
            BasicExtensibleJsonObject input    = new BasicExtensibleJsonObject();
            BasicExtensibleJsonObject extended = input.WithExtensionData(input.ExtensionData.SetItem("property", 3));

            Assert.AreEqual(0, input.ExtensionData.Count);
            Assert.IsFalse(input.ExtensionData.ContainsKey("property"));
            Assert.AreEqual(1, extended.ExtensionData.Count);
            Assert.IsTrue(extended.ExtensionData.ContainsKey("property"));
            Assert.AreEqual(3, extended.ExtensionData["property"]);
        }
        public void TestUpdateExtensibleObject()
        {
            ExtensibleJsonObject originalObject = new BasicExtensibleJsonObject();
            Assert.IsNotNull(originalObject.ExtensionData);
            Assert.AreEqual("{}", JsonConvert.SerializeObject(originalObject, Formatting.None));

            ExtensibleJsonObject updatedObject = new BasicExtensibleJsonObject(originalObject.ExtensionData.Add("key", "value"));
            Assert.AreEqual("{\"key\":\"value\"}", JsonConvert.SerializeObject(updatedObject, Formatting.None));
            Assert.AreEqual("value", updatedObject.ExtensionData["key"]);
            Assert.AreEqual(1, updatedObject.ExtensionData.Count);

            // the original object did not change
            Assert.AreEqual(0, originalObject.ExtensionData.Count);
        }
        public void TestUpdateExtensibleObject()
        {
            ExtensibleJsonObject originalObject = new BasicExtensibleJsonObject();

            Assert.IsNotNull(originalObject.ExtensionData);
            Assert.AreEqual("{}", JsonConvert.SerializeObject(originalObject, Formatting.None));

            ExtensibleJsonObject updatedObject = new BasicExtensibleJsonObject(originalObject.ExtensionData.Add("key", "value"));

            Assert.AreEqual("{\"key\":\"value\"}", JsonConvert.SerializeObject(updatedObject, Formatting.None));
            Assert.AreEqual("value", updatedObject.ExtensionData["key"]);
            Assert.AreEqual(1, updatedObject.ExtensionData.Count);

            // the original object did not change
            Assert.AreEqual(0, originalObject.ExtensionData.Count);
        }
        public void TestWithExtensionDataNameValue()
        {
            BasicExtensibleJsonObject input    = new BasicExtensibleJsonObject().WithExtensionData("initial", 1);
            BasicExtensibleJsonObject extended = input.WithExtensionData("property", 3);

            Assert.AreEqual(1, input.ExtensionData.Count);
            Assert.IsTrue(input.ExtensionData.ContainsKey("initial"));
            Assert.IsFalse(input.ExtensionData.ContainsKey("property"));
            Assert.AreEqual(1, input.ExtensionData["initial"]);

            Assert.AreEqual(2, extended.ExtensionData.Count);
            Assert.IsTrue(extended.ExtensionData.ContainsKey("initial"));
            Assert.IsTrue(extended.ExtensionData.ContainsKey("property"));
            Assert.AreEqual(1, extended.ExtensionData["initial"]);
            Assert.AreEqual(3, extended.ExtensionData["property"]);
        }
        public void TestWithExtensionDataDictionary()
        {
            BasicExtensibleJsonObject input = new BasicExtensibleJsonObject();
            BasicExtensibleJsonObject extended = input.WithExtensionData(input.ExtensionData.SetItem("property", 3));

            Assert.AreEqual(0, input.ExtensionData.Count);
            Assert.IsFalse(input.ExtensionData.ContainsKey("property"));
            Assert.AreEqual(1, extended.ExtensionData.Count);
            Assert.IsTrue(extended.ExtensionData.ContainsKey("property"));
            Assert.AreEqual(3, extended.ExtensionData["property"]);
        }
        public void TestWithExtensionDataNameValue()
        {
            BasicExtensibleJsonObject input = new BasicExtensibleJsonObject().WithExtensionData("initial", 1);
            BasicExtensibleJsonObject extended = input.WithExtensionData("property", 3);

            Assert.AreEqual(1, input.ExtensionData.Count);
            Assert.IsTrue(input.ExtensionData.ContainsKey("initial"));
            Assert.IsFalse(input.ExtensionData.ContainsKey("property"));
            Assert.AreEqual(1, input.ExtensionData["initial"]);

            Assert.AreEqual(2, extended.ExtensionData.Count);
            Assert.IsTrue(extended.ExtensionData.ContainsKey("initial"));
            Assert.IsTrue(extended.ExtensionData.ContainsKey("property"));
            Assert.AreEqual(1, extended.ExtensionData["initial"]);
            Assert.AreEqual(3, extended.ExtensionData["property"]);
        }