Example #1
0
        public void Push_MoreThanCapacity_False()
        {
            var buffer = new AgentWriterBuffer <int>(100);

            for (int i = 0; i < 100; i++)
            {
                Assert.True(buffer.Push(i));
            }

            Assert.False(buffer.Push(101));

            // Check that one random element of the queue was replaced
            var vals     = buffer.Pop();
            var replaced = 0;

            for (int i = 0; i < 100; i++)
            {
                if (vals[i] != i)
                {
                    replaced++;
                }
            }

            Assert.Equal(1, replaced);
        }
Example #2
0
        public void Pop_Empty_Empty()
        {
            var buffer = new AgentWriterBuffer <int>(100);
            var vals   = buffer.Pop();

            Assert.False(vals.Any());
        }
Example #3
0
        public void PushPop_1ElementIn_1ElementOut()
        {
            var buffer = new AgentWriterBuffer <int>(100);

            buffer.Push(42);
            var vals = buffer.Pop();

            Assert.Equal(42, vals.Single());
        }