예제 #1
0
        public void should_throw_when_dequeue_from_empty()
        {
            IQueue <int> queue = new Services.Queue <int>();

            Action act = () => queue.Dequeue();

            act.Should().Throw <InvalidOperationException>();
        }
예제 #2
0
        public void should_still_contain_items_after_trydequeue()
        {
            IQueue <int> queue = new Services.Queue <int>();

            queue.Enqueue(321);

            int dequeueped;

            queue.TryDequeue(out dequeueped);

            Action act = () => queue.Dequeue();

            act.Should().NotThrow();
        }
예제 #3
0
        public void should_be_empty_after_dequeueing_all_items()
        {
            IQueue <string> queue = new Services.Queue <string>();

            var items = new[] { "Alpha", "Bravo", "Charlie", "Delta" };

            foreach (string s in items)
            {
                queue.Enqueue(s);
            }

            for (int i = 0; i < items.Length; i++)
            {
                queue.Dequeue();
            }

            queue.Invoking(q => q.Dequeue()).Should().Throw <InvalidOperationException>();
        }
예제 #4
0
        public void should_dequeue_items_correctly(int itemCount)
        {
            IQueue <int> queue = new Services.Queue <int>();

            int[] range    = Enumerable.Range(1, itemCount).ToArray();
            int[] expected = range;

            foreach (int i in range)
            {
                queue.Enqueue(i);
            }

            var actual = new int[range.Length];
            int index  = 0;

            foreach (int i in range)
            {
                actual[index++] = queue.Dequeue();
            }

            actual.Should().BeEquivalentTo(expected);
        }