public void ThrowsExceptionOnBadInput() { var setVariable = new SetVariable(); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("x2 = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("x 2 = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("= 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("x.y = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("x,y = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("x-2 = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("x+2 = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("x/2 = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("x*2 = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("x^2 = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("e = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("pi = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("ans = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("root = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("log = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("help = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("frac = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("calc = 1")); Assert.Throws<CalculatorException>(() => setVariable.HandleInput("set = 1")); }
/// <summary> /// Initializes a new instance of the <see cref="InputHandler"/> class. /// </summary> public InputHandler() { _fraction = new Fraction(); _setVariable = new SetVariable(); _unsetVariable = new UnsetVariable(); _variables = new Variables(); _calculate = new Calculate(); _help = new Help(); }