Skip to content
This repository has been archived by the owner on Jun 12, 2021. It is now read-only.

Defining a custom step method

Adam Ralph edited this page Jul 14, 2015 · 11 revisions

If the x, f and _ methods are not to your taste, it's trivial to define your own synonym(s). E.g.

public static class MyExtensions
{
    public static IStep o(this string text, Action body)
    {
        return text.f(body);
    }

    public static IStep ʃ(this string text, Action body)
    {
        return text.f(body);
    }

    public static IStep σʃσ(this string text, Action body)
    {
        return text.f(body);
    }

    public static IStep (this string text, Action body)
    {
        return text.f(body);
    }

    public static IStep χ(this string text, Action body)
    {
        return text.f(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 IStep o(this string text, Action body)
    {
        return text.f(body);
    }

    public static IStep o(this string text, Action<IStepContext> body)
    {
        return text.f(body);
    }

    public static IStep o(this string text, Func<Task> body)
    {
        return text.f(body);
    }

    public static IStep o(this string text, Func<IStepContext, Task> body)
    {
        return text.f(body);
    }
}
Clone this wiki locally