Beispiel #1
0
        public void TestShouldThrowAnExceptionWhenIndexIsOutOfRangeAfterRollOver()
        {
            LookBehindPool <byte> buf = new LookBehindPool <byte>(3);

            buf.Write(1);
            buf.Write(2);
            buf.Write(3);
            buf.Write(4);

            int errorLine = buf[3];
        }
Beispiel #2
0
        public void TestWritesShouldStoreValues()
        {
            LookBehindPool <byte> buf = new LookBehindPool <byte>(10);

            buf.Write(1);
            buf.Write(2);
            buf.Write(3);

            Assert.AreEqual(3, buf[0]);
            Assert.AreEqual(2, buf[1]);
            Assert.AreEqual(1, buf[2]);
            Assert.AreEqual(3, buf.Count);
        }
Beispiel #3
0
        public void BasicTest()
        {
            LookBehindPool <byte> buf = new LookBehindPool <byte>(10);

            buf.Write(1);
            buf.Write(2);
            buf.Write(3);

            Assert.AreEqual(3, buf[0]);
            Assert.AreEqual(2, buf[1]);
            Assert.AreEqual(1, buf[2]);
            Assert.AreEqual(3, buf.Count);
        }
Beispiel #4
0
        public void TestWriteBeyondCapacityShouldRollOver()
        {
            LookBehindPool <byte> buf = new LookBehindPool <byte>(3);

            buf.Write(1);
            buf.Write(2);
            buf.Write(3);
            buf.Write(4);

            Assert.AreEqual(4, buf[0]);
            Assert.AreEqual(3, buf[1]);
            Assert.AreEqual(2, buf[2]);
            Assert.AreEqual(3, buf.Count);

            Assert.AreEqual(4, buf.Current);
        }
Beispiel #5
0
        public void RolloverTest()
        {
            LookBehindPool <byte> buf = new LookBehindPool <byte>(3);

            buf.Write(1);
            buf.Write(2);
            buf.Write(3);
            buf.Write(4);

            Assert.AreEqual(4, buf[0]);
            Assert.AreEqual(3, buf[1]);
            Assert.AreEqual(2, buf[2]);
            Assert.AreEqual(3, buf.Count);

            Assert.AreEqual(4, buf.Current);
        }
Beispiel #6
0
        public void TestAccessToExpiredBookmarkUsingPreviousShouldThrowAnException()
        {
            LookBehindPool <byte> lbp = new LookBehindPool <byte>(3);

            lbp.Write(1);
            lbp.Write(2);
            lbp.Write(3);

            Bookmark <byte> bm = new Bookmark <byte>();

            bm.Set(lbp);

            lbp.Write(4);
            lbp.Write(5);

            Assert.AreEqual(5, lbp.Current);
            Assert.AreEqual(2, bm.Previous);
        }
Beispiel #7
0
        public void RolleOverOutOfRangeExceptionTest()
        {
            LookBehindPool <byte> buf = new LookBehindPool <byte>(3);

            buf.Write(1);
            buf.Write(2);
            buf.Write(3);
            buf.Write(4);
            try
            {
                int errorLine = buf[3];
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message == "Index out of range. Value must be from 0 to 2");
            }
        }
Beispiel #8
0
        public void TestBookmarkShouldRetainIndexReference()
        {
            LookBehindPool <byte> lbp = new LookBehindPool <byte>(10);

            lbp.Write(1);
            lbp.Write(2);
            lbp.Write(3);

            Bookmark <byte> bm = new Bookmark <byte>();

            bm.Set(lbp);

            lbp.Write(4);
            lbp.Write(5);
            lbp.Write(6);

            Assert.AreEqual(6, lbp.Current);
            Assert.AreEqual(3, bm.Current);
        }