Beispiel #1
0
 public void T15_Sequence_Nested_BER_Stream_IO()
 {
     using (var stream = new MemoryStream()) {
         var x      = new X690.Sequence();
         var s      = new X690.Sequence();
         var leaves = new X690.Node[] {
             new X690.Null(),
             new X690.Boolean(false),
             new X690.Boolean(true),
             new X690.Integer(-1),
             new X690.Integer(0),
             new X690.Integer(1),
             new X690.Text("WOOF!")
             {
                 IsDefiniteLength = false
             },
             new X690.Text("GRR.."),
             new X690.Text("WOOF!")
             {
                 IsDefiniteLength = false
             },
             new X690.Sequence()
         };
         foreach (var leaf in leaves)
         {
             s.Nodes.Add(leaf);
         }
         x.Nodes.Add(s);
         x.Write(stream);
         stream.Position = 0;
         TT.Peek(x, stream);
         var y = X690.Read(stream);
         Assert.Equal(x, y);
     }
 }
Beispiel #2
0
    public void T16_Sequence_Nested_BER_Buffered_IO()
    {
        var buffer = new byte[64];
        var x      = new X690.Sequence();
        var s      = new X690.Sequence();
        var leaves = new X690.Node[] {
            new X690.Null(),
            new X690.Boolean(false),
            new X690.Boolean(true),
            new X690.Integer(-1),
            new X690.Integer(0),
            new X690.Integer(1),
            new X690.Text("WOOF!")
            {
                IsDefiniteLength = false
            },
            new X690.Text("GRR.."),
            new X690.Text("WOOF!")
            {
                IsDefiniteLength = false
            },
            new X690.Sequence()
        };

        foreach (var leaf in leaves)
        {
            s.Nodes.Add(leaf);
        }
        x.Nodes.Add(s);
        var length = x.Write(buffer, 0);

        TT.Peek(x, buffer, length);
        var y = X690.Read(buffer, 0, length);

        Assert.Equal(x, y);
    }