Writing Screenplay Extensions
Screenplay ships with a small number of Abilities and performables but it is designed to be extended with new ones. New Abilities, Actions and Questions extend Screenplay by allowing Actors to interact with new APIs, services and libraries.
Broadly-speaking to extend Screenplay in this way you must:
- Write one or more new ability types which provide access to the API of the service or library with which you'd like to interact
- Write one or more Action and/or Question Performables which make use of that ability
Writing abilities
Recall that Abilities represent capabilities & dependencies granted to or associated with Actors. It is normal for developers to want to write new Ability classes in order to provide capabilities/dependencies which are not yet catered-for.
Ability classes do not need to derive from any particular base type, although it is strongly recommended that they implement ICanReport.
Ability classes may constructor-inject dependencies and should declare whatever API is appropriate.
Writing Actions and/or Questions
Hand-in-hand with writing new ability classes, comes writing new Action and/or Question performables.
These classes must derive from an appropriate Performable interface and should also implement ICanReport.
These actions/questions should interact with the ability and make use of its functionality or return a value accordingly.
Recall that actions & questions should be as granular as reasonably possible, accepting whatever parameters are appropriate for the usage of the ability. Continue to follow best practice for performables, though.