Ejemplo n.º 1
0
        public object[] Queue_Clear_IsCorrect(object[] input)
        {
            CustomQueue <object> queue = new CustomQueue <object>(input);

            queue.Clear();

            return(queue.ToArray());
        }
Ejemplo n.º 2
0
        public char[] Queue_EnqueueRange_IsCorrect(char[] input)
        {
            CustomQueue <char> queue = new CustomQueue <char>(input);

            queue.EnqueueRange(new char[] { 'e', 'r', 'a' });

            return(queue.ToArray());
        }
Ejemplo n.º 3
0
        public double[] Queue_Dequeue_IsCorrect(double[] input)
        {
            CustomQueue <double> queue = new CustomQueue <double>(input);

            queue.Dequeue();

            return(queue.ToArray());
        }
Ejemplo n.º 4
0
        public void TestToArray_EmptyQueue()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            int[] arr = queue.ToArray();

            Assert.AreEqual(0, arr.Length);
        }
Ejemplo n.º 5
0
        public int[] Queue_Enqueue_IsCorrect(int[] input)
        {
            CustomQueue <int> queue = new CustomQueue <int>(input);

            queue.Enqueue(5);

            return(queue.ToArray());
        }
        public void ToArrayShouldMakeQueueToArrayNoItems()
        {
            //Arange
            var queue = new CustomQueue <int>();
            //Act
            var array = queue.ToArray();

            //Assert
            Assert.AreEqual("CustomArray`1", array.GetType().Name);
        }
Ejemplo n.º 7
0
        public void Enqueue_IntElements_EqualToResult(int[] source, int[] result)
        {
            var queue = new CustomQueue <int>();

            for (int i = 0; i < source.Length; i++)
            {
                queue.Enqueue(source[i]);
            }

            CollectionAssert.AreEqual(result, queue.ToArray());
        }
        public void EnqueueTests(IEnumerable <char> collection, char value, IEnumerable <char> expected)
        {
            // Arrange
            CustomQueue <char> queue = new CustomQueue <char>(collection);

            // Act
            queue.Enqueue(value);

            // Assert
            CollectionAssert.AreEqual(expected.ToArray(), queue.ToArray());
        }
        public void DequeueTests(IEnumerable <sbyte> collection, sbyte value, IEnumerable <sbyte> expected)
        {
            // Arrange
            CustomQueue <sbyte> queue = new CustomQueue <sbyte>(collection);

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

            // Assert
            Assert.AreEqual(value, result);
            CollectionAssert.AreEqual(expected.ToArray(), queue.ToArray());
        }
        public void EnqueueTestMethod()
        {
            var queue = new CustomQueue <int>();

            queue.Enqueue(10);
            queue.Enqueue(20);
            queue.Enqueue(30);
            queue.Enqueue(40);
            queue.Enqueue(50);
            var expected = new[] { 10, 20, 30, 40, 50 };

            var actual = queue.ToArray();

            CollectionAssert.AreEqual(expected, actual);
        }
        public void ClearTestMethod()
        {
            var queue = new CustomQueue <int>();

            queue.Enqueue(10);
            queue.Enqueue(20);
            queue.Enqueue(30);
            queue.Enqueue(40);
            queue.Enqueue(50);
            var expectedQueue = new int[] { };

            queue.Clear();
            var actualQueue = queue.ToArray();

            CollectionAssert.AreEqual(expectedQueue, actualQueue);
        }
        public void TestMethodsEnqueuDequeuPeek(int[] expectedArray, int expectedPeek)
        {
            CustomQueue<int> customQueue = new CustomQueue<int>();
            var customIter = customQueue.GetEnumerator();
            Queue<int> queue = new Queue<int>();
            customQueue.Enqueue(1);
            customQueue.Enqueue(2);
            customQueue.Enqueue(4);
            customQueue.Enqueue(8);
            customQueue.Enqueue(9);
            customQueue.Dequeue();
            Assert.AreEqual(customQueue.Peek(), expectedPeek);
            int[] array = customQueue.ToArray();
            CollectionAssert.AreEqual(expectedArray, array);

        }
Ejemplo n.º 13
0
        public void Dequeue_DeleteElements_EqualToResult(int[] source, int numDeleted, int[] result)
        {
            var queue = new CustomQueue <int>();

            for (int i = 0; i < source.Length; i++)
            {
                queue.Enqueue(source[i]);
            }

            for (int i = 0; i < numDeleted; i++)
            {
                Console.Write(queue.Dequeue() + " ");
            }

            CollectionAssert.AreEqual(result, queue.ToArray());
        }
Ejemplo n.º 14
0
        public static void Main(string[] args)
        {
            CustomQueue<int> test = new CustomQueue<int>();

            for (int i = 0; i < 10; i++)
            {
                test.Enqueue(i);
            }

            int[] teter = test.ToArray();
            test.Clear();
            foreach (var item in teter)
            {
                Console.WriteLine(item);
            }
        }
Ejemplo n.º 15
0
        public int[] Queue_CanForeach()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            queue.EnqueueRange(new int[] { 1, 2, 3 });

            int[] actual = new int[queue.Count];
            int   index  = 0;

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

            return(actual);
        }
Ejemplo n.º 16
0
        public void TestToArray_NonEmptyQueue()
        {
            CustomQueue <int> queue = new CustomQueue <int>();

            int queueCount = 10;

            for (int i = 0; i < queueCount; i++)
            {
                queue.Enqueue(i);
            }

            int[] arr = queue.ToArray();

            Assert.AreEqual(10, arr.Length);
            Assert.AreEqual(queue.Peek(), arr[0]);
            Assert.AreEqual(queue.ToString(), string.Join(string.Empty, arr));
        }
        public void ToArrayShouldMakeQueueToArrayWithItems()
        {
            //Arange
            var queue = new CustomQueue <int>();

            //Act
            queue.Enqueue(2);
            queue.Enqueue(1);
            queue.Enqueue(3);
            queue.Enqueue(4);
            var array = queue.ToArray();

            //Assert
            Assert.AreEqual(2, array[0]);
            Assert.AreEqual(1, array[1]);
            Assert.AreEqual(3, array[2]);
            Assert.AreEqual(4, array[3]);
        }
        public void PeekTestMethod()
        {
            var queue = new CustomQueue <int>();

            queue.Enqueue(10);
            queue.Enqueue(20);
            queue.Enqueue(30);
            queue.Enqueue(40);
            queue.Enqueue(50);
            var expectedItem  = 10;
            var expectedQueue = new[] { 10, 20, 30, 40, 50 };

            var actualItem  = queue.Peek();
            var actualQueue = queue.ToArray();

            bool actual = actualQueue.SequenceEqual(expectedQueue) && (actualItem == expectedItem);

            Assert.AreEqual(true, actual);
        }
        public void CustomQueue_ToArray_Int_Test()
        {
            var resultArray = new[] { 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7 };
            var customQueue = new CustomQueue <int>();

            customQueue.Enqueue(1);
            customQueue.Enqueue(2);
            customQueue.Enqueue(3);
            customQueue.Enqueue(4);
            customQueue.Enqueue(5);
            customQueue.Enqueue(6);
            customQueue.Enqueue(7);
            customQueue.Enqueue(1);
            customQueue.Enqueue(2);
            customQueue.Enqueue(3);
            customQueue.Enqueue(4);
            customQueue.Enqueue(5);
            customQueue.Enqueue(6);
            customQueue.Enqueue(7);

            CollectionAssert.AreEqual(customQueue.ToArray(), resultArray);
        }
Ejemplo n.º 20
0
        public void TestQueueToArray()
        {
            var queue         = new CustomQueue <int>();
            var array         = new int[] { 0, 3, 5, 7, 9, 11 };
            var arrayAsString = String.Empty;
            var queueAsString = String.Empty;

            foreach (var item in array)
            {
                queue.Enqueue(item);
            }
            var newArray = queue.ToArray();

            foreach (var item in array)
            {
                arrayAsString += item;
            }
            foreach (var item in newArray)
            {
                queueAsString += item;
            }
            Assert.AreEqual(arrayAsString, queueAsString);
        }
        public void CustomQueue_ToArrayTest()
        {
            CustomQueue<int> myQueue = new CustomQueue<int>();

            for (int i = 0; i < 10; i++)
            {
                myQueue.Enqueue(i);
            }

            int[] actual = myQueue.ToArray();
            int[] expected = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

            CollectionAssert.AreEqual(expected, actual);
        }