コード例 #1
0
        public void ForeachElemsTest()
        {
            var n = new ObjectNode();

            n.AddElement("a", new IntegerNode(42));
            n.AddElement("b", new StringNode("test"));

            Assert.That(n, Is.EquivalentTo(new KeyValuePair <string, INode>[] {
                new KeyValuePair <string, INode>("a", new IntegerNode(42)),
                new KeyValuePair <string, INode>("b", new StringNode("test")),
            }));
        }
コード例 #2
0
        public void ElementsModificationTest()
        {
            var n = new ObjectNode();

            Assert.AreEqual(null, n.Elems);

            // Addition
            n.AddElement("a", new IntegerNode(42));
            n.AddElement("b", new StringNode("test"));

            Assert.AreEqual(2, n.Elems.Count);

            Assert.AreEqual(new IntegerNode(42), n.Elems["a"]);
            Assert.AreEqual(new StringNode("test"), n.Elems["b"]);

            // Deletion
            n.RemoveElement("a");
            n.RemoveElement("b");
            n.RemoveElement("c"); // Do not fail if removes non-existing keys

            Assert.AreEqual(0, n.Elems.Count);
        }