示例#1
0
        public void MergeJConstructor()
        {
            JConstructor c1 = new JConstructor("c1", new[] { 1, 2 });
            JConstructor c2 = new JConstructor("c2", new[] { 3, 4 });

            c1.Merge(c2);
            Assert.AreEqual("c2", c1.Name);
            CollectionAssert.AreEquivalent(new[] { 1, 2, 3, 4 }, c1.Select(i => (int)i));

            JConstructor c3 = new JConstructor();

            c1.Merge(c3);
            Assert.AreEqual("c2", c1.Name);

            JConstructor c4 = new JConstructor("c4", new[] { 5, 6 });

            c1.Merge(c4, new JsonMergeSettings {
                MergeArrayHandling = MergeArrayHandling.Replace
            });
            Assert.AreEqual("c4", c1.Name);
            CollectionAssert.AreEquivalent(new[] { 5, 6 }, c1.Select(i => (int)i));
        }
示例#2
0
文件: MergeTests.cs 项目: zjsxzst/P2P
        public void MergeNull()
        {
            JConstructor c = new JConstructor();

            c.Merge(null);
            Assert.AreEqual(null, c.Name);
            Assert.AreEqual(0, c.Count);

            JObject o = new JObject();

            o.Merge(null);
            Assert.AreEqual(0, o.Count);

            JArray a = new JArray();

            a.Merge(null);
            Assert.AreEqual(0, a.Count);

            JProperty p = new JProperty("name1");

            p.Merge(null);
            Assert.AreEqual("name1", p.Name);
            Assert.AreEqual(0, p.Count);
        }