Table of Contents

Class Performance

Namespace
CSF.Screenplay
Assembly
CSF.Screenplay.dll

Primary implementation type of IPerformance.

public sealed class Performance : IPerformance, IHasPerformanceIdentity, IHasServiceProvider, IDisposable, IBeginsAndEndsPerformance, IEquatable<Performance>
Inheritance
Performance
Implements
Inherited Members

Constructors

Performance(IServiceProvider, IList<IdentifierAndName>, Guid)

Initialises a new instance of Performance

public Performance(IServiceProvider serviceProvider, IList<IdentifierAndName> namingHierarchy = null, Guid performanceIdentity = default)

Parameters

serviceProvider IServiceProvider

A dependency injection service provider

namingHierarchy IList<IdentifierAndName>

A collection of identifiers and names providing the hierarchical name of this performance; see NamingHierarchy for more information.

performanceIdentity Guid

A unique identifier for the performance; if omitted (equal to Empty) then a new Guid will be generated as the identity for this performance

Exceptions

ArgumentNullException

If serviceProvider is null

Properties

NamingHierarchy

Gets an ordered list of identifiers which indicate the current performance's name within an organisational hierarchy.

public List<IdentifierAndName> NamingHierarchy { get; }

Property Value

List<IdentifierAndName>

Examples

If the current performance is to be named Joe can take out the Trash, and it is part of a parent name, named Joe can do his chores then the first identifier in the list will be named Joe can do his chores and the second will be named Joe can take out the Trash.

Remarks

A Screenplay typically contains more than one performance and may contain many. It is normal to organise performances into a hierarchical structure based upon their purpose, role or relationship. The position of the current performance in that naming structure is represented by the value of this property.

The ordered list of IdentifierAndName instances indicate a path from the 'root' of the hierarchy (which has no inherent name) to the current performance. Identifier/name pairs which are earlier in the collection are considered to be closer to the root, whereas latter identifier/names are branch & leaf names. In this manner, they work very similarly to .NET namespaces. The earlier in the list that a name appears, the more general it should be, representing a wider category.

When using Screenplay with Integration, this hierarchy of names would typically correspond to the naming convention used by the testing framework. That might be based upon .NET namespaces, classes and test methods for a more traditional unit testing framework. Alternatively, for a BDD-style testing framework, it could be named based upon human-readable feature & scenario names.

Ideally this property would be immutable after a Performance is created. Unfortunately, some testing frameworks do not expose relevant naming information about a test until after the point of execution where the Performance must be created. Thus, this property is mutable, so that it is possible to 'backfill' missing naming information after the performance has been created. Wherever possible, it is recommended to avoid updating this list of identifier/names and to only set them up when creating the performance, via ICreatesPerformance.

PerformanceIdentity

Gets the unique IPerformance identifier

public Guid PerformanceIdentity { get; }

Property Value

Guid

Remarks

This value is used to uniquely identify a performance within a CSF.Screenplay.

PerformanceState

Gets a value which indicates the state of the current performance.

public PerformanceState PerformanceState { get; }

Property Value

PerformanceState
See Also

ServiceProvider

Gets a service provider/resolver instance associated with this object.

public IServiceProvider ServiceProvider { get; }

Property Value

IServiceProvider

Methods

BeginPerformance()

Begins the performance

public void BeginPerformance()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Equals(Performance)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Performance other)

Parameters

other Performance

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

FinishPerformance(bool?)

Finishes the performance with a value indicating whether or not it was a success

public void FinishPerformance(bool? success)

Parameters

success bool?

If true then the performance is to be considered a success; if false then a failure. A value of null indicates that the performance did not succeed but should not be considered a failure either.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.