Beispiel #1
0
        public virtual void TestFull()
        {
            SinkQueue <int> q = new SinkQueue <int>(1);

            q.Enqueue(1);
            Assert.True("should drop", !q.Enqueue(2));
            Assert.Equal("element", 1, (int)q.Dequeue());
            q.Enqueue(3);
            q.Consume(new _Consumer_114());
            Assert.Equal("queue size", 0, q.Size());
        }
Beispiel #2
0
        public virtual void TestCommon()
        {
            SinkQueue <int> q = new SinkQueue <int>(2);

            q.Enqueue(1);
            Assert.Equal("queue front", 1, (int)q.Front());
            Assert.Equal("queue back", 1, (int)q.Back());
            Assert.Equal("element", 1, (int)q.Dequeue());
            Assert.True("should enqueue", q.Enqueue(2));
            q.Consume(new _Consumer_50());
            Assert.True("should enqueue", q.Enqueue(3));
            Assert.Equal("element", 3, (int)q.Dequeue());
            Assert.Equal("queue size", 0, q.Size());
            Assert.Equal("queue front", null, q.Front());
            Assert.Equal("queue back", null, q.Back());
        }
Beispiel #3
0
        public virtual void TestConsumerException()
        {
            SinkQueue <int>  q  = new SinkQueue <int>(1);
            RuntimeException ex = new RuntimeException("expected");

            q.Enqueue(1);
            try
            {
                q.Consume(new _Consumer_157(ex));
            }
            catch (Exception expected)
            {
                NUnit.Framework.Assert.AreSame("consumer exception", ex, expected);
            }
            // The queue should be in consistent state after exception
            Assert.Equal("queue size", 1, q.Size());
            Assert.Equal("element", 1, (int)q.Dequeue());
        }