gpt4 book ai didi

c# - 在单元测试中模拟对话框

转载 作者:行者123 更新时间:2023-11-30 17:00:20 25 4
gpt4 key购买 nike

请建议如何使用最小起订量在单元测试中模拟以下类型的对话框。

void ShowDialog(string windowName, string parentWindowName, 
Dictionary<string, object> inputFields,
Action<Dictionary<string, object>> closeCallBack,
Dictionary<string, object> windowProperties = null);

我试过以下方法,但没有用:

UIServicemock.Setup(u => u.ShowDialog(It.IsAny<string>, It.IsAny<string>, 
It.IsAny<Dictionary<string,object>>,
It.IsAny<Action<Dictionary<string, object>>>,
It.IsAny<Dictionary<string,object>>));

我想我缺少语法。

最佳答案

It.IsAny<T>() call 是一种方法,因此需要在其后加上括号:

UIServicemock.Setup(u => u.ShowDialog(It.IsAny<string>(), It.IsAny<string>(), 
It.IsAny<Dictionary<string,object>>(),
It.IsAny<Action<Dictionary<string, object>>>(),
It.IsAny<Dictionary<string,object>>()));

关于c# - 在单元测试中模拟对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22372704/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com