Пример #1
0
        public IEnumerable<Block> FetchForward()
        {
            Reader.BaseStream.Position = 0;

            Console.WriteLine("Fetch file#{0} {1}", Position, Name);

            var blockBuffer = new byte[Units.KILO * 4];

            while (Reader.Read(blockBuffer, 0, blockBuffer.Length) > 0)
            {
                var block = new Block(blockBuffer.ToArray());

                if (block.Records().Count == 0)
                    break;

                yield return block;
            }
        }
Пример #2
0
 public void EmptyBlockTest()
 {
     var block = new Block(new byte[] {});
     Assert.That(block.Records().Count, Is.EqualTo(0));
 }
Пример #3
0
        public void Parse_3_Records()
        {
            var layout = new byte[50];
            var idx = layout.Length - 4;

            var first = BitConverter.GetBytes(1111);
            Array.Copy(first, 0, layout, idx, 4);

            idx = idx - 4;

            var second = BitConverter.GetBytes(2222);
            Array.Copy(second, 0, layout, idx, 4);

            idx = idx - 4;

            var third = BitConverter.GetBytes(3333);
            Array.Copy(third, 0, layout, idx, 4);

            var block = new Block(layout);
            var records = block.Records();

            Assert.That(records.Count, Is.EqualTo(3));

            Assert.That(records[0], Is.EqualTo(1111));
            Assert.That(records[1], Is.EqualTo(2222));
            Assert.That(records[2], Is.EqualTo(3333));
        }