开发者

Mocking method call with out param and no return value in Rhino Mocks

开发者 https://www.devze.com 2022-12-19 09:56 出处:网络
So I\'ve got this method called LoginUser: public void LoginUser(out SystemUse开发者_JAVA百科r userToLogin, string username)

So I've got this method called LoginUser:

public void LoginUser(out SystemUse开发者_JAVA百科r userToLogin, string username)

Having just started with Rhino Mocks, I'm having a little trouble mocking a call and return value from this method while testing my Presenter code. What's the correct syntax in this instance?


Does this blog post help? Code sample:

IList<RecordModel> ReadPaged(int pageNumber, int pageSize, out int recordCount);
...
recordRepositoryStub
 .Stub(m => m.ReadPaged(pageNumber, pageSize, out recordCount))
 .OutRef(250)
 .Return(records);

Basically, look for the OutRef method and use that to return the right result :)

As an aside, does your method have to be in that form? Using an out parameter in a void method is usually a bit of a design smell.

0

精彩评论

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

关注公众号