Inheritance: NodeBase
Exemplo n.º 1
0
 public void should_encode_csv()
 {
     var file = new FileNode(NodeType.Array, 
         typeof(List<Record>), Options.Create(x => 
         x.IncludePublicFields()));
     var row = new RowNode(1)
     {
         { new ValueNode("Property", "oh,"), x => {} },
         { new ValueNode("Field", "\"hai\""), x => {} },
         { new ValueNode("Null"), x => {} }
     };
     file.Add(row, x => {});
     file.EncodeToString().ShouldEqual(Data);
 }
Exemplo n.º 2
0
        public void should_parse_csv()
        {
            var fileNode = new FileNode(new MemoryStream(
                Encoding.ASCII.GetBytes(Data)), Options.Create());

            fileNode.NodeType.ShouldEqual(NodeType.Array);
            var rowNodes = fileNode.ToList();
            rowNodes.Count.ShouldEqual(1);
            var rowNode = rowNodes.First();
            rowNode.NodeType.ShouldEqual(NodeType.Object);
            var rowValues = rowNode.ToList();
            rowValues.Count.ShouldEqual(3);
            var rowValue = rowValues[0];
            rowValue.NodeType.ShouldEqual(NodeType.Value);
            rowValue.Value.ShouldEqual("oh,");
            rowValue = rowValues[1];
            rowValue.NodeType.ShouldEqual(NodeType.Value);
            rowValue.Value.ShouldEqual("");
            rowValue = rowValues[2];
            rowValue.NodeType.ShouldEqual(NodeType.Value);
            rowValue.Value.ShouldEqual("\"hai\"");
        }