StoryQ When()调用任务C#

编程入门 行业动态 更新时间:2024-10-25 00:32:34
本文介绍了StoryQ When()调用任务C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用storyQ将此单元测试转换为BDD 工作单元测试

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() { .... }

转换为BDD

[Test] public async Task CreateNewProjectAndDatabase() { _story.WithScenario("Create a new bla bla") .Given(StartParametersAndAteEngineDlls) .When(async ()=> await TheNewDatabaseAndProjectIsCreated()) .Then(TheDataBaseViewModelIsCreated) .And(TheMainViewModelIsCreated) .Execute(); }

代码正在编译,但是我得到了ArgumentException 如果您在方法名称中使用2个下划线,请确保有2个参数(找到0)

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)

推荐答案

我知道我来晚了.我遇到了同样的问题,我修改了它的执行方式,更改了When方法的执行方式.我没有使用await和执行任务,而是在While方法中使用了oldSchool函数"Wait".这样,我们可以拥有StoryQ可以理解的私有void函数.

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.

类似这样的东西.

private void MyWhenMethod() { _sut.AsyncMethodRun().Wait() }

更多推荐

StoryQ When()调用任务C#

本文发布于:2023-11-12 01:35:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580140.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:StoryQ

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!