Я хотел бы знать, как я могу реализовать модульный тест для этого метода
private void ConfigLogging(IConfigurationRoot configuration)
{
var nLogConfigFile = Path.Combine(configuration["environment:root"], "configs", configuration["application:configDirectory"], configuration["application:id"] + "_NLog.config");
if (File.Exists(nLogConfigFile))
{
LogManager.Configuration = new LoggingConfiguration();
LogManager.LoadConfiguration(nLogConfigFile);
}
else
{
var logFilePath = Path.Combine(configuration["environment:root"], "logs", configuration["application:logDirectory"], configuration["application:id"] + ".log");
var loggingConfiguration = new LoggingConfiguration();
var logFile = new FileTarget("logfile")
{
FileName = logFilePath,
Layout = new SimpleLayout("${longdate}|${appdomain}-${assembly-version}|${pad:padding=5:inner=${level:uppercase=true}}|Job: ${pad:padding=8:inner=${var:JobId}}|Thread: ${threadid}|${pad:padding=25:inner=${logger:shortName=true}}|${message} ${when:when=length('${exception}')>0:inner=[Exception=${exception}]}${newline:when=length('${exception}')>0}${exception:format=toString,Data:maxInnerExceptionLevel=10:exceptionDataSeparator=\r\n}"),
Footer = new SimpleLayout("${longdate}|${appdomain}-${assembly-version}|=====Application stopped====="),
ArchiveNumbering = ArchiveNumberingMode.Date,
ArchiveEvery = FileArchivePeriod.Day
};
loggingConfiguration.AddRule(NLog.LogLevel.Info, NLog.LogLevel.Fatal, logFile);
LogManager.Configuration = loggingConfiguration;
}
LogManager.KeepVariablesOnReload = true;
if (!LogManager.Configuration.Variables.ContainsKey("JobId"))
{
LogManager.Configuration.Variables.Add("JobId", new SimpleLayout(string.Empty));
}
#if DEBUG
var debugOutput = new OutputDebugStringTarget("debugoutput");
LogManager.Configuration.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, debugOutput);
LogManager.ReconfigExistingLoggers();
#endif
}