public void ContainTest()
 {
     MyQueue<int> Queue = new MyArrayQueue<int>();
     Queue.Enqueue(31);
     Queue.Enqueue(9);
     Assert.AreEqual(Queue.Contains(31), true);
 }
 public void NotContainTest()
 {
     MyQueue<int> Queue = new MyArrayQueue<int>();
     Queue.Enqueue(31);
     Queue.Enqueue(9);
     Assert.AreEqual(Queue.Contains(63), false);
 }
示例#3
0
        public void Should_Check_Head_Tail_Floating()
        {
            //arrange
            var queue = new MyArrayQueue <int>();

            //act
            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Enqueue(4);
            queue.Dequeue();
            queue.Enqueue(5);

            var first  = queue.Dequeue();
            var second = queue.Dequeue();
            var third  = queue.Dequeue();
            var fourth = queue.Dequeue();

            //assert
            queue.Capacity.ShouldBeEquivalentTo(4);
            queue.Count.ShouldBeEquivalentTo(0);
            first.ShouldBeEquivalentTo(2);
            second.ShouldBeEquivalentTo(3);
            third.ShouldBeEquivalentTo(4);
            fourth.ShouldBeEquivalentTo(5);
        }
        public void NotContainTest()
        {
            MyQueue <int> Queue = new MyArrayQueue <int>();

            Queue.Enqueue(31);
            Queue.Enqueue(9);
            Assert.AreEqual(Queue.Contains(63), false);
        }
 public void CopyConstructorTest()
 {
     MyQueue<int> Queue = new MyArrayQueue<int>();
     Queue.Enqueue(1);
     Queue.Enqueue(2);
     MyQueue<int> Queue2 = new MyArrayQueue<int>(Queue);
     Assert.AreEqual(Queue2, Queue);
 }
        public void ContainTest()
        {
            MyQueue <int> Queue = new MyArrayQueue <int>();

            Queue.Enqueue(31);
            Queue.Enqueue(9);
            Assert.AreEqual(Queue.Contains(31), true);
        }
        public void PeekTest()
        {
            MyQueue <int> Queue = new MyArrayQueue <int>();

            Queue.Enqueue(98);
            Queue.Enqueue(20);
            Assert.AreEqual(Queue.Peek(), 98);
        }
        public void EnqueueDequeueTest()
        {
            MyQueue <int> Queue = new MyArrayQueue <int>();

            Queue.Enqueue(85);
            Queue.Enqueue(48);
            Assert.AreEqual(Queue.Dequeue(), 85);
            Assert.AreEqual(Queue.Dequeue(), 48);
        }
 public void ClearTest()
 {
     MyQueue<int> Queue = new MyArrayQueue<int>();
     Queue.Enqueue(1);
     Queue.Enqueue(2);
     Queue.Clear();
     Assert.AreEqual(Queue.Count, 0);
     Assert.AreEqual((Queue as MyArrayQueue<int>).Capacity, 10);
 }
        public void ClearTest()
        {
            MyQueue <int> Queue = new MyArrayQueue <int>();

            Queue.Enqueue(1);
            Queue.Enqueue(2);
            Queue.Clear();
            Assert.AreEqual(Queue.Count, 0);
            Assert.AreEqual((Queue as MyArrayQueue <int>).Capacity, 10);
        }
        public void CopyConstructorTest()
        {
            MyQueue <int> Queue = new MyArrayQueue <int>();

            Queue.Enqueue(1);
            Queue.Enqueue(2);
            MyQueue <int> Queue2 = new MyArrayQueue <int>(Queue);

            Assert.AreEqual(Queue2, Queue);
        }
        public void EnqueueMoreThanCapacityTest()
        {
            int           actualCapacity = 1;
            MyQueue <int> Queue          = new MyArrayQueue <int>(actualCapacity);

            Queue.Enqueue(70);
            Queue.Enqueue(52);
            Assert.AreEqual(Queue.Count, 2);
            Assert.AreEqual((Queue as MyArrayQueue <int>).Capacity, actualCapacity + 10);
        }
 public void CopyToArray()
 {
     int[] array = new int[2];
     MyQueue<int> Queue = new MyArrayQueue<int>();
     Queue.Enqueue(51);
     Queue.Enqueue(94);
     Queue.CopyTo(array, 0);
     Assert.AreEqual(array[0], 51);
     Assert.AreEqual(array[1], 94);
 }
        public void CopyToArray()
        {
            int[]         array = new int[2];
            MyQueue <int> Queue = new MyArrayQueue <int>();

            Queue.Enqueue(51);
            Queue.Enqueue(94);
            Queue.CopyTo(array, 0);
            Assert.AreEqual(array[0], 51);
            Assert.AreEqual(array[1], 94);
        }
        public void InvalidCopyToArray()
        {
            int[]         array = new int[2];
            MyQueue <int> Queue = new MyArrayQueue <int>();

            Queue.Enqueue(51);
            Queue.Enqueue(94);
            try
            {
                Queue.CopyTo(array, 2);
            }
            catch (IndexOutOfRangeException e)
            {
                StringAssert.Contains(e.Message, "Индекс вне диапазона.");
            }
        }
示例#16
0
        public void Should_Enqueue_With_Changed_Size()
        {
            //arrange
            var queue = new MyArrayQueue <int>();

            //act
            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Enqueue(4);
            queue.Enqueue(5);

            //assert
            queue.Count.ShouldBeEquivalentTo(5);
            queue.Capacity.ShouldBeEquivalentTo(8);
        }
示例#17
0
        public void Should_Check_Tail_Floating()
        {
            //arrange
            var queue = new MyArrayQueue <int>(1);

            //act
            queue.Enqueue(1);
            queue.Dequeue();
            queue.Enqueue(2);
            var result = queue.Dequeue();

            //assert
            result.ShouldBeEquivalentTo(2);
            queue.Count.ShouldBeEquivalentTo(0);
            queue.Capacity.ShouldBeEquivalentTo(1);
        }
示例#18
0
        public void Should_Check_Floating_Overflow_Multiple()
        {
            //arrange
            var queue = new MyArrayQueue <int>(1);

            //act
            queue.Enqueue(1);
            queue.Dequeue();
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Dequeue();
            queue.Enqueue(4);
            queue.Enqueue(5);
            queue.Enqueue(6);
            queue.Enqueue(7);
            queue.Dequeue();

            //assert
            queue.Capacity.ShouldBeEquivalentTo(8);
            queue.Count.ShouldBeEquivalentTo(4);
            queue.Dequeue().ShouldBeEquivalentTo(4);
            queue.Dequeue().ShouldBeEquivalentTo(5);
            queue.Dequeue().ShouldBeEquivalentTo(6);
            queue.Dequeue().ShouldBeEquivalentTo(7);
        }
示例#19
0
        public void Should_Dequeue_After_Enqueue()
        {
            //arrange
            var queue = new MyArrayQueue <int>();

            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);
            queue.Enqueue(4);
            queue.Enqueue(5);

            //act
            var result = queue.Dequeue();

            //assert
            result.ShouldBeEquivalentTo(1);
            queue.Capacity.ShouldBeEquivalentTo(8);
            queue.Count.ShouldBeEquivalentTo(4);
        }
示例#20
0
        public void Should_Enqueue()
        {
            //arrange
            var queue = new MyArrayQueue <int>();

            //act
            queue.Enqueue(1);

            //assert
            queue.Count.ShouldBeEquivalentTo(1);
            queue.Capacity.ShouldBeEquivalentTo(4);
        }
示例#21
0
        public void Should_Check_Is_Empty_False()
        {
            //arrange
            var queue = new MyArrayQueue <int>(1);

            queue.Enqueue(1);

            //act
            var result = queue.IsEmpty();

            //assert
            result.ShouldBeEquivalentTo(false);
        }
 public void EnqueueDequeueTest()
 {
     MyQueue<int> Queue = new MyArrayQueue<int>();
     Queue.Enqueue(85);
     Queue.Enqueue(48);
     Assert.AreEqual(Queue.Dequeue(), 85);
     Assert.AreEqual(Queue.Dequeue(), 48);
 }
 public void PeekTest()
 {
     MyQueue<int> Queue = new MyArrayQueue<int>();
     Queue.Enqueue(98);
     Queue.Enqueue(20);
     Assert.AreEqual(Queue.Peek(), 98);
 }
 public void InvalidCopyToArray()
 {
     int[] array = new int[2];
     MyQueue<int> Queue = new MyArrayQueue<int>();
     Queue.Enqueue(51);
     Queue.Enqueue(94);
     try
     {
         Queue.CopyTo(array, 2);
     }
     catch (IndexOutOfRangeException e)
     {
         StringAssert.Contains(e.Message, "Индекс вне диапазона.");
     }
 }
 public void EnqueueMoreThanCapacityTest()
 {
     int actualCapacity = 1;
     MyQueue<int> Queue = new MyArrayQueue<int>(actualCapacity);
     Queue.Enqueue(70);
     Queue.Enqueue(52);
     Assert.AreEqual(Queue.Count, 2);
     Assert.AreEqual((Queue as MyArrayQueue<int>).Capacity, actualCapacity + 10);
 }