开发者

How can I rhino mock a method that returns the passed in argument?

开发者 https://www.devze.com 2023-01-12 20:09 出处:网络
I want a mocked interface method that returns the value that is passed in to it, in this case a string. The method signature is:

I want a mocked interface method that returns the value that is passed in to it, in this case a string. The method signature is:

string GetLooUp( string thingToLookUp )

I thought this anonymous delegate would work, but it throws an exception on this declaration. Maybe this isn't the right approach?

  Expect.Call( mockIThing.GetLookUp( null ))
     开发者_如何学JAVA   .IgnoreArguments()
        .Do ( (Func<string, string>) delegate (string value) { return value; })
        .Repeat.Any();


I discovered the problem. I was mocking a stub interface rather than a strict interface. This mock works fine. Should have used:

 ... = mocks.StrictMock< ... >();
0

精彩评论

暂无评论...
验证码 换一张
取 消