Ejemplo n.º 1
0
        public void Append_returns_index()
        {
            var layout = new byte[50];
            var block = new Block(layout);

            Assert.That(block.Append(BitConverter.GetBytes(1111)), Is.EqualTo(0));
            Assert.That(block.Append(BitConverter.GetBytes(2222)), Is.EqualTo(4));
        }
Ejemplo n.º 2
0
        public void BlockFullException_when_full()
        {
            var layout = new byte[10];
            var block = new Block(layout);

            Assert.Throws<BlockFullException>(() =>
            {
                block.Append(BitConverter.GetBytes(1111));
                block.Append(BitConverter.GetBytes(7777));
            });
        }
Ejemplo n.º 3
0
        public void Format_Payload_and_Size()
        {
            var layout = new byte[50];
            var block = new Block(layout);

            block.Append(BitConverter.GetBytes(1111));
            block.Append(Encoding.UTF8.GetBytes("hello this is very cool"));

            Assert.That(BitConverter.ToInt32(layout, 0), Is.EqualTo(1111));

            Assert.That(BitConverter.ToInt32(layout, 46), Is.EqualTo(4));
            Assert.That(BitConverter.ToInt32(layout, 42), Is.EqualTo(23));
        }
Ejemplo n.º 4
0
        public void Size_tracking()
        {
            var layout = new byte[50];
            var block = new Block(layout);

            block.Append(BitConverter.GetBytes(1111));
            block.Append(BitConverter.GetBytes(1111));

            Assert.That(BitConverter.ToInt32(layout, 42), Is.EqualTo(4));
            Assert.That(BitConverter.ToInt32(layout, 46), Is.EqualTo(4));
        }