我正在尝试转换一个我用mocking编写的助手方法
ILogger
用最小起订量来伪装。这个
Log()
伊洛格
Log(LogLevel, EventId, FormattedLogValues, Exception, Func<object, Exception, string>)
docs
):
// Pass up to 4 original call argument values into the method that creates the exception.
A.CallTo(()=>fakeShop.NumberOfSweetsSoldOn(A<DateTime>._))
.Invokes((DateTime when) => System.Console.Out.WriteLine("showing sweet sales for " + when))
.Returns(17);
var logs = new List<string>();
var logger = A.Fake<ILogger<ElasticSearchRepository>>();
A.CallTo(() => logger.Log(A<LogLevel>._, A<EventId>._, A<FormattedLogValues>._, A<Exception>._, A<Func<object, Exception, string>>._))
.Invokes((LogLevel a, EventId b, FormattedLogValues x, Exception c, Func<object, Exception, string> d) => logs.Add(x.ToString()));
... 我得到以下错误
Delegate 'Action<IFakeObjectCall>' does not take 5 arguments
有什么我应该做的不同吗?很难想象有人任意选择4作为可以传递的最大参数,所以我猜这是有原因的。最小起订量
Callback()