/// <summary> /// Records that the current performable has failed with an exception. /// </summary> /// <param name="performable">Performable.</param> /// <param name="exception">Exception.</param> /// <param name="scenarioId">The screenplay scenario identity.</param> public void RecordFailure(Performables.IPerformable performable, Exception exception, Guid scenarioId) { var scenario = GetScenarioBuilder(scenarioId); scenario.RecordFailure(performable, exception); }
ReportableBuilder PeekCurrentBuilder(Performables.IPerformable expectedPerformable = null) { if (builderStack.Count == 0 && expectedPerformable == null) { return(null); } else if (builderStack.Count == 0) { var message = String.Format(Resources.ExceptionFormats.PerformableWasRequiredInBuilderStack, nameof(Performables.IPerformable), nameof(ReportableBuilder)); throw new InvalidOperationException(message); } var current = builderStack.Peek(); if (expectedPerformable == null) { return(current); } if (!ReferenceEquals(expectedPerformable, current.Performable)) { var message = String.Format(Resources.ExceptionFormats.PerformableDoesNotMatchExpectedPerformance, nameof(Performables.IPerformable), nameof(ReportableBuilder)); throw new ArgumentException(message, nameof(expectedPerformable)); } return(current); }
void FinalisePerformance(Performables.IPerformable performable) { var builder = PopCurrentBuilder(performable); var performance = builder.GetReportable(); AddReportable(performance); }
/// <summary> /// Records that the current performable has completed successfully. /// </summary> /// <param name="performable">Performable.</param> /// <param name="scenarioId">The screenplay scenario identity.</param> public void RecordSuccess(Performables.IPerformable performable, Guid scenarioId) { var scenario = GetScenarioBuilder(scenarioId); scenario.RecordSuccess(performable); }
/// <summary> /// Records that the current performable has received a result. /// </summary> /// <param name="performable">Performable.</param> /// <param name="result">Result.</param> /// <param name="scenarioId">The screenplay scenario identity.</param> public void RecordResult(Performables.IPerformable performable, object result, Guid scenarioId) { var scenario = GetScenarioBuilder(scenarioId); scenario.RecordResult(performable, result); }
/// <summary> /// Records that the current performable has received a result. /// </summary> /// <param name="performable">Performable.</param> /// <param name="result">Result.</param> public void RecordResult(Performables.IPerformable performable, object result) { EnsureNotFinalised(); var builder = PeekCurrentBuilder(performable); builder.HasResult = true; builder.Result = result; }
/// <summary> /// Records that the current performable has failed with an exception. /// </summary> /// <param name="performable">Performable.</param> /// <param name="exception">Exception.</param> public void RecordFailure(Performables.IPerformable performable, Exception exception) { EnsureNotFinalised(); var builder = PeekCurrentBuilder(performable); builder.IsFailure = true; builder.Exception = exception; FinalisePerformance(performable); }
/// <summary> /// Begins reporting of a new performable. /// </summary> /// <param name="actor">Actor.</param> /// <param name="performable">Performable.</param> public void BeginPerformance(INamed actor, Performables.IPerformable performable) { EnsureNotFinalised(); var builder = new ReportableBuilder(objectFormatter) { Performable = performable, Actor = actor, PerformanceType = currentPerformanceType, }; AddPerformanceBuilder(builder); }
/// <summary> /// Begins reporting of a new performable. /// </summary> /// <param name="actor">Actor.</param> /// <param name="performable">Performable.</param> /// <param name="scenarioId">The screenplay scenario identity.</param> public void BeginPerformance(INamed actor, Performables.IPerformable performable, Guid scenarioId) { var scenario = GetScenarioBuilder(scenarioId); if (scenario.IsFinalised()) { throw new ScenarioIsFinalisedAlreadyException(Resources.ExceptionFormats.ScenarioAlreadyFinalised); } scenario.BeginPerformance(actor, performable); }
ReportableBuilder PopCurrentBuilder(Performables.IPerformable expectedPerformable) { PeekCurrentBuilder(expectedPerformable); return(builderStack.Pop()); }
/// <summary> /// Records that the current performable has completed successfully. /// </summary> /// <param name="performable">Performable.</param> public void RecordSuccess(Performables.IPerformable performable) { EnsureNotFinalised(); FinalisePerformance(performable); }
/// <summary> /// Reports that a performable item has completed successfully. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable item.</param> /// <param name="scenarioIdentity">The screenplay scenario identity.</param> public void Success(Actors.INamed actor, Performables.IPerformable performable, Guid scenarioIdentity) { builder.RecordSuccess(performable, scenarioIdentity); }
/// <summary> /// Reports that a performable item has failed and possible terminated early. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable item.</param> /// <param name="exception">An exception encountered whilst attempting to perform the item.</param> /// <param name="scenarioIdentity">The screenplay scenario identity.</param> public void Failure(Actors.INamed actor, Performables.IPerformable performable, Exception exception, Guid scenarioIdentity) { builder.RecordFailure(performable, exception, scenarioIdentity); }
/// <summary> /// Reports that a performable item has produced a result. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable item.</param> /// <param name="result">The result produced.</param> /// <param name="scenarioIdentity">The screenplay scenario identity.</param> public void Result(Actors.INamed actor, Performables.IPerformable performable, object result, Guid scenarioIdentity) { builder.RecordResult(performable, result, scenarioIdentity); }
/// <summary> /// Reports that a performable item has begun. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable item.</param> /// <param name="scenarioIdentity">The screenplay scenario identity.</param> public void Begin(Actors.INamed actor, Performables.IPerformable performable, Guid scenarioIdentity) { builder.BeginPerformance(actor, performable, scenarioIdentity); }