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
IServiceProviderA 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
GuidA 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
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
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
- See Also
ServiceProvider
Gets a service provider/resolver instance associated with this object.
public IServiceProvider ServiceProvider { get; }
Property Value
Methods
BeginPerformance()
Begins the performance
public void BeginPerformance()
Dispose()
public void Dispose()
Equals(Performance)
public bool Equals(Performance other)
Parameters
other
Performance
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
obj
object
Returns
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()
public override int GetHashCode()