Exemple #1
0
        public static void TestCloneJsonArray()
        {
            var jsonArray = new JsonArray {
                "value1", "value2"
            };
            var jsonArrayCopy = jsonArray.Clone() as JsonArray;

            Assert.Equal(2, jsonArrayCopy.Count);
            jsonArray.Add("value3");
            Assert.Equal(2, jsonArrayCopy.Count);
        }
Exemple #2
0
        public static void TestDeepCloneJsonArray()
        {
            JsonArray inner = new JsonArray {
                1, 2, 3
            };
            JsonArray outer = new JsonArray {
                inner
            };
            JsonArray outerClone = (JsonArray)outer.Clone();

            ((JsonArray)outerClone[0]).Add(4);

            Assert.Equal(3, inner.Count);
        }