![](/img/trans.png)
[英]How can I test if a private method of a class is called or not with rhino mock?
[英]How can I rhino mock a method that returns the passed in argument?
我想要一個模擬的接口方法,該方法返回傳遞給它的值,在這種情況下為字符串。 方法簽名為:
string GetLooUp( string thingToLookUp )
我以為該匿名委托可以工作,但是在此聲明上引發了異常。 也許這不是正確的方法?
Expect.Call( mockIThing.GetLookUp( null ))
.IgnoreArguments()
.Do ( (Func<string, string>) delegate (string value) { return value; })
.Repeat.Any();
我發現了問題。 我在模擬存根接口而不是嚴格的接口。 該模擬工作正常。 應該使用過:
... = mocks.StrictMock< ... >();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.