public void ReturnValidResult()
        {
            var mathResolver = new MathOperationResolver();

            Assert.Equal(4, mathResolver.GetResult("2+2"));
            Assert.Equal(14, mathResolver.GetResult("4+5*2"));
            Assert.Equal(6.5, mathResolver.GetResult("4+5/2"));
            Assert.Equal(5.5, mathResolver.GetResult("4+5/2-1"));
        }
Esempio n. 2
0
        public void StartApp()
        {
            outStream("Welcome in MathifyString!");

            string mathOperationString = null;
            var    resolver            = new MathOperationResolver();

            while (true)
            {
                outStream($"--------------------------------------------");
                outStream($"Enter a mathematical operation using integers " +
                          $"or operations characters like + - * /");
                outStream("For get result press enter or press q for quit:");

                mathOperationString = inStream();
                if (mathOperationString == "q")
                {
                    break;
                }

                try
                {
                    var result = resolver.GetResult(mathOperationString);
                    outStream($"Result is:{result}!");
                } catch (Exception e)
                {
                    outStream("Error:" + e.Message);
                }
            }
        }