public void ChangingApplicationLogFilePathResultsInANewLogBeingCreated() { // Act var logManager = new LogManager(this.mockDateTimeStamper, this.applicationLogFilePath); logManager.WriteMessageToApplicationLog("Application log file."); logManager.Close(); logManager.ApplicationLogFilePath = this.alternativeApplicationLogFilePath; logManager.WriteMessageToApplicationLog("Alteranative application log file."); logManager.Close(); // Assert File.Exists(this.applicationLogFilePath).ShouldBeTrue(); File.Exists(this.alternativeApplicationLogFilePath).ShouldBeTrue(); }
public void ApplicationLogFileNotCreatedWhenLogManagerIsInstantiated() { // Act var logManager = new LogManager(this.mockDateTimeStamper, this.applicationLogFilePath); logManager.Close(); // Assert File.Exists(this.applicationLogFilePath).Should().BeFalse(); }
public void WritingMessagesToJobLogAndClosingCreatesValidLog() { // Arrange var logManager = new LogManager(this.mockDateTimeStamper, this.applicationLogFilePath); logManager.JobLogFilePath = this.jobLogFilePath; // Act WriteMessagesToJobLog(logManager); logManager.Close(); // Assert File.Exists(this.jobLogFilePath).Should().BeTrue(); var logFileLines = File.ReadAllLines(this.jobLogFilePath); AssertLogFileContentsAreCorrect(logFileLines); }
public void MessagesInOpenJobLogCanBeReadByOtherReader() { // Arrange var logManager = new LogManager(this.mockDateTimeStamper, this.applicationLogFilePath); logManager.JobLogFilePath = this.jobLogFilePath; try { // Act WriteMessagesToJobLog(logManager); // Assert File.Exists(this.jobLogFilePath).Should().BeTrue(); var logFileLines = GetOpenLogFileContent(this.jobLogFilePath); AssertLogFileContentsAreCorrect(logFileLines); } finally { // Teardown logManager.Close(); } }