示例#1
0
        /// <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);
        }
示例#4
0
        /// <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);
        }
示例#5
0
        /// <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);
        }
示例#9
0
        /// <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);
 }
示例#12
0
 /// <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);
 }
示例#13
0
 /// <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);
 }
示例#14
0
 /// <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);
 }
示例#15
0
 /// <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);
 }