Пример #1
0
        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");
        }
Пример #2
0
 public void CopyIfNewerSourceDoesNotExist()
 {
     Action action = () =>
         {
             Copier copier = new Copier(new MemoryLog());
             copier.TryCopyIfNewer(this.file1, this.file2);
         };
     action.ShouldThrow<FileNotFoundException>();
 }
Пример #3
0
        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");
        }
Пример #4
0
        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");
        }