TResult IGivenActor.WasAbleTo <TResult>(IPerformable <TResult> performable) { InvokeBeginGiven(); var result = Perform(performable); InvokeEndGiven(); return(result); }
TResult IWhenActor.AttemptsTo <TResult>(IPerformable <TResult> performable) { InvokeBeginWhen(); var result = Perform(performable); InvokeEndWhen(); return(result); }
TResult IThenActor.Should <TResult>(IPerformable <TResult> performable) { InvokeBeginThen(); var result = Perform(performable); InvokeEndThen(); return(result); }
/// <summary> /// Initializes a new instance of the <see cref="PerformanceEventArgsBase"/> class. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable.</param> public PerformanceEventArgsBase(IActor actor, IPerformable performable) : base(actor) { if (performable == null) { throw new ArgumentNullException(nameof(performable)); } Performable = performable; }
/// <summary> /// Initializes a new instance of the <see cref="PerformanceFailureEventArgs"/> class. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable.</param> /// <param name="exception">The exception.</param> public PerformanceFailureEventArgs(IActor actor, IPerformable performable, Exception exception) : base(actor, performable) { if (exception == null) { throw new ArgumentNullException(nameof(exception)); } Exception = exception; }
public void BeginPerformance_raises_exception_when_called_after_EndScenario(INamed actor, IPerformable performable, bool success, ReportBuilder sut, Guid scenarioIdentity) { // Arrange sut.BeginNewScenario(null, null, null, null, scenarioIdentity, false, false); sut.EndScenario(success, scenarioIdentity); // Act & assert Assert.That(() => sut.BeginPerformance(actor, performable, scenarioIdentity), Throws.TypeOf <ScenarioIsFinalisedAlreadyException>()); }
/// <summary> /// Initializes a new instance of the <see cref="PerformableReportBase"/> class. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable.</param> public PerformableReportBase(INamed actor, IPerformable performable) { if (performable == null) { throw new ArgumentNullException(nameof(performable)); } if (actor == null) { throw new ArgumentNullException(nameof(actor)); } Performable = performable; Actor = actor; }
public void BeginPerformance_calls_BeginPerformance_from_builder(IBuildsScenario scenarioBuilder, IFormatsObjectForReport formatter, Builders.IGetsReport reportFactory, Guid scenarioIdentity, IActor actor, IPerformable performable) { // Arrange var sut = new ReportBuilder(formatter, reportFactory, GetScenarioBuilderFactory(scenarioBuilder)); sut.BeginNewScenario(null, null, null, null, scenarioIdentity, false, false); // Act sut.BeginPerformance(actor, performable, scenarioIdentity); // Assert Mock.Get(scenarioBuilder).Verify(x => x.BeginPerformance(actor, performable), Times.Once); }
/// <summary> /// Performs an action or task. /// </summary> /// <param name="performable">The performable item to execute.</param> protected virtual void Perform(IPerformable performable) { if (ReferenceEquals(performable, null)) { throw new ArgumentNullException(nameof(performable)); } try { InvokeBeginPerformance(performable); performable.PerformAs(this); InvokeEndPerformance(performable); } catch (Exception ex) { InvokePerformanceFailed(performable, ex); throw; } }
/// <summary> /// Performs an action, task or asks a question which returns a result value. /// </summary> /// <returns>The result of performing the item</returns> /// <param name="performable">The performable item to execute.</param> /// <typeparam name="TResult">The result type.</typeparam> protected virtual TResult Perform <TResult>(IPerformable <TResult> performable) { if (ReferenceEquals(performable, null)) { throw new ArgumentNullException(nameof(performable)); } TResult result; try { InvokeBeginPerformance(performable); result = performable.PerformAs(this); InvokePerformanceResult(performable, result); InvokeEndPerformance(performable); } catch (Exception ex) { InvokePerformanceFailed(performable, ex); throw; } return(result); }
public void BeginPerformance_raises_exception_when_called_for_a_scenario_which_has_not_begun(ReportBuilder sut, INamed actor, IPerformable performable, Guid scenarioIdentity) { // Act & assert Assert.That(() => sut.BeginPerformance(actor, performable, scenarioIdentity), Throws.TypeOf <ScenarioHasNotBegunException>()); }
void IThenActor.Should(IPerformable performable) { InvokeBeginThen(); Perform(performable); InvokeEndThen(); }
public void RecordSuccess_raises_exception_when_called_for_a_scenario_which_has_not_begun(ReportBuilder sut, IPerformable performable, Guid scenarioIdentity) { // Act & assert Assert.That(() => sut.RecordSuccess(performable, scenarioIdentity), Throws.TypeOf <ScenarioHasNotBegunException>()); }
void IGivenActor.WasAbleTo(IPerformable performable) { InvokeBeginGiven(); Perform(performable); InvokeEndGiven(); }
void IWhenActor.AttemptsTo(IPerformable performable) { InvokeBeginWhen(); Perform(performable); InvokeEndWhen(); }
/// <summary> /// Invokes the performance result event. /// </summary> /// <param name="performable">Performable.</param> /// <param name="result">Result.</param> protected virtual void InvokePerformanceResult(IPerformable performable, object result) { var args = new PerformanceResultEventArgs(this, performable, result); PerformanceResult?.Invoke(this, args); }
/// <summary> /// Invokes the performance failed event. /// </summary> /// <param name="performable">Performable.</param> /// <param name="exception">Exception.</param> protected virtual void InvokePerformanceFailed(IPerformable performable, Exception exception) { var args = new PerformanceFailureEventArgs(this, performable, exception); PerformanceFailed?.Invoke(this, args); }
TResult IPerformer.Perform <TResult>(IPerformable <TResult> performable) { return(Perform(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(INamed actor, IPerformable performable, Guid scenarioIdentity) { var report = new SuccessReport(actor, performable); Trace(TraceConstants.PerformanceSuccess, report); }
/// <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(INamed actor, IPerformable performable, object result, Guid scenarioIdentity) { var report = new ResultReport(actor, performable, result); Trace(TraceConstants.PerformanceResult, report); }
/// <summary> /// Initializes a new instance of the <see cref="ResultReport"/> class. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable.</param> /// <param name="result">The result value.</param> public ResultReport(INamed actor, IPerformable performable, object result) : base(actor, performable) { Result = result; }
/// <summary> /// Initializes a new instance of the <see cref="PerformanceResultEventArgs"/> class. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable.</param> /// <param name="result">The result retrieved from the performable.</param> public PerformanceResultEventArgs(IActor actor, IPerformable performable, object result) : base(actor, performable) { Result = result; }
/// <summary> /// Initializes a new instance of the <see cref="BeginPerformanceEventArgs"/> class. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable.</param> public BeginPerformanceEventArgs(IActor actor, IPerformable performable) : base(actor, performable) { }
/// <summary> /// Initializes a new instance of the <see cref="EndSuccessfulPerformanceEventArgs"/> class. /// </summary> /// <param name="actor">The actor.</param> /// <param name="performable">The performable.</param> public EndSuccessfulPerformanceEventArgs(IActor actor, IPerformable performable) : base(actor, performable) { }
/// <summary> /// /// </summary> /// <param name="i_MenuTitle"></param> /// <param name="i_Performable">IPerformable object that will listen to action notification</param> /// <param name="i_MethodNameToPeform">represent the method to perform</param> public ActionItem(string i_MenuTitle, object i_Performable, string i_MethodNameToPeform) : base(i_MenuTitle) { m_MethodNameToPeform = i_MethodNameToPeform; m_ObjectWithMenu = i_Performable as IPerformable; }
/// <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(INamed actor, IPerformable performable, Exception exception, Guid scenarioIdentity) { var report = new FailureReport(actor, performable, exception); Trace(TraceConstants.PerformanceFailure, report); }
void IPerformer.Perform(IPerformable performable) { Perform(performable); }
/// <summary> /// Invokes the begin performance event. /// </summary> /// <param name="performable">Performable.</param> protected virtual void InvokeBeginPerformance(IPerformable performable) { var args = new BeginPerformanceEventArgs(this, performable); BeginPerformance?.Invoke(this, args); }
/// <summary> /// Invokes the end performance event. /// </summary> /// <param name="performable">Performable.</param> protected virtual void InvokeEndPerformance(IPerformable performable) { var args = new EndSuccessfulPerformanceEventArgs(this, performable); EndPerformance?.Invoke(this, args); }
/// <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(INamed actor, IPerformable performable, Guid scenarioIdentity) { var report = new BeginReport(actor, performable); Trace(TraceConstants.BeginPerformance, report); }