Storyteller 5.1.0


Next

Running Specs from your IDE

Previous

Extensions

Asynchronous Grammars Edit on GitHub


Storyteller 4.0 adds some ability to use asynchronous methods as grammars. As asynchronous programming continues to become so much more prevalant, Storyteller will adapt and add more capabilities. For now, you have these options:


public class AsyncOperationsFixture : Fixture
{
    [FormatAs("Perform a task asynchronously")]
    public Task PerformTask()
    {
        // do something with a method that returns a Task
        return Task.CompletedTask;
    }

    [FormatAs("The current name should be {name}")]
    public Task<string> CheckName()
    {
        // Use an ansynchronous method
        return Task.FromResult("Jeremy");
    }

    [FormatAs("This condition should be true")]
    public Task<bool> IsConditionTrue()
    {
        // Use an asynchronous result
        return Task.FromResult(true);
    }

}

Effectively, all you're doing is allowing Storyteller to worry about the Task's much the same way testing tools like xUnit or mocha do for you today.