public void ConstantTestGetExpressionWithOtherConstants() { Constant constant = new Constant(); string input = "x = 12 + 12"; constant.ChangeExpression(input); constant.GetExpression(); constant.ChangeExpression("y = x + 2"); int expected = 26; Assert.AreEqual(expected, constant.GetExpression()); }
public void ConstantTestGetExpression() { string input = "x = 12 + 12"; Constant constant = new Constant(); constant.ChangeExpression(input); int expected = 24; Assert.AreEqual(expected, constant.GetExpression()); }
public void ConstantTestGetExpressionWithOneThingOneRightSide() { Constant constant = new Constant(); string input = "x = 12"; constant.ChangeExpression(input); int expected = 12; Assert.AreEqual(expected, constant.GetExpression()); }
static void Main(string[] args) { Console.WriteLine("Calculator"); int count = 0; string input; Constant constant = new Constant(); while (true) { Console.Write("[{0}]> ", count); input = Console.ReadLine(); if(input == "exit" || input == "quit") { Console.WriteLine("loggin out"); break; } ProcessInput PI = new ProcessInput(input); try { Evaluate ev = new Evaluate(PI.GetFirstInputNumber(), PI.GetOperator(), PI.GetSecondInputNumber()); Console.WriteLine(" = " + ev.Operate()); } catch { constant.ChangeExpression(input); try { Console.WriteLine(constant.GetExpression()); } catch { Console.WriteLine("Error! Try again . . ."); } } count++; } }
public void ConstantTestIfReturnsValueOfConstant() { Constant constant = new Constant(); constant.AddToConstants('x', 12); constant.ChangeExpression("x"); Assert.AreEqual(12, constant.GetExpression()); }