static void TestInt() {
     var yw=new YAMLWalker(null);
     var nodes=yw.Walk("root",1);
     Is(nodes.Count,1);
     var node=nodes[0];
     Is(node.O,1);
 }
Beispiel #2
0
        public TextWriter Write(object o)
        {
            var walker = new YAMLWalker(BBD);

            List = walker.Walk(null, o);
            WriteLine(0, "---");
            WriteValue(0);
            WriteLine(0, "...");
            return(Lw.Tw);
        }
 public TextWriter Write(object o) {
     var walker=new YAMLWalker(BBD);
     List=walker.Walk(null,o);
     WriteLine(0,"---");
     WriteValue(0);
     WriteLine(0,"...");
     return Lw.Tw;
 }
 static void TestDic() {
     var dic=new Dictionary<string,int>(){{"b",1},{"a",2}};
     var yw=new YAMLWalker(null);
     var nodes=yw.Walk(null,dic);
     IsDeeply(from x in nodes select x.Key,new []{null,"a","b"});
     IsDeeply((from x in nodes select x.O).Skip(1),new object[]{2,1});
 }
 static void TestNullEnumerator() {
     var yw=new YAMLWalker(null);
     var nodes=yw.Walk("root",new[]{"a",null,"b"});
     IsDeeply(from x in nodes select x.Key,new []{"root",null,null,null});
     IsDeeply((from x in nodes select x.O).Skip(1),new object[]{"a",null,"b"});
 }
 static void TestNullField() {
     var yw=new YAMLWalker(null);
     var nodes=yw.Walk("root",new A());
     IsDeeply(from x in nodes select x.Key,new []{"root","otherA"});
     IsDeeply((from x in nodes select x.O).Skip(1),new object[]{null});
 }
 static void TestFields() {
     var yw=new YAMLWalker(null);
     var nodes=yw.Walk("root",new Fields());
     IsDeeply(from x in nodes select x.Key,new []{"root","a","b","n"});
     IsDeeply((from x in nodes select x.O).Skip(1),new object[]{1,"Sally",Fields.Numbers.two});
 }
 static void TestTightCycle() {
     var yw=new YAMLWalker(null);
     A a=new A();
     a.otherA=a;
     var nodes=yw.Walk("root",a);
     IsDeeply(from x in nodes select x.Key,new []{"root","otherA"});
     IsDeeply(from x in nodes select x.Depth,new []{0,1});
     IsDeeply(from x in nodes select x.Ref,new []{-1,0});
     IsDeeply(from x in nodes select x.Flags,new []{YNode.Flag.ReferredTo|YNode.Flag.Dic,YNode.Flag.Dic});
     //DumpNodes(nodes);
 }
 static void TestRef() {
     var a=new Fields(2);
     var dic=new Dictionary<string,Fields>(){{"b",a},{"a",a}};
     var yw=new YAMLWalker(null);
     var nodes=yw.Walk("root",dic);
     IsDeeply(from x in nodes where x.Depth==1 select x.Flags,new []{YNode.Flag.ReferredTo|YNode.Flag.Dic,YNode.Flag.Dic});
     IsDeeply(from x in nodes where x.Depth<=1 select x.Key,new []{"root","a","b"});
     IsDeeply(from x in nodes where x.Depth==1 select x.O,new []{a,a});
     IsDeeply(from x in nodes where x.Depth==1 select x.Ref,new []{-1,1});
     // the fields of a appear after a
     Is(nodes[2].Depth,2);
     // the fields of a appear only once
     IsDeeply((from x in nodes where x.Depth==2 select x.O),new object[]{2,"Sally",Fields.Numbers.two});
     //DumpNodes(nodes);
 }
Beispiel #10
0
 static void TestDicField() {
     var b=new Fields(1);
     var a=new Fields(2);
     var dic=new Dictionary<string,Fields>(){{"b",b},{"a",a}};
     var yw=new YAMLWalker(null);
     var nodes=yw.Walk("root",dic);
     IsDeeply(from x in nodes where x.Depth<=1 select x.Key,new []{"root","a","b"});
     IsDeeply((from x in nodes where x.Depth==1 select x.O),new object[]{a,b});
     IsDeeply((from x in nodes where x.Depth==2 select x.O),new object[]{
             2,"Sally",Fields.Numbers.two,1,"Sally",Fields.Numbers.two});
     //DumpNodes(yw);
 }