Beispiel #1
0
 public void Get_tokens_correctly()
 {
     Assert.AreEqual(3, ExpressionCalc.GetTokens("1+2").Count());
     Assert.AreEqual(3, ExpressionCalc.GetTokens("11+22").Count());
     Assert.AreEqual(5, ExpressionCalc.GetTokens("-11*(-22)").Count());
     Assert.AreEqual(7, ExpressionCalc.GetTokens("(1+5)-2").Count());
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the expression!");
            var expression = Console.ReadLine();

            try
            {
                ExpressionCalc calc = new ExpressionCalc();
                Console.WriteLine("The result is {0}", calc.Calculate(expression));
            }
            catch (Exception e)
            {
                Console.WriteLine("Ooops! {0}", e.Message);
            }
            Console.ReadKey();
        }
Beispiel #3
0
 public void Setup()
 {
     calc = new ExpressionCalc();
 }