Table of Contents

Class StageAdapter

Namespace
CSF.Screenplay
Assembly
CSF.Screenplay.NUnit.dll

An adapter which enables the use of IStage within an NUnit3 test, without needing to parameter-inject the instance as Lazy<IStage>.

public sealed class StageAdapter : IStage
Inheritance
StageAdapter
Implements
Inherited Members

Remarks

Due to NUnit architectural limitations, injectable parameters cannot be resolved from DI at the point the test method is built. If we were to attempt this, then the parameter value would not be associated with the correct Screenplay/DI scope (and thus Event Bus). This is due to the two-process model which NUnit uses; one process for building the test methods and another process for running the tests. By using an adapter with Lazy resolution of the real implementation, we ensure that DI resolution is deferred into the test-run process and not the test-building process.

Constructors

StageAdapter(Guid)

Creates a new instance of StageAdapter for the specified performance identity.

public StageAdapter(Guid performanceIdentity)

Parameters

performanceIdentity Guid

A performance identity, corresponding to PerformanceIdentity.

Properties

Cast

Gets the cast to which the current stage is linked.

public ICast Cast { get; }

Property Value

ICast

Methods

GetSpotlitActor()

Gets the actor which is currently in the spotlight.

public Actor GetSpotlitActor()

Returns

Actor

The actor who has previously been placed in the spotlight, or a null reference if there is presently no actor in the spotlight.

Spotlight(Actor)

Places the specified actor into the spotlight, making them 'the current actor' on this stage.

public void Spotlight(Actor actor)

Parameters

actor Actor

Remarks

A maximum of one actor may be in the spotlight at any time, so if a different actor is already in the spotlight as this method is used, then they will be implicitly removed and replaced by the specified actor. The actor who is in the spotlight may be retrieved by calling GetSpotlitActor().

If the specified actor is already in the spotlight then this method will have no effect, the actor will remain in the spotlight.

To remove an actor from the spotlight without replacing them, use TurnSpotlightOff().

Exceptions

ArgumentNullException

If the actor is null.

Spotlight(IPersona)

Places an actor matching the specified persona into the spotlight, making them 'the current actor' on this stage.

public Actor Spotlight(IPersona persona)

Parameters

persona IPersona

Returns

Actor

The actor instance which was placed into the spotlight.

Remarks

A maximum of one actor may be in the spotlight at any time, so if a different actor is already in the spotlight as this method is used, then they will be implicitly removed and replaced by the actor derived from the persona. The actor who is in the spotlight may be retrieved by calling GetSpotlitActor().

If actor indicated by the persona is already in the spotlight then this method will have no effect, the actor will remain in the spotlight.

When spotlighting a persona, the actor instance is retrieved from an ICast based upon that same persona. See GetActor(IPersona) for more information.

To remove an actor from the spotlight without replacing them, use TurnSpotlightOff().

Consider using Spotlight<TPersona>(IStage) instead of this method; the generic version takes care of resolving the persona instance from dependency injection for you.

Exceptions

ArgumentNullException

If the actor is null.

TurnSpotlightOff()

Removes any existing actor from the spotlight, ensuring that no actor is in the spotlight.

public Actor TurnSpotlightOff()

Returns

Actor

If an actor was previously in the spotlight, and has now been removed, then this method returns that actor; otherwise it will return a null reference.

Remarks

If there was already no actor in the spotlight when this method is executed then it will have no effect, the spotlight will remain empty and this method will return null.