예제 #1
0
        static void Main(string[] args)
        {
            var mathSolver = new MathSolver();
            var lines      = Convert.ToInt32(System.Console.ReadLine());

            for (int i = 0; i < lines; i++)
            {
                var numberLine = System.Console.ReadLine();

                var result = mathSolver.Solve(new FindThePointProblem(numberLine));
                System.Console.WriteLine(result);
            }
        }
        public void FindThePointProblem_Given1122_ShouldReturn33()
        {
            //---------------Set up test pack-------------------
            var mathSolver          = new MathSolver();
            var findThePointProblem = new FindThePointProblem("1 1 2 2");
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var result = mathSolver.Solve(findThePointProblem);

            //---------------Test Result -----------------------
            Assert.AreEqual("3 3", result);
        }
예제 #3
0
        public string Compute()
        {
            MathSolver _solverSvc = new MathSolver();
            var        result     = _solverSvc.Solve(Request.Query["expr"]);

            if (String.IsNullOrEmpty(result.Error))
            {
                return(result.Value.ToString());
            }
            else
            {
                return(result.Error);
            }
        }
예제 #4
0
 public void TestBasicAdd()
 {
     Assert.AreEqual(6, _solverSvc.Solve("1+2+3").Value);
     Assert.AreEqual(6, _solverSvc.Solve("1 + 2 +3").Value);
     Assert.AreEqual(6, _solverSvc.Solve("1                   +2+3").Value);
     Assert.AreEqual(6, _solverSvc.Solve("1+2+3    ").Value);
     Assert.AreEqual(3, _solverSvc.Solve("1+(2)").Value);
     Assert.AreEqual(3, _solverSvc.Solve("1+(+2)").Value);
     Assert.AreEqual(-1, _solverSvc.Solve("1+(-2)").Value);
 }