Exemplo n.º 1
0
        public void FullFilePath_Rollover()
        {
            // Create a date time provider that will start off on the current day and simulate a rollover to the next day
            Mock <IDateTimeProvider> rolloverProvider;

            rolloverProvider = new Mock <IDateTimeProvider>();
            rolloverProvider.SetupSequence(x => x.Now)
            .Returns(_currentDate.Date)
            .Returns(_nextDayDate.Date);

            _logPath = new LogFilePath(rolloverProvider.Object, TEST_DIRECTORY, TEST_FILE_NAME, TEST_LOG_EXTENSION);
            _logPath.CheckDate();

            string expectedFormat = $"{TEST_DIRECTORY}{TEST_FILE_NAME}_{_nextDayDate.ToString(DATE_FORMAT)}.{TEST_LOG_EXTENSION}";

            Assert.AreEqual(expectedFormat, _logPath.FullFilePath);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Checks if the file name needs to be updated and logs the message
 /// </summary>
 /// <param name="type">The type of log message</param>
 /// <param name="message">The message to log</param>
 /// <param name="methodName">The method that called</param>
 private void LogMessage(string type, string message, string methodName)
 {
     _logFilePath.CheckDate();
     WriteToFile(_messageGenerator.GenerateLogMessage(Timestamp, ThreadName, methodName, type, message));
 }