示例#1
0
    static void Main()
    {
        StackOfInt pilica = new StackOfInt();

        pilica.Push(1);
        pilica.Push(2);
        pilica.Push(3);
        pilica.Push(4);
        pilica.Push(5);

        Console.WriteLine("Cantidad Ini. : " + pilica.Count);
        Console.WriteLine(pilica.Pop());
        Console.WriteLine(pilica.Pop());
        Console.WriteLine(pilica.Pop());
        Console.WriteLine(pilica.Pop());
        Console.WriteLine(pilica.Pop());
        Console.WriteLine("Cantidad Fin : " + pilica.Count);

        Console.WriteLine();

        int[]      enteros = { 1, 2, 3, 4, 5 };
        StackOfInt pilica2 = new StackOfInt(enteros);

        Console.WriteLine("Cantidad Ini. : " + pilica2.Count);
        Console.WriteLine(pilica2.Pop());
        Console.WriteLine(pilica2.Pop());
        Console.WriteLine(pilica2.Pop());
        Console.WriteLine(pilica2.Pop());
        Console.WriteLine(pilica2.Pop());
        Console.WriteLine("Cantidad Fin : " + pilica2.Count);
    }
示例#2
0
        public void TestCount()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Push(1);
            SOI.Push(11);
            SOI.Push(21);
            Assert.AreEqual(3, SOI.Count());
        }
示例#3
0
        public void TestClear()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Push(1);
            SOI.Push(11);
            SOI.Push(21);
            SOI.Clear();
            Assert.AreEqual(0, SOI.StackInt.Count());
        }
示例#4
0
        public void TestMultiplyAll()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Push(1);
            SOI.Push(11);
            SOI.Push(21);
            SOI.MultiAllNumbers();
            Assert.AreEqual(21 * 11 * 1, SOI.StackInt.Peek());
        }
示例#5
0
        public void TestaddAll()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Push(1);
            SOI.Push(11);
            SOI.Push(21);
            SOI.AddAll();
            Assert.AreEqual(21 + 11 + 1, SOI.StackInt.Peek());
        }
示例#6
0
        public void TestDivisionTop2()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Push(1);
            SOI.Push(11);
            SOI.Push(21);
            SOI.DivisionTop2();
            Assert.AreEqual((double)21 / (double)11, SOI.StackInt.Peek());
        }
示例#7
0
        public void TestMultiplyTop2()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Push(1);
            SOI.Push(11);
            SOI.Push(21);
            SOI.Multiplytop2();
            Assert.AreEqual(21 * 11, SOI.StackInt.Peek());
        }
示例#8
0
        public void TestsubTop2()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Push(1);
            SOI.Push(11);
            SOI.Push(21);
            SOI.SubTop2();
            Assert.AreEqual(21 - 11, SOI.StackInt.Peek());
        }
示例#9
0
        public void TestAddTop2()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Push(1);
            SOI.Push(11);
            SOI.Push(21);
            SOI.AddTop2();
            Assert.AreEqual(11 + 21, SOI.StackInt.Peek());
        }
示例#10
0
        public void TestTop()
        {
            StackOfInt SOI       = new StackOfInt();
            double     expResult = 2;

            SOI.Push(expResult);
            double result = SOI.Top();

            Assert.AreEqual(expResult, result);

            double expResult2 = 3;

            SOI.Push(expResult2);
            double result2 = SOI.Top();

            Assert.AreEqual(expResult2, result2);
        }
示例#11
0
        public void TestMultiplyTop2Exception()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Push(1);

            SOI.Multiplytop2();
        }
示例#12
0
        public void TestAddAllNumber1Number()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Clear();
            SOI.Push(1);
            SOI.AddAll();
            Assert.AreEqual(1, SOI.StackInt.Peek());
        }
示例#13
0
        public void TestMultiplyAll1Number()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Clear();
            SOI.Push(1);
            SOI.MultiAllNumbers();
            Assert.AreEqual(1, SOI.StackInt.Peek());
        }
示例#14
0
        public void TestDivsionTop2Exception()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Push(1);
            try
            {
                SOI.DivisionTop2();
                Assert.Fail();
            }
            catch (Exception)
            {
            }
        }
示例#15
0
        public void Testpop()
        {
            StackOfInt SOI = new StackOfInt();

            double expResult = 2;

            SOI.Push(expResult);
            SOI.Push(3);
            double expResult3 = SOI.Pop();
            double result     = SOI.StackInt.Peek();

            Assert.AreEqual(expResult, result);
            Assert.AreEqual(expResult3, 3);

            double expResult2 = 3;

            SOI.Push(expResult2);
            SOI.Push(2);
            double expResult4 = SOI.Pop();
            double result2    = SOI.StackInt.Peek();

            Assert.AreEqual(expResult2, result2);
            Assert.AreEqual(expResult4, 2);
        }
示例#16
0
        public void TestAddTwoException()
        {
            StackOfInt SOI = new StackOfInt();

            SOI.Clear();
            SOI.Push(2);
            try
            {
                SOI.AddTop2();
                Assert.Fail();
            }
            catch (System.Exception)
            {
            }
        }