问题
I want to convert this unit test into BDD using storyQ working unit test
[Test]
public async void CreateNewProjectAndDatabase()
{
StartParametersAndAteEngineDlls();
await TheNewDatabaseAndProjectIsCreated();
TheDataBaseViewModelIsCreated();
TheMainViewModelIsCreated();
}
private async Task TheNewDatabaseAndProjectIsCreated()
{
....
}
converted to BDD
[Test]
public async Task CreateNewProjectAndDatabase()
{
_story.WithScenario("Create a new bla bla")
.Given(StartParametersAndAteEngineDlls)
.When(async ()=> await TheNewDatabaseAndProjectIsCreated())
.Then(TheDataBaseViewModelIsCreated)
.And(TheMainViewModelIsCreated)
.Execute();
}
the code is code is compiling however I get an ArgumentException If you use 2 underscores in your method name, make sure there's 2 arguments (found 0)
回答1:
I know I'm a bit late. I had the same problem I fixed it changing the way I execute the When method. Instead of using await and having a Task I used the oldSchool function "Wait" inside the When method. In that way we can have a private void function that StoryQ understand.
Something like this.
private void MyWhenMethod()
{
_sut.AsyncMethodRun().Wait()
}
来源:https://stackoverflow.com/questions/46888815/storyq-when-calling-task-c-sharp