Ejemplo n.º 1
0
        public void QueueTest_Adding3Elements_QueueHas3Element()
        {
            QueueT <int> qeue = new QueueT <int>(1);

            qeue.Enqueue(1);
            qeue.Enqueue(3);
            qeue.Enqueue(3);

            Assert.AreEqual(3, qeue.Count());
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //1
            //int[] arr = {1,2,5,9,11,55,88,99,152,158,178,199};
            //int element = 152;
            //var index = BinaryGenericSearch.Exec(arr.ToList(),152);
            //System.Console.WriteLine("Элемент {0} находится после позиции {1}",element,index);
            //2
            //string fname = "10.2.SilkRoads1.txt";
            //Dictionary<string, int> result = FrequencyWords.Exec(fname);
            //foreach (var i in result) Console.WriteLine("Word: {0,-20}Freq: {1}", i.Key, i.Value);
            //3
            //int fibNumbers = 0;
            //var sum = Fibonacci.Calc(fibNumbers);
            //Console.WriteLine("Sequence of {0} Fibonacci's numbers is: ", fibNumbers);
            //foreach (var i in sum) Console.Write(i + " ");
            //Console.ReadKey();

            //4
            QueueT <int> myQueue = new QueueT <int>();

            for (int i = 1; i < 5; i++)
            {
                myQueue.Enqueue(i);
            }
            myQueue.Dequeue();
            myQueue.Enqueue(6);
            myQueue.Dequeue();

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

            //7
            //var bst = new BST<int>();

            //bst.Add(1);
            //bst.Add(2);
            //bst.Add(3);
            //bst.Add(4);
            //bst.Add(5);
            //bst.Remove(2);
            //var result = bst.PreOrder().ToArray();
            //8

            //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            //string rpn = "5 1 2 + 4 * + 3 - ";
            //Console.WriteLine("\n{0}", rpn);
            //decimal result1 = RPMCalc.CalculateRPN(rpn);
            //Console.WriteLine("Result is {0}", result1);
            //Console.ReadKey();
        }
Ejemplo n.º 3
0
        public void EnumeratorTest()
        {
            //arrange
            var enumTest = new QueueT <string>();

            //act
            enumTest.Enqueue("First");
            enumTest.Enqueue("Second");
            enumTest.Enqueue("Third");

            //assert
            Assert.AreEqual("First", enumTest.Dequeue());
            Assert.AreEqual("Second", enumTest.Dequeue());
        }
Ejemplo n.º 4
0
        public void QueueTStrTests()
        {
            //arrange
            var myqueue = new QueueT <string>();

            //act
            myqueue.Enqueue("0");
            myqueue.Enqueue("1");
            myqueue.Enqueue("2");

            //assert
            Assert.AreEqual("0", myqueue.Dequeue());
            Assert.AreEqual("1", myqueue.Dequeue());
            Assert.AreEqual("2", myqueue.Dequeue());
            Assert.AreEqual(0, myqueue.Count());
        }
Ejemplo n.º 5
0
        public void QueueTIntTests()
        {
            //arrange
            var myqueue = new QueueT <int>();

            //act
            myqueue.Enqueue(0);
            myqueue.Enqueue(1);
            myqueue.Enqueue(2);

            //assert
            Assert.AreEqual(0, myqueue.Dequeue());
            Assert.AreEqual(1, myqueue.Dequeue());
            Assert.AreEqual(2, myqueue.Dequeue());
            Assert.AreEqual(0, myqueue.Count());
        }
Ejemplo n.º 6
0
        public void GetPeekOfQueue_FirstElementInQueue()
        {
            QueueT <CastomForTest> queue = new QueueT <CastomForTest>(1);

            queue.Enqueue(new CastomForTest(1));

            Assert.AreEqual(new CastomForTest(1), queue.Peek());
        }
Ejemplo n.º 7
0
        public void QueueTest_QueueWith1ElementAndDelete2_InvalideOperationException()
        {
            QueueT <CastomForTest> queue = new QueueT <CastomForTest>(1);

            queue.Enqueue(new CastomForTest(1));
            queue.Dequeue();

            Assert.Throws <InvalidOperationException>(() => queue.Dequeue());
        }