Table of Contents

Class ScreenplayLocator

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

A small static service locator of sorts, dedicated to getting an appropriate instance of Screenplay for a specified test object.

public static class ScreenplayLocator
Inheritance
ScreenplayLocator
Inherited Members

Remarks

This type uses reflection to find the ScreenplayAssemblyAttribute which decorates the assembly in which the specified object (a test, a test method or the assembly itself) resides. It additionally caches the results in-memory to avoid repetitive reflection, only to retrieve the same results.

Methods

GetScreenplay(IMethodInfo)

Gets a Screenplay instance from the specified test method.

public static Screenplay GetScreenplay(IMethodInfo method)

Parameters

method IMethodInfo

The test method for which to get a Screenplay object.

Returns

Screenplay

The Screenplay object for the specified test method.

Remarks

This method makes use of the ScreenplayAssemblyAttribute which decorates the assembly in which the specified method was declared, to get a Screenplay object instance applicable to the test method. If the method's assembly is not decorated with the Screenplay assembly attribute then this method will raise an exception.

Exceptions

ArgumentNullException

If method is null.

ArgumentException

If the method's assembly is null or is not decorated with ScreenplayAssemblyAttribute.

GetScreenplay(ITest)

Gets a Screenplay instance from the specified test.

public static Screenplay GetScreenplay(ITest test)

Parameters

test ITest

The test for which to get a Screenplay object.

Returns

Screenplay

The Screenplay object for the specified test.

Remarks

This method makes use of the ScreenplayAssemblyAttribute which decorates the assembly in which the specified test's method was declared, to get a Screenplay object instance applicable to the test method. If the test's method's assembly is not decorated with the Screenplay assembly attribute then this method will raise an exception.

Exceptions

ArgumentNullException

If test is null.

ArgumentException

If the test's method's assembly is null or is not decorated with ScreenplayAssemblyAttribute.

GetScreenplay(Assembly)

Gets a Screenplay instance from the specified Assembly.

public static Screenplay GetScreenplay(Assembly assembly)

Parameters

assembly Assembly

The test assembly for which to get a Screenplay object.

Returns

Screenplay

The Screenplay object for the specified assembly.

Remarks

This method makes use of the ScreenplayAssemblyAttribute which decorates the assembly to get a Screenplay object instance for that assembly. If the specified assembly is not decorated with the Screenplay assembly attribute then this method will raise an exception.

Exceptions

ArgumentNullException

If assembly is null.

ArgumentException

If the assembly is not decorated with ScreenplayAssemblyAttribute.