/// <summary> /// Main program for starting the calculator /// </summary> /// <param name="args">Not used</param> public static void Main(string[] args) { var inputHandler = new InputHandler(); Console.WriteLine(inputHandler.GetStartHelp()); while ( true ) { var readLine = Console.ReadLine(); if ( StringParse.StringStartsWith(readLine, inputHandler.GetQuitCommands(), true) != null ) { Console.WriteLine("Goodbye!\n"); break; } Console.WriteLine(inputHandler.HandleInput(readLine) + "\n"); } }
protected void SetUp() { _inputHandler = new InputHandler(); }
public void VariablesAreGlobal() { Assert.AreEqual("x = 2", _inputHandler.HandleInput("set x = 2")); Assert.AreEqual("2", _inputHandler.HandleInput("x")); _inputHandler.HandleInput("x + 4"); Assert.AreEqual("6", _inputHandler.HandleInput("ans")); var inputHandler2 = new InputHandler(); Assert.AreEqual("6", inputHandler2.HandleInput("ans")); Assert.AreEqual("2", inputHandler2.HandleInput("x")); }
public void TestFraction() { var inputHandler = new InputHandler(); Assert.AreEqual("511/1000", inputHandler.HandleInput("frac 511/1000")); Assert.AreEqual("611/1000", inputHandler.HandleInput("frac 511/1000 + 1/10")); Assert.AreEqual("3/4", inputHandler.HandleInput("frac 0,25 + 0,5")); Assert.AreEqual("1 3/4", inputHandler.HandleInput("frac 0,25 + 1,5")); }