コード例 #1
0
        public void document()
        {
            PropertyTreeNodeWriter writer = new PropertyTreeNodeWriter();
            writer.WriteStartDocument();
            writer.WriteStartTree("hello");
            writer.WriteStartTree("george");
            writer.WriteEndTree();
            writer.WriteEndTree();
            writer.WriteEndDocument();

            Assert.That(writer.Root.Name, Is.EqualTo("hello"));
            Assert.That(writer.Root.Children.Count, Is.EqualTo(1));
            Assert.That(writer.Root.Children[0].Name, Is.EqualTo("george"));
            Assert.That(writer.Root.Children["george"], Is.Not.Null);
            Assert.That(writer.Root["george"], Is.Not.Null);
        }
コード例 #2
0
        public void document3()
        {
            PropertyTreeNodeWriter writer = new PropertyTreeNodeWriter();
            writer.WriteStartDocument();
            writer.WriteStartTree("hello");

            writer.WriteStartProperty("george");
            writer.WritePropertyValue("burdell");
            writer.WriteEndProperty();

            writer.WriteStartProperty("buzz");
            writer.WritePropertyValue("234");
            writer.WriteEndProperty();

            writer.WriteProperty("hey", "arnold");

            writer.WriteEndTree();
            writer.WriteEndDocument();

            Assert.That(writer.Root.Children.Count, Is.EqualTo(3));
            Assert.That(writer.Root.Children.Select(t => t.Name).ToArray(), Is.EquivalentTo(new [] { "george", "buzz", "hey" }));
            Assert.That(writer.Root.Children["buzz"], Is.Not.Null);
            Assert.That(writer.Root["buzz"], Is.Not.Null);
        }