예제 #1
0
        // ToDo: this method does not really belong to this class
        public Result ExecuteStep(Step step)
        {
            try
            {
                step.Execute(TestObject);
                step.Result = Result.Passed;
            }
            catch (Exception ex)
            {
                // ToDo: more thought should be put into this. Is it safe to get the exception?
                var exception = ex;
                if (exception is TargetInvocationException)
                {
                    exception = ex.InnerException ?? ex;
                }

                if (exception is NotImplementedException)
                {
                    step.Result = Result.NotImplemented;
                    step.Exception = exception;
                }
                else if (IsInconclusive(exception))
                {
                    step.Result = Result.Inconclusive;
                    step.Exception = exception;
                }
                else
                {
                    step.Exception = exception;
                    step.Result = Result.Failed;
                }
            }

            return step.Result;
        }
예제 #2
0
 public Step(Step step)
 {
     Id = step.Id;
     _title = step._title;
     Asserts = step.Asserts;
     ExecutionOrder = step.ExecutionOrder;
     ShouldReport = step.ShouldReport;
     Result = Result.NotExecuted;
     Action = step.Action;
     Arguments = step.Arguments;
 }
예제 #3
0
 /// <summary>
 /// Executes the step. If you'd like to run your own custom logic before/after each step, 
 /// override this method and call the base method within your implementation.
 /// </summary>
 public virtual object Execute(Step step, object testObject)
 {
     Stopwatch sw = Stopwatch.StartNew();
     try
     {
         var result = step.Action(testObject);
         sw.Stop();
         step.Duration = sw.Elapsed;
         return result;
     }
     finally
     {
         sw.Stop();
         step.Duration = sw.Elapsed;
     }
 }