public static void Main() { Console.WriteLine("Please, type in an arithmetic expression:"); try { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { Console.WriteLine("The input string is empty!"); return; } decimal result = MathProcessor.Calculate(input); Console.WriteLine($"Expression result: {result}"); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } }
public void ModuloBehaviourUndefinedException() { Assert.Throws <ModuloBehaviourUndefinedException>(() => MathProcessor.Calculate("6%0")); }
public void DivideByZeroException() { Assert.Throws <DivideByZeroException>(() => MathProcessor.Calculate("1/0")); }
public void MismatchedParenthesisException(string expression) { Assert.Throws <ExpressionMismatchedParenthesisException>(() => MathProcessor.Calculate(expression)); }
public void CalculateValues(string expression, decimal expected) { decimal actual = MathProcessor.Calculate(expression); Assert.AreEqual(expected, actual); }
public void ExpressionInvalidCharsException(string expression) { Assert.Throws <ExpressionInvalidCharsException>(() => MathProcessor.Calculate(expression)); }