简体   繁体   English

犀牛模拟存根历史

[英]rhino mocks stub history

I have stubbed a method on an interface and want to see with what parameter it was called, but this method is called several times and I'd like to be able to inspect the parameter of each call. 我已经在接口上添加了一个方法,并想知道它被调用了什么参数,但是这个方法被调用了几次,我希望能够检查每个调用的参数。 is there like a stack of the history of calls made to the stub that I can inspect? 我可以检查存根中存根的调用历史记录吗?

my scenario is something like this: 我的情况是这样的:

myStub.AssertWasCalled(stub => stub.SomeMethod(Arg<ISomeInterface>.Matches<ISomeInterface>(p => p.Mode == Mode.SomeEnum)))

You can use GetArgumentsForCallsMadeOn . 您可以使用GetArgumentsForCallsMadeOn

GetArgumentsForCallsMadeOn returns a two dimensional array of objects so you will need to cast to get to the types you are expecting. GetArgumentsForCallsMadeOn返回一个二维对象数组,因此您将需要强制转换为所需的类型。

It works like this: 它是这样的:

  public interface IDependency {
      int DoSomething(SomeComplexType someComplexType,
                            int someInteger);
    }

    IList<object[]> argumentsSentToDoSomething = 
dependency.GetArgumentsForCallsMadeOn(x => x.DoSomething(null, 0));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM