private TaskResult Start(IRemoteTaskServer server, TaskExecutionNode node, CSUnitTestTask test)
    {
      var fixture = (CSUnitTestFixtureTask) node.Parent.RemoteTask;

      object instance = fixture.Instance;
      Type type = instance.GetType();

      MethodInfo testMI = type.GetMethod(test.TestMethod, new Type[0]);
      if (testMI == null)
      {
        server.TaskError(test, string.Format("Cannot find test  method '{0}'", test.TestMethod));
        return TaskResult.Error;
      }

      string ignoreReason;
      if (IsIgnored(testMI, out ignoreReason) && !test.Explicitly)
      {
        server.TaskFinished(test, ignoreReason, TaskResult.Skipped);
        return TaskResult.Skipped;
      }

      if (myTestSetUp != null)
      {
        server.TaskProgress(test, "Setting up...");
        try
        {
          TaskExecutor.Invoke(fixture.Instance, myTestSetUp);
        }
        catch (TargetInvocationException e)
        {
          Exception exception = e.InnerException ?? e;

          string message;
          Server.TaskException(test, TaskExecutor.ConvertExceptions(exception, out message));
          Server.TaskFinished(test, message, TaskResult.Exception);
          return TaskResult.Exception;
        }
      }

      return TaskResult.Success;
    }
    private TaskResult Finish(IRemoteTaskServer server, TaskExecutionNode node, CSUnitTestTask test)
    {
      var fixture = (CSUnitTestFixtureTask) node.Parent.RemoteTask;

      if (myTestTearDown != null)
      {
        server.TaskProgress(test, "Tearing down...");
        try
        {
          TaskExecutor.Invoke(fixture.Instance, myTestTearDown);
        }
        catch (TargetInvocationException e)
        {
          Exception exception = e.InnerException ?? e;

          string message;
          Server.TaskException(test, TaskExecutor.ConvertExceptions(exception, out message));
          Server.TaskFinished(test, message, TaskResult.Exception);
          return TaskResult.Exception;
        }
      }
      server.TaskProgress(test, "");
      return TaskResult.Success;
    }
    private static TaskResult Execute(IRemoteTaskServer server, TaskExecutionNode node, CSUnitTestTask test)
    {
      var fixture = (CSUnitTestFixtureTask) node.Parent.RemoteTask;
      object instance = fixture.Instance;
      Type type = instance.GetType();

      MethodInfo testMI = type.GetMethod(test.TestMethod, new Type[0]);
      if (testMI == null)
      {
        server.TaskError(test, string.Format("Cannot find test  method '{0}'", test.TestMethod));
        return TaskResult.Error;
      }
      server.TaskProgress(test, "");

      string expectedExceptionType;
      GetExpectedException(testMI, out expectedExceptionType);

      Exception exception = null;
      try
      {
        TaskExecutor.Invoke(instance, testMI);
      }
      catch (TargetInvocationException e)
      {
        exception = e.InnerException ?? e;
      }
      if (exception != null && exception.GetType().FullName == "csUnit.IgnoreException")
      {
        server.TaskFinished(test, exception.Message, TaskResult.Skipped);
        return TaskResult.Skipped;
      }
      if (expectedExceptionType != null && exception == null)
      {
        // failed, exception expected but not thrown
        server.TaskError(test, string.Format("Expected exception '{0}' was not thrown", expectedExceptionType));
        return TaskResult.Error;
      }
      if (expectedExceptionType != null && expectedExceptionType == exception.GetType().FullName)
      {
        return TaskResult.Success;
      }
      if (exception != null)
        throw new TargetInvocationException(exception);

      return TaskResult.Success;
    }