StoryQ When() calling task C#

∥☆過路亽.° 提交于 2019-12-11 01:01:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!