下面是连贯接口:如何嘲笑连贯接口与犀牛模拟
public interface IReporter<in T,out TResult>
{
IReporter<T, TResult> Add(T seed);
TResult Prepare();
}
使用在代码为:
串errorReport = ErrorReporter.Add(例外)。准备() ;
模拟测试情况:
With.Mocks(mockRepository)
.Expecting(() =>
{
Expect.Call(errorReporter.Add(null)).IgnoreArguments();
Expect.Call(errorReporter.Prepare()).Return(string.Empty);
Expect.Call(notifier.Notify(null)).IgnoreArguments().Return(true);
})
.Verify(() =>
{
ITransporter transporter = new Transporter
{
ExpectedArgsLength = 1,
Notifiers = notifiers,
ErrorReporter = errorReporter
};
transporter.Run(new string[] { });
});
错误:
Rhino.Mocks.Exceptions.ExpectationViolationException:IReporter`2.Prepare();预期#1,实际#0。
If I comment Expect.Call(errorReporter.Prepare())。Return(string.Empty);那么它对我来说没有任何意义。
我错过了什么吗?请帮忙!
如果我按以下方式分解我的代码,那么测试运行良好。 ErrorReporter.Add(例外); string errorReport = ErrorReporter.Prepare();我不想破解我的代码 – milind