void Add5Elemenets(RingBuffer <int> rb) { rb.Add(1); rb.Add(2); rb.Add(3); rb.Add(4); rb.Add(5); }
public void RingBuffer_Count() { var rb = new RingBuffer <int>(5, RingOverflowBehavior.ThrowException); rb.Add(1); rb.Add(2); Assert.AreEqual(rb.Count, 2); }
public void RingBuffer_PeekHead_Peeks() { var rb = new RingBuffer <int>(5, RingOverflowBehavior.ThrowException); rb.Add(1); rb.Add(2); int head = rb.PeekHead; Assert.AreEqual(head, 1); string memoryLayout = rb.ToString(); Assert.AreEqual("1,2,0,0,0", memoryLayout); }
public void RingBuffer_ThrowException_Throws() { var rb = new RingBuffer <int>(5, RingOverflowBehavior.ThrowException); Add5Elemenets(rb); Assert.Catch <System.OverflowException>(() => rb.Add(6)); }
public void RingBuffer_OverrideHeadAndContinue_DoesOverride() { var rb = new RingBuffer <int>(5, RingOverflowBehavior.OverrideHeadAndContinue); Add6ELements(rb); rb.Add(7); string memoryLayout = rb.ToString(); Assert.AreEqual("6,7,3,4,5", memoryLayout); }
void Add6ELements(RingBuffer <int> rb) { Add5Elemenets(rb); rb.Add(6); }