Exemplo n.º 1
0
    public void ReadAll(Stream framedStream)
    {
        framedStream.Length.Returns(10);
        framedStream.Position = 0;
        var       frame  = new FramedStream(framedStream, 6, doDispose: false);
        const int offset = 5;

        byte[] b = new byte[10];
        frame.Read(b, offset, (int)frame.Length);
        framedStream.Received(1).Read(b, offset, (int)frame.Length);
    }
Exemplo n.º 2
0
    public void ReadOutOfRange()
    {
        byte[] bufIn = new byte[10];
        for (byte i = 0; i < 10; i++)
        {
            bufIn[i] = i;
        }

        var framedStream = new MemoryStream(bufIn);
        var frame        = new FramedStream(framedStream, 6, doDispose: false);

        byte[] buf = new byte[100];
        frame.Read(buf, 0, 7)
        .Should().Be(6);
        for (byte i = 0; i < 6; i++)
        {
            buf[i].Should().Be(i);
        }

        for (int i = 6; i < 100; i++)
        {
            buf[i].Should().Be(0);
        }
    }
Exemplo n.º 3
0
 public DataSectionData( SectionHeader header, FramedStream stream )
 {
     Value = new byte[ header.Size ];
     stream.Read( Value, 0, (int) header.Size );
 }
Exemplo n.º 4
0
 public DataSectionData(SectionHeader header, FramedStream stream)
 {
     Value = new byte[header.Size];
     stream.Read(Value, 0, (int)header.Size);
 }