示例#1
0
        public void RemoveFromTailTest()
        {
            var rnd = new Random();
            var buffer = new CircularBuffer<int>(2);

            var head = rnd.Next();
            var tail = rnd.Next();

            buffer.AddToTail(tail);
            buffer.AddToHead(head);

            Assert.That(buffer.Head, Is.EqualTo(head), "Invalid head value");
            Assert.That(buffer.Tail, Is.EqualTo(tail), "Invalid tail value");
            Assert.That(buffer.Length, Is.EqualTo(2), "Invalid Length value");

            Assert.That(buffer.RemoveFromTail(), Is.EqualTo(tail), "Step 1");
            Assert.That(buffer.RemoveFromTail(), Is.EqualTo(head), "Step 2");
            Assert.That(buffer.IsEmpty, Is.True, "Buffer should be empty");
            Assert.Throws(typeof(InvalidOperationException), () => buffer.RemoveFromTail());
        }