Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would this Moq code look like in RhinoMocks

Hey people... trying to get my mocking sorted with asp.net MVC.

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.

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);
like image 290
Keith Avatar asked Jun 20 '09 01:06

Keith


1 Answers

If you are using the stub method as opposed to the SetupResult method, then the syntax for this is below:

response.Stub(res => res.ApplyAppPathModifier(Arg<String>.Is.Anything))
                .Do(new Func<string, string>(s => s));
like image 68
DownChapel Avatar answered Nov 14 '22 11:11

DownChapel