Ejemplo n.º 1
0
 public void TestCase3()
 {
     try
     {
         RPNCalculator obj    = new RPNCalculator();
         int           result = Convert.ToInt32(obj.Calculate("2,+,2"));
     }catch (Exception ex)
     {
         Assert.AreEqual("Invalid Expression", ex.Message);
     }
 }
Ejemplo n.º 2
0
 public void TestCase9()
 {
     try
     {
         RPNCalculator obj = new RPNCalculator();
         Convert.ToInt32(obj.Calculate("-4,!"));
     }
     catch (Exception ex)
     {
         Assert.AreEqual("Invalid Operand", ex.Message);
     }
 }
Ejemplo n.º 3
0
 public void TestCase8()
 {
     try
     {
         RPNCalculator obj    = new RPNCalculator();
         int           result = Convert.ToInt32(obj.Calculate("2,0,/"));
     }
     catch (Exception ex)
     {
         Assert.AreEqual("Divide by zero", ex.Message);
     }
 }
Ejemplo n.º 4
0
 public void TestCase12()
 {
     try
     {
         RPNCalculator obj = new RPNCalculator();
         obj.Calculate("2147483647,2,+");
     }
     catch (Exception ex)
     {
         Assert.AreEqual("greater than max1", ex.Message);
     }
 }
Ejemplo n.º 5
0
        public void TestCase7()
        {
            RPNCalculator obj = new RPNCalculator();

            Assert.AreEqual(0, Convert.ToInt32(obj.Calculate("2,2,*,4,/,1,+,2,-")));
        }
Ejemplo n.º 6
0
        public void TestCase2()
        {
            RPNCalculator obj = new RPNCalculator();

            Assert.AreEqual(5, Convert.ToInt32(obj.Calculate("2,3,+")));
        }
Ejemplo n.º 7
0
        public void TestCase10()
        {
            RPNCalculator obj = new RPNCalculator();

            Assert.AreEqual(24, Convert.ToInt32(obj.Calculate("4,!")));
        }