コード例 #1
0
        public void Queue_And_Dequeue_Values()
        {
            // assign
            var myQueue = new MyGenericQueue.MyQueue <int>();

            // act
            myQueue.Enqueue(111);
            myQueue.Enqueue(222);
            myQueue.Enqueue(333);
            myQueue.Enqueue(444);
            myQueue.Enqueue(555);

            // assert
            myQueue.Count.ShouldBe(5);

            var scratch1 = myQueue.Peek();

            scratch1.ShouldBe(111);

            var scratch2 = myQueue.Dequeue();

            scratch2.ShouldBe(111);

            var scratch3 = myQueue.Dequeue();

            scratch3.ShouldBe(222);

            myQueue.Dequeue();
            myQueue.Dequeue();

            myQueue.Count.ShouldBe(1);

            var scratch4 = myQueue.Dequeue();

            scratch4.ShouldBe(555);

            myQueue.Count.ShouldBe(0);
        }
コード例 #2
0
        public void ReturnAnArray()
        {
            // assign
            var myQueue = new MyGenericQueue.MyQueue <int>();

            // act
            myQueue.Enqueue(111);
            myQueue.Enqueue(222);
            myQueue.Enqueue(333);
            myQueue.Enqueue(444);
            myQueue.Enqueue(555);

            // assert
            myQueue.Count.ShouldBe(5);

            var myQueueArray = myQueue.ToArray();

            myQueueArray.ShouldBeOfType <int[]>();
            myQueueArray[0].ShouldBe(111);
            myQueueArray[1].ShouldBe(222);
            myQueueArray[2].ShouldBe(333);
            myQueueArray[3].ShouldBe(444);
            myQueueArray[4].ShouldBe(555);
        }