开发者

How do I use Rhino.Mocks.RhinoMocksExtensions.VoidType with lambda Expect?

I get the following error on this line:

session.Expect(s => s.Add("string", null)).IgnoreArguments().Return(SaveMockUser());

cannot convert from 'void' to 'Rhino.Mocks.RhinoMocksExtensions.VoidType'

SaveMockUser is defined as 开发者_开发知识库follows

private void SaveMockUser()
{
}

What am I doing wrong?


It's not possible to return a void type. Probably what you want to do is have another expectation that expects that SaveMockUser() is actually called or actually perform the action via a callback - i.e., when you see this function called, then do this.

session.Expect( s => s.Add("string", null) )
       .IgnoreArguments()
       .WhenCalled( x => SaveMockUser() );

or even better - use the new inline constraints

session.Expect( s => s.Add( Arg<string>.Is.Equal( "string" ), Arg<string>.Is.Anything ) )
       .WhenCalled( x => SaveMockUser() );
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜