public void Execute(SpecContext context) { using (context.Timings.Subject(Type, Subject)) { Values.DoDelayedConversions(context); if (Values.Errors.Any()) { var result = Values.ToConversionErrorResult(); result.position = Position; context.LogResult(result); return; } try { var result = execute(context); result.position = Position; context.LogResult(result); } catch (Exception ex) { context.LogException(Values.id, ex, Position); } } }
public void Execute(SpecContext context) { var record = context.Timings.Subject(Type, Subject, maximumRuntimeInMilliseconds); Values.DoDelayedConversions(context); StepResult result = null; if (Values.Errors.Any()) { result = Values.ToConversionErrorResult(); result.position = Position; context.LogResult(result, record); return; } try { result = IsAsync() ? executeAsync(context).GetAwaiter().GetResult() : execute(context); result.position = Position; context.LogResult(result, record); } catch (Exception ex) { context.LogException(Values.id, ex, record, Position); } }
public void stop_on_the_first_wrong_when_stop_conditions_say_so() { theContext.StopConditions.BreakOnWrongs = true; theContext.LogResult(new StepResult("1", ResultStatus.success)); theContext.CanContinue().ShouldBe(true); theContext.LogResult(new StepResult("1", ResultStatus.failed)); theContext.CanContinue().ShouldBe(false); }
public void Execute(SpecContext context) { // TODO -- add threshold here? var record = context.Timings.Subject(type, Subject, 0); try { Action(context); var result = new StepResult(Id, ResultStatus.ok) { position = Position }; context.LogResult(result, record); context.Timings.End(record, result); } catch (Exception ex) { context.LogException(Node.id, ex, record, Position); context.Timings.End(record); } }
public Task ExecuteAsync(SpecContext context, CancellationToken cancellation) { var record = context.Timings.Subject("Grammar", _grammar.Key, _maximumRuntimeInMilliseconds); var fetch = _comparison.Fetch(context); if (!convertData(context, record)) { return(Task.CompletedTask); } return(fetch.ContinueWith(t => { if (t.IsFaulted) { // TODO -- do the Flatten() trick here on the aggregated exception context.LogException(_section.id, t.Exception, record, Stage.before); return; } if (t.IsCompleted) { var result = CreateResults(_expected, t.Result); result.id = _section.id; context.LogResult(result, record); context.Timings.End(record, result); } }, cancellation)); }
public async Task ExecuteAsync(SpecContext context, CancellationToken cancellation) { if (AsyncAction != null) { // TODO -- add threshold here? var record = context.Timings.Subject(type, Subject, 0); try { await AsyncAction(context); var result = new StepResult(Id, ResultStatus.ok) { position = Position }; context.LogResult(result, record); context.Timings.End(record, result); } catch (Exception ex) { context.LogException(Node.id, ex, record, Position); context.Timings.End(record); } } else { Execute(context); } }
public void Execute(SpecContext context) { // TODO -- add threshold here? var record = context.Timings.Subject(type, Subject, 0); try { if (AsyncAction != null) { AsyncAction(context).Wait(context.StopConditions.TimeoutInSeconds.Seconds()); } else { Action(context); } var result = new StepResult(Id, ResultStatus.ok) { position = Position }; context.LogResult(result, record); context.Timings.End(record, result); } catch (Exception ex) { context.LogException(Node.id, ex, record, Position); context.Timings.End(record); } }
public void Execute(SpecContext context) { using (context.Timings.Subject("Grammar", _section.Key)) { var fetch = _comparison.Fetch(context); _expected.Each(x => { x.DoDelayedConversions(context); if (!x.Errors.Any()) return; context.LogResult(x.ToConversionErrorResult()); }); if (_expected.Any(x => x.HasErrors())) return; fetch.ContinueWith(t => { if (t.IsFaulted) { // TODO -- do the Flatten() trick here on the aggregated exception context.LogException(_section.id, t.Exception, Stage.before); return; } if (t.IsCompleted) { var result = CreateResults(_expected, t.Result); result.id = _section.id; context.LogResult(result); } }).Wait(); } }
public void Execute(SpecContext context) { using (context.Timings.Subject("Grammar", _section.Key)) { var fetch = _comparison.Fetch(context); _expected.Each(x => { x.DoDelayedConversions(context); if (!x.Errors.Any()) { return; } context.LogResult(x.ToConversionErrorResult()); }); if (_expected.Any(x => x.HasErrors())) { return; } fetch.ContinueWith(t => { if (t.IsFaulted) { // TODO -- do the Flatten() trick here on the aggregated exception context.LogException(_section.id, t.Exception, Stage.before); return; } if (t.IsCompleted) { var result = CreateResults(_expected, t.Result); result.id = _section.id; context.LogResult(result); } }).Wait(); } }
private bool convertData(SpecContext context, PerfRecord record) { _expected.Each(x => { x.DoDelayedConversions(context); if (!x.Errors.Any()) { return; } context.LogResult(x.ToConversionErrorResult(), record); }); return(_expected.All(x => !x.HasErrors())); }
public void Execute(SpecContext context) { using (context.Timings.Subject(type, Subject)) try { Action(context); context.LogResult(new StepResult(Id, ResultStatus.ok) {position = Position}); } catch (Exception ex) { context.LogException(Node.id, ex, Position); } }
private SpecResults buildResults(SpecContext context, Timings timings) { if (Request.IsCancelled) { return(null); } var catastrophic = context?.CatastrophicException; if (catastrophic != null) { throw new StorytellerExecutionException(catastrophic); } Finished = !_timeout.IsCompleted && !Request.IsCancelled; if (_timeout.IsCompleted && !Request.IsCancelled) { var result = timeoutMessage(timings); if (context == null) { var perf = timings.Finish(); return(new SpecResults { Counts = new Counts(0, 0, 1, 0), Duration = timings.Duration, Performance = perf.ToArray(), Attempts = Request.Plan.Attempts, Results = new IResultMessage[] { result }, WasAborted = false }); } context.LogResult(result, null); context.Cancel(); } return(context.FinalizeResults(Request.Plan.Attempts)); }
public void Execute(SpecContext context) { using (context.Timings.Subject(_type, Subject)) try { _action(context); context.LogResult(new StepResult(Id, ResultStatus.ok) { position = Position }); } catch (Exception ex) { context.LogException(_node.id, ex, Position); } }
public Task ExecuteAsync(SpecContext context, CancellationToken cancellation) { if (!IsAsync()) { return(Task.Factory.StartNew(() => Execute(context), cancellation)); } var record = context.Timings.Subject(Type, Subject, maximumRuntimeInMilliseconds); return(executeAsync(context).ContinueWith(t => { if (t.IsFaulted) { context.LogException(Values.id, t.Exception, record, Position); } else { var result = t.Result; result.position = Position; context.LogResult(result, record); } }, cancellation)); }
public SpecResults Execute() { _reset = new ManualResetEvent(false); _thread = new Thread(() => { try { execute(); } #if NET46 catch (ThreadAbortException) { // nothing, it's handled below } #endif catch (Exception e) { Console.WriteLine(e); } }) { Name = "StoryTeller-Test-Execution" }; _thread.Start(); var timedout = !_reset.WaitOne(_stopConditions.TimeoutInSeconds.Seconds()); _finished = true; if (_wasCancelled) { return(null); } if (_catastrophicException != null) { throw new StorytellerExecutionException(_catastrophicException); } if (_context?.CatastrophicException != null) { throw new StorytellerExecutionException(_context.CatastrophicException); } if (timedout && !_wasCancelled) { var result = timeoutMessage(); if (_context == null) { var perf = _timings.Finish(); return(new SpecResults { Counts = new Counts(0, 0, 1, 0), Duration = _timings.Duration, Performance = perf.ToArray(), Attempts = _request.Plan.Attempts, Results = new IResultMessage[] { result }, WasAborted = false }); } _context.LogResult(result); _context.Cancel(); } return(_context.FinalizeResults(_request.Plan.Attempts));; }
private SpecResults buildResults(SpecContext context, Timings timings ) { if (Request.IsCancelled) return null; var catastrophic = context?.CatastrophicException; if (catastrophic != null) { throw new StorytellerExecutionException(catastrophic); } Finished = !_timeout.IsCompleted && !Request.IsCancelled; if (_timeout.IsCompleted && !Request.IsCancelled) { var result = timeoutMessage(timings); if (context == null) { var perf = timings.Finish(); return new SpecResults { Counts = new Counts(0, 0, 1, 0), Duration = timings.Duration, Performance = perf.ToArray(), Attempts = Request.Plan.Attempts, Results = new IResultMessage[] { result }, WasAborted = false }; } context.LogResult(result); context.Cancel(); } return context.FinalizeResults(Request.Plan.Attempts); }