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]; }
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); }
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); }
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); }
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); }
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); }
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"); } }
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); }