示例#1
0
        public void WriteArray()
        {
            int[] array = new int[] { 1, 2, 3, 4, 5 };
            Dom   dom   = Dom.Serialise(array);

            Assert.IsInstanceOfType(dom.Root.GetNode(), typeof(Dom.ListNode));

            Dom.ListNode node = dom.Root.GetNode() as Dom.ListNode;

            Assert.AreEqual(typeof(int[]), node.Type);

            Assert.AreEqual(array.Length, node.Children.Count);
            for (int i = 0; i < array.Length; i++)
            {
                Assert.AreEqual(typeof(int), node.Children[i].GetNode().Type);
                Assert.AreEqual(string.Format("{0}", array[i]), (node.Children[i].GetNode() as Dom.LiteralNode).Value);
            }
        }
示例#2
0
        public void WriteList()
        {
            List <int> list = new List <int>()
            {
                1, 2, 3, 4, 5
            };
            Dom dom = Dom.Serialise(list);

            Assert.IsInstanceOfType(dom.Root.GetNode(), typeof(Dom.ListNode));

            Dom.ListNode node = dom.Root.GetNode() as Dom.ListNode;

            Assert.AreEqual(typeof(List <int>), node.Type);

            Assert.AreEqual(list.Count, node.Children.Count);
            for (int i = 0; i < list.Count; i++)
            {
                Assert.AreEqual(typeof(int), node.Children[i].GetNode().Type);
                Assert.AreEqual(string.Format("{0}", list[i]), (node.Children[i].GetNode() as Dom.LiteralNode).Value);
            }
        }