Defining a custom step method - adamralph/xbehave.net GitHub Wiki
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);
}