This repository has been archived by the owner on Jun 12, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 46
Defining a custom step method
Adam Ralph edited this page Sep 5, 2018
·
11 revisions
If the x
method is not to your taste, it's trivial to define your own synonym(s). E.g.
public static class MyExtensions
{
public static IStepBuilder o(this string text, Action body) => text.x(body);
public static IStepBuilder ʃ(this string text, Action body) => text.x(body);
public static IStepBuilder σʃσ(this string text, Action body) => text.x(body);
public static IStepBuilder 梟(this string text, Action body) => text.x(body);
public static IStepBuilder χ(this string text, Action body) => text.x(body);
}
Note that to support object disposal and async steps you need to provide overloads of your custom step method which accept Action<IStepContext>
, Func<Task>
and Func<IStepContext, Task>
. E.g. the full set of custom step methods for o
would be:
public static class MyExtensions
{
public static IStepBuilder o(this string text, Action body) => text.x(body);
public static IStepBuilder o(this string text, Action<IStepContext> body) => text.x(body);
public static IStepBuilder o(this string text, Func<Task> body) => text.x(body);
public static IStepBuilder o(this string text, Func<IStepContext, Task> body) => text.x(body);
}