Example #1
0
        public void RecordGetBytes()
        {
            byte[] data = new byte[1024];
            using (var record = new StdoutRecord(1))
            {
                Stream s = record.Contents;
                // Just write anything
                s.Write(data, 0, data.Length);

                int totalRecordBytes = record.GetBytes().Sum(d => d.Count);

                Assert.AreEqual(data.Length + 8 + record.PaddingLength, totalRecordBytes);
            }
        }
Example #2
0
        public void RecordGetBytesDosNotChangeContentsStreamPosition()
        {
            byte[] data = new byte[1024];
            using (var record = new StdoutRecord(1))
            {
                // Just write anything and seek to some position
                long   seekPos = 27;
                Stream s       = record.Contents;
                s.Write(data, 0, data.Length);
                s.Position = seekPos;

                int totalRecordBytes = record.GetBytes().Sum(d => d.Count);

                Assert.AreEqual(data.Length + 8 + record.PaddingLength, totalRecordBytes);
                Assert.AreEqual(seekPos, s.Position);
            }
        }