public void SimpleAddition() { double value; _calculator = new Calc(); _calculator.ParseString("1+1"); value = _calculator.Result(); Assert.AreEqual(value, (double)2); }
public void ComplexParen() { double value; _calculator = new Calc(); _calculator.ParseString("2*(1+1)"); value = _calculator.Result(); Assert.AreEqual(value, (double)4); }
public void ParseStringWithSimpleParse() { double value; _calculator = new Calc(); _calculator.ParseString("5 + "); _calculator.Parse("5"); value = _calculator.Result(); Assert.AreEqual(value, (double)10); }
static void Main(string[] args) { Calc _calculator = new Calc(); string equation; double lastResult = 0; while (true) { Console.WriteLine("Input your equation."); equation = Console.ReadLine().Trim(); if (!_calculator.Operators.ContainsKey(equation[0])) _calculator.Clear(); _calculator.ParseString(equation); lastResult = _calculator.Result(); Console.WriteLine("= " + lastResult.ToString()); } }
public void NoOperatorParseString() { _calculator = new Calc(); _calculator.ParseString("5 5"); _calculator.Result(); }