示例#1
0
    static public void Main()
    {
        CalcInterface calc = new CalcInterface();
        string        str  = "";

        while (true)
        {
            Console.WriteLine("Enter expression. Enter q to quit. ");
            str = Console.ReadLine();
            str = str.Trim();
            if (str == "q")
            {
                break;
            }
            Console.WriteLine(calc.evaluate(str));
        }
    }
    public override List <TestResult> run()
    {
        List <TestResult> results = new List <TestResult>();

        CalcInterface face = new CalcInterface();

        string fail    = "Error, expression not valid.";
        string success = "5";

        TestResult res;
        string     actual = face.evaluate("(");

        res = new TestResult("Interface Fail", actual, fail, actual == fail);
        results.Add(res);

        actual = face.evaluate("5");
        res    = new TestResult("Interface Fail", actual, success, actual == success);
        results.Add(res);

        return(results);
    }