Skip to content

Async steps

Michael W Powell edited this page Dec 8, 2020 · 1 revision

xWellBehaved.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.AssertNull().Add(x, y));

    "Then the answer is 3".x(() => answer.AssertEquals(3));
}
Clone this wiki locally