public void LogMessagesLogsToAllLogs() { const string message = "a message"; MemoryLog log1 = new MemoryLog(); MemoryLog log2 = new MemoryLog(); List<ILog> logs = new List<ILog>() { log1, log2 }; logs.LogMessage(message); log1.Log.ToString().Should().Contain(message); log2.Log.ToString().Should().Contain(message); }
public void LogErrorLogsToAllLogs() { const string error = "an error"; MemoryLog log1 = new MemoryLog(); MemoryLog log2 = new MemoryLog(); List<ILog> logs = new List<ILog>() { log1, log2 }; logs.LogError(error); log1.Error.ToString().Should().Contain(error); log2.Error.ToString().Should().Contain(error); }
public void ExceptionsLogged() { File.WriteAllText(this.file1, "some text"); MemoryLog log = new MemoryLog(); Copier copier = new Copier(log); using (var fs = File.Open(this.file1, FileMode.Open)) // open file handle { copier.TryCopy(this.file1, this.file2).Should().BeFalse(); log.Error.ToString().Should().Contain(this.file1); log.Error.ToString().Should().Contain(this.file2); } }
public void ExistingFileOverwritten() { File.WriteAllText(this.file1, "some text"); File.WriteAllText(this.file2, "some other text"); MemoryLog log = new MemoryLog(); Copier copier = new Copier(log); copier.TryCopy(this.file1, this.file2).Should().BeTrue(); File.ReadAllText(this.file2).Should().Be("some text"); log.Log.ToString().Should().Contain(this.file1); log.Log.ToString().Should().Contain(this.file2); }
public void NewFileCreated() { File.WriteAllText(this.file1, "some text"); MemoryLog log = new MemoryLog(); Copier copier = new Copier(log); copier.TryCopy(this.file1, this.file2).Should().BeTrue(); File.ReadAllText(this.file2).Should().Be("some text"); log.Log.ToString().Should().Contain(this.file1); log.Log.ToString().Should().Contain(this.file2); }