Esempio n. 1
0
        public async Task <SpecResults> Execute(ExecutionPlan plan)
        {
            _observer.Starting(plan);

            /* TODOs
             *
             * 1. Try/Catch around the creation of the context. If it fails, the running is invalid.
             *  Return a results for that problem
             *
             * 2. Check if the runner is in an invalid state. If so, bail out
             *
             * 3. Start a timings object
             * 4. Create a timings object for creating the context
             * 5. If no steps at all in the execution plan, log an exception about the spec
             *  not being real
             *
             *
             * 6. Need to redirect the debug and trace output to the context
             * 7. Do a timeout where you start a parallel task and wait both
             *
             * 8. Build the results
             *  a. check for a catastropic exception
             *  b. mark if the spec completed
             *  c. timings.Finish()
             *  d. log the final result
             *
             * 9. cancel the context
             * 10. Finalize the results
             */

            var context = await _system.CreateContext(plan.Specification);


            // Need to check if the context itself is invalid before going on
            foreach (var line in plan.Lines)
            {
                // This is going to be it. All smarts in the new ExecutionContext
                if (context.Cancellation.IsCancellationRequested)
                {
                    break;
                }

                // TODO -- trap exceptions inside of line itself
                // TODO -- if line captures a critical or catastrophic exception,
                // kill the spec
                var result = await line.Execute(context);

                _observer.Completed(plan, line, result);
            }


            await _system.Complete(context);


            _observer.Finished(plan, new SpecResults());
            throw new NotImplementedException();
        }
        public async Task Start()
        {
            _context = await _system.CreateContext(_plan.Specification);

            _observer.Starting(_plan);

            // TODO -- if it fails, bail out with a failed result

            _hasStarted.SetResult(true);
        }