Async steps - adamralph/xbehave.net GitHub Wiki

xBehave.net provides the ability to define asynchronous steps using the async and await keywords.

[Scenario]
public void Addition(int x, int y, AsyncCalculator calculator, int answer)
{
    "Given the number 1"
        .x(() => x = 1);

    "And the number 2"
        .x(() => y = 2);

    "And an asynchronous calculator"
        .x(() => calculator = new AsyncCalculator());

    "When I add the numbers together"
        .x(async () => answer = await calculator.Add(x, y));

    "Then the answer is 3"
        .x(() => answer.Should().Be(3));
}