Interface IFormatsReportFragment
- Namespace
- CSF.Screenplay
- Assembly
- CSF.Screenplay.Abstractions.dll
A service which produces formatted report fragments from a template and a collection of parameter values.
public interface IFormatsReportFragment
Methods
Format(string, params object[])
Gets the formatted report fragment from the specified template and values.
ReportFragment Format(string template, params object[] values)
Parameters
template
stringA string template for the report fragment
values
object[]A collection of values associated with the report fragment
Returns
- ReportFragment
A formatted report fragment
Examples
The following code will produce the final formatted string as noted below.
var p1 = "first";
var p2 = "second";
formatter.Format("The values are {p2} and {p1}", p1, p2);
// This will yield the result "The values are first and second"
Remarks
The template
should be a human-readable string (localized if you wish) which would be recorded in a
Screenplay report.
This string may contain any number of placeholder markers which are indicated by some text enclosed within
braces, such as {Name}
.
This functions in a slightly similar fashion to .NET logging:
https://learn.microsoft.com/en-us/dotnet/core/extensions/logging?tabs=command-line#log-message-template
or the Format(string, params object[]) method.
Importantly, the placeholders are identified by names, rather than numeric index, in the same way that logging template strings work. Placeholders do not support any kind of format or alignment syntax.
Developers are encouraged to choose meaningful names for their placeholders.
The ReportFragment which is produced by this method will include the values
associated with those placeholder names.
This allows reporting infrastructure to work in a similar manner to the way in which structured logging is described in
the article linked above.
This provides a richer data model than simply a plain string.
- See Also