gpt4 book ai didi

c# - 这个最小起订量代码在 RhinoMocks 中会是什么样子

转载 作者:太空狗 更新时间:2023-10-29 18:19:37 25 4
gpt4 key购买 nike

大家好...尝试使用 asp.net MVC 对我的模拟进行排序。

我在网上找到了这个使用 Moq 的例子,基本上我的理解是:当调用 ApplyAppPathModifier 时,返回传递给它的值。

我不知道如何在 Rhino Mocks 中执行此操作,有什么想法吗?

var response = new Mock<HttpResponseBase>();
response.Expect(res => res.ApplyAppPathModifier(It.IsAny<string>()))
.Returns((string virtualPath) => virtualPath);

最佳答案

如果您使用 stub 方法而不是 SetupResult 方法,则语法如下:

response.Stub(res => res.ApplyAppPathModifier(Arg<String>.Is.Anything))
.Do(new Func<string, string>(s => s));

关于c# - 这个最小起订量代码在 RhinoMocks 中会是什么样子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1020673/

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