Class ReportFragment
- Namespace
- CSF.Screenplay
- Assembly
- CSF.Screenplay.Abstractions.dll
A model for a fragment of a report upon a IPerformance.
public sealed class ReportFragment
- Inheritance
-
ReportFragment
- Inherited Members
Examples
An example of a template string is "{Actor} washes {Count} dishes"
.
This template expects two placeholder values for Actor
& Count
.
A sample FormattedFragment which might result from this could be "Joe washes 5 dishes"
.
Remarks
A report fragment is typically human readable summary of the execution of a single performable item or the assignment of an ability to an Actor (the actor "gaining" an ability). A complete report about an IPerformance would usually contain many such fragments, organised hierarchically where performables consume & execute performables themselves. This creates a nested structure where the outermost report fragments describe higher-level performables, with lower-level performables contained within.
Report fragments are created from a template, which is a human-readable string with named placeholders, using a syntax which is very similar
to the way in which Microsoft.Extensions.Logging uses template strings: https://learn.microsoft.com/en-us/dotnet/core/extensions/logging.
The template may have any number of placeholders, which are names enclosed within braces, such as {Actor}
.
These placeholders are then populated with a collection of values which are provided to fill those placeholders.
The result is a completely formatted, human-readable report fragment string.
This model holds the result of this formatting process, the implementation of IFormatsReportFragment is responsible for performing the formatting itself.
Constructors
ReportFragment(string, string, IReadOnlyList<NameAndValue>)
Initializes a new instance of ReportFragment.
public ReportFragment(string originalTemplate, string formattedFragment, IReadOnlyList<NameAndValue> placeholderValues)
Parameters
originalTemplate
stringThe original template string
formattedFragment
stringThe formatted report fragment
placeholderValues
IReadOnlyList<NameAndValue>The placeholder values
Exceptions
- ArgumentNullException
If any parameter is null.
Properties
FormattedFragment
Gets the formatted report fragment, after placeholder substitution has taken place.
public string FormattedFragment { get; }
Property Value
OriginalTemplate
Gets the original template string for this report fragment, without placeholder substitution.
public string OriginalTemplate { get; }
Property Value
PlaceholderValues
Gets a collection of the placeholder values, and the placeholder names to which those values correspond.
public IReadOnlyList<NameAndValue> PlaceholderValues { get; }
Property Value
Methods
ToString()
public override string ToString()