public void ReturnsDatetimeAsMillisecondsWithCustomExtension() { var formatter = new MillisecondsArchiveFileNameFormatter("json"); var expected = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds(); var result = formatter.Format(); Assert.IsTrue(result.Contains(".json")); var milliseconds = long.Parse(result.Split('.')[0]); Assert.AreEqual(expected, milliseconds); }
static ILogWriter CreateErrorsFileWriter() { var errorsFileInfo = new SystemFileInfo("errors.txt"); var errorsChecker = new SizeArchiveNecessityChecker(errorsFileInfo, 100, MemoryUnit.B); var fileNameFormatter = new MillisecondsArchiveFileNameFormatter("json"); var errorsArchiver = new FileArchiver(errorsFileInfo, "Archive_Errors", errorsChecker, fileNameFormatter: fileNameFormatter); var logLevels = new LogLevel[] { LogLevel.ERROR, LogLevel.FATAL }; return(FileLogWriter.Builder() .SetFileInfo(errorsFileInfo) .SetFileArchiver(errorsArchiver) .SetAllowedLogLevels(logLevels) .Build()); }