public void Report(ScenarioRunResult result) { try { var writer = new DelayedBatchWriter(_queue); writer.Write(new StartScenario(result.Title ?? result.Scope, result.Scope, result.Grouping)); foreach (var given in result.Given) { writer.Write(given); } if (result.When != null) { writer.Write(result.When); } foreach (var then in result.Then) { writer.Write(then); } writer.Complete(); } catch (Exception ex) { _diagnosticMessageSinkessageSink.OnMessage( new DiagnosticMessage($"An error occured reading scenario result:{Environment.NewLine} {ex}")); _error = ex; } EnsureWriting(); }
private void VerifyAndReportScenario(ScenarioRunResult result, string name, string grouping) { if (_scenarioRunner != null) { throw new InvalidOperationException(Constants.Errors.DontReturnScenarioResults); } result.Scope = name; result.Grouping = result.Grouping ?? grouping; _report.Report(result); result.ThrowIfErrored(); }
private async Task ExecuteWithoutThrowing() { if (!_runCompleted) { _runCompleted = true; try { await Run(); } catch (Exception ex) { _error = ExceptionDispatchInfo.Capture(ex); } if (_when == null) { AddResult(null, "Incomplete scenario", new Exception("No when provided")); } _result = new ScenarioRunResult(Title, _givens, _when ?? NullWhen, _thens, _error) { Scope = Scope, Grouping = Group }; } }
private async Task VerifyAndReport <T>(Task <T> scenarioTask, string name, string grouping) where T : ScenarioRunResult { ScenarioRunResult result = await scenarioTask; VerifyAndReportScenario(result, name, grouping); }