public void CopyIfNewerDestinationDoesNotExist() { File.WriteAllText(this.file1, "file"); Copier copier = new Copier(new MemoryLog()); copier.TryCopyIfNewer(this.file1, this.file2).Should().BeTrue(); File.ReadAllText(this.file2).Should().Be("file"); }
public void CopyIfNewerSourceDoesNotExist() { Action action = () => { Copier copier = new Copier(new MemoryLog()); copier.TryCopyIfNewer(this.file1, this.file2); }; action.ShouldThrow<FileNotFoundException>(); }
public void CopyIfNewerSameTime() { File.WriteAllText(this.file1, "file1"); File.Copy(this.file1, this.file2); Copier copier = new Copier(new MemoryLog()); copier.TryCopyIfNewer(this.file1, this.file2).Should().BeFalse(); File.ReadAllText(this.file2).Should().Be("file1"); }
public void CopyIfNewerSourceOlder() { File.WriteAllText(this.file1, "file1"); Thread.Sleep(5); File.WriteAllText(this.file2, "file2"); Copier copier = new Copier(new MemoryLog()); copier.TryCopyIfNewer(this.file1, this.file2).Should().BeFalse(); File.ReadAllText(this.file2).Should().Be("file2"); }