示例#1
0
        public void bytebuf_base_return_test()
        {
            IByteBuf buf = new AbstructByteBuf(4);

            buf.SetOffset(1).WriteByte(1).ReadByte();

            Assert.AreEqual(buf.Offset, 1);
            Assert.AreEqual(buf.ReadIndex, 2);
            Assert.AreEqual(buf.WriteIndex, 2);
            Assert.AreEqual(buf.Readables(), 0);
            Assert.AreEqual(buf.Writeables(), 2);
            Assert.AreEqual(buf.Capacity, 3);

            buf.Return();

            Assert.AreEqual(buf.Offset, 0);
            Assert.AreEqual(buf.ReadIndex, 0);
            Assert.AreEqual(buf.WriteIndex, 0);
            Assert.AreEqual(buf.Readables(), 0);
            Assert.AreEqual(buf.Writeables(), 0);
            Assert.AreEqual(buf.Capacity, 0);
            Assert.AreEqual(buf.GetBytes(), AbstructByteBuf.Emtpy);
        }