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 SourceFileDoesNotExist() { Action action = () => { Copier copier = new Copier(new MemoryLog()); copier.TryCopy(this.file1, this.file2); }; action.ShouldThrow<FileNotFoundException>(); }
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 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); }