Inheritance: System.MarshalByRefObject, EventListener
Exemplo n.º 1
0
        public bool Run(TestInfo test, TestSuiteResult suite_result, string test_name, EventListener listener, ITestFilter filter, int timeout)
        {
            listener = new ProxyListener(listener);

            TestRunnerDelegate runner = new TestRunnerDelegate(delegate {
                return(server.Run(test_name, listener, filter));
            });

            IAsyncResult ar = runner.BeginInvoke(test_name, null, filter, null, null);

            if (!ar.AsyncWaitHandle.WaitOne(timeout) || !ar.IsCompleted)
            {
                TestCaseResult error = new TestCaseResult(test);
                string         msg   = String.Format("Timeout after {0} ms", timeout);
                error.Failure(msg, null, FailureSite.Parent);
                suite_result.AddResult(error);
                return(false);
            }

            try {
                TestResult result = runner.EndInvoke(ar);
                if (result != null)
                {
                    suite_result.AddResult(result);
                    return(true);
                }

                TestCaseResult error = new TestCaseResult(test);
                error.Failure("Unknown error", null, FailureSite.Parent);
                suite_result.AddResult(error);
                return(false);
            } catch (Exception ex) {
                TestCaseResult error = new TestCaseResult(test);
                string         msg   = String.Format("Unknown exception: {0}", ex);
                error.Failure(msg, null, FailureSite.Parent);
                suite_result.AddResult(error);
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool Run(TestInfo test, TestSuiteResult suite_result, string test_name, EventListener listener, ITestFilter filter, int timeout)
        {
            listener = new ProxyListener (listener);

            TestRunnerDelegate runner = new TestRunnerDelegate (delegate {
                return server.Run (test_name, listener, filter);
            });

            IAsyncResult ar = runner.BeginInvoke (test_name, null, filter, null, null);

            if (!ar.AsyncWaitHandle.WaitOne (timeout) || !ar.IsCompleted) {
                TestCaseResult error = new TestCaseResult (test);
                string msg = String.Format ("Timeout after {0} ms", timeout);
                error.Failure (msg, null, FailureSite.Parent);
                suite_result.AddResult (error);
                return false;
            }

            try {
                TestResult result = runner.EndInvoke (ar);
                if (result != null) {
                    suite_result.AddResult (result);
                    return true;
                }

                TestCaseResult error = new TestCaseResult (test);
                error.Failure ("Unknown error", null, FailureSite.Parent);
                suite_result.AddResult (error);
                return false;
            } catch (Exception ex) {
                TestCaseResult error = new TestCaseResult (test);
                string msg = String.Format ("Unknown exception: {0}", ex);
                error.Failure (msg, null, FailureSite.Parent);
                suite_result.AddResult (error);
                return false;
            }
        }