Am trying to rewrite into F# the following C# which mocks up a Log4Net logger with NSubstitute and captures the parameters passed to a Log.ErrorFormat call into the _loggerException string.
string _loggerException = string.Empty;
this.c_logger.When(log => log.ErrorFormat(
Arg.Any<string>(), Arg.Any<string>()))
.Do(logger => _loggerException = logger.Arg<string>().ToString());
The following is the F# I have reached
let mutable _loggerException = System.String.Empty
let _logger = Substitute.For<ILog>()
SubstituteExtensions.When(_logger, _logger.WarnFormat(Arg.Any<string>(), Arg.Any<string>())).Do(fun logger -> _loggerException <- logger.Arg<string>())
However I am getting an error on the second parameter to SubstituteExtensions.When
- _logger.WarnFormat(Arg.Any<string>(), Arg.Any<string>())
as follows:
This expression was expected to have type
Action<ILog>
but here has typeunit
.
Any thoughts on what I am doing wrong?