Moq代码在RhinoMocks中是什么样的 [英] What would this Moq code look like in RhinoMocks
本文介绍了Moq代码在RhinoMocks中是什么样的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿人们...试图用asp.net MVC对我的嘲笑进行排序.
Hey people... trying to get my mocking sorted with asp.net MVC.
我已经使用Moq在网上找到了这个示例,基本上我理解它是说:调用ApplyAppPathModifier时,返回传递给它的值.
I've found this example on the net using Moq, basically I'm understanding it to say: when ApplyAppPathModifier is called, return the value that was passed to it.
有什么想法,我想不通如何在Rhino Mocks中做到这一点?
I cant figure out how to do this in Rhino Mocks, any thoughts?
var response = new Mock<HttpResponseBase>();
response.Expect(res => res.ApplyAppPathModifier(It.IsAny<string>()))
.Returns((string virtualPath) => virtualPath);
推荐答案
正如我上面提到的,草皮法",一旦您寻求帮助,便会在5分钟后找到它(即使搜索了一段时间).无论如何,为了他人的利益,这行得通:
As I mentioned above, sods law, once you post for help you find it 5 min later (even after searching for a while). Anyway for the benefit of others this works:
SetupResult
.For<string>(response.ApplyAppPathModifier(Arg<String>.Is.Anything)).IgnoreArguments()
.Do((Func<string, string>)((arg) => { return arg; }));
这篇关于Moq代码在RhinoMocks中是什么样的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文