예제 #1
0
        public void Test_Single_Size_Circular_Buffer()
        {
            var ringBuffer = new CircularFifoBuffer <byte>(1);

            for (var i = 0; i < 100; i++)
            {
                ringBuffer.Write(GetBytes("ABC"));
                Assert.AreEqual("C", GetString(ringBuffer.ReadToArray()));
                ringBuffer.Write(GetBytes("D"));
                Assert.AreEqual("D", GetString(ringBuffer.ReadToArray()));
            }
        }
예제 #2
0
        public void Test_Circular_Massive2B()
        {
            var ringBuffer = new CircularFifoBuffer <byte>(5);

            ringBuffer.Write(GetBytes("ABC"));
            Assert.AreEqual("ABC", GetString(ringBuffer.ReadToArray()));

            ringBuffer.Write(GetBytes("ABC"));
            ringBuffer.Write(GetBytes("DE"));
            ringBuffer.Write(GetBytes("123456789"));

            Assert.AreEqual("56789", GetString(ringBuffer.ReadToArray()));
        }
예제 #3
0
        public void Test_Circular_FirstItem()
        {
            var ringBuffer = new CircularFifoBuffer <byte>(5);

            ringBuffer.Write(GetBytes("ABCDEFG"));

            Assert.AreEqual("CDEFG", GetString(ringBuffer.ReadToArray()));
        }
예제 #4
0
        public void Test_Circular_FirstItem()
        {
            var ringBuffer = new CircularFifoBuffer<byte>(5);

            ringBuffer.Write(GetBytes("ABCDEFG"));

            Assert.AreEqual("CDEFG", GetString(ringBuffer.ReadToArray()));
        }
예제 #5
0
        public void Test_Circular1()
        {
            var ringBuffer = new CircularFifoBuffer <byte>(5);

            ringBuffer.Write(GetBytes("ABC"));
            ringBuffer.Write(GetBytes("DE"));
            ringBuffer.Write(GetBytes("F"));

            Assert.AreEqual("BCDEF", GetString(ringBuffer.ReadToArray()));
        }
예제 #6
0
        public void Test_Circular1()
        {
            var ringBuffer = new CircularFifoBuffer<byte>(5);

            ringBuffer.Write(GetBytes("ABC"));
            ringBuffer.Write(GetBytes("DE"));
            ringBuffer.Write(GetBytes("F"));

            Assert.AreEqual("BCDEF", GetString(ringBuffer.ReadToArray()));
        }
예제 #7
0
        public void Test_Circular_Massive1A()
        {
            var ringBuffer = new CircularFifoBuffer<byte>(5);

            ringBuffer.Write(GetBytes("ABC"));
            Assert.AreEqual("ABC", GetString(ringBuffer.ReadToArray()));

            ringBuffer.Write(GetBytes("ABC"));
            ringBuffer.Write(GetBytes("DE"));
            ringBuffer.Write(GetBytes("1234567890"));

            Assert.AreEqual("67890", GetString(ringBuffer.ReadToArray()));
        }
예제 #8
0
        public void Test_Single_Size_Circular_Buffer()
        {
            var ringBuffer = new CircularFifoBuffer<byte>(1);

            for (var i = 0; i < 100; i++)
            {
                ringBuffer.Write(GetBytes("ABC"));
                Assert.AreEqual("C", GetString(ringBuffer.ReadToArray()));
                ringBuffer.Write(GetBytes("D"));
                Assert.AreEqual("D", GetString(ringBuffer.ReadToArray()));
            }
        }