Exemple #1
0
        public void DestinationNoExist()
        {
            var src  = NewFile("foo");
            var dest = NewFile();

            var task = new CopyIfChanged {
                BuildEngine      = new MockBuildEngine(TestContext.Out),
                SourceFiles      = ToArray(src),
                DestinationFiles = ToArray(dest),
            };

            Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded.");
            Assert.AreEqual(1, task.ModifiedFiles.Length, "Changes should have been made.");
        }
        public void NoChange()
        {
            var src  = NewFile("foo");
            var dest = NewFile("foo");
            var now  = DateTime.UtcNow;

            File.SetLastWriteTimeUtc(src, now);
            File.SetLastWriteTimeUtc(dest, now);

            var task = new CopyIfChanged {
                BuildEngine      = new MockBuildEngine(TestContext.Out),
                SourceFiles      = ToArray(src),
                DestinationFiles = ToArray(dest),
            };

            Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded.");
            Assert.AreEqual(0, task.ModifiedFiles.Length, "No changes should have been made.");
        }
Exemple #3
0
        public void SourceOlderDifferentLength()
        {
            var src  = NewFile("foo");
            var dest = NewFile("foofoo");
            var now  = DateTime.UtcNow;

            File.SetLastWriteTimeUtc(src, now.AddSeconds(-1));               // source is older
            File.SetLastWriteTimeUtc(dest, now);

            var task = new CopyIfChanged {
                BuildEngine      = new MockBuildEngine(TestContext.Out),
                SourceFiles      = ToArray(src),
                DestinationFiles = ToArray(dest),
            };

            Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded.");
            Assert.AreEqual(1, task.ModifiedFiles.Length, "Changes should have been made.");
        }
        public void DestinationOlderNoLengthCheck()
        {
            var src  = NewFile("foo");
            var dest = NewFile("bar");
            var now  = DateTime.UtcNow;

            File.SetLastWriteTimeUtc(src, now);
            File.SetLastWriteTimeUtc(dest, now.AddSeconds(-1));               // destination is older

            var task = new CopyIfChanged {
                BuildEngine        = new MockBuildEngine(TestContext.Out),
                SourceFiles        = ToArray(src),
                DestinationFiles   = ToArray(dest),
                CompareFileLengths = false,
            };

            Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded.");
            Assert.AreEqual(1, task.ModifiedFiles.Length, "Changes should have been made.");
            FileAssert.AreEqual(src, dest);
        }
        public void CaseChanges()
        {
            var src  = NewFile(contents: "Foo");
            var dest = NewFile(contents: "foo", fileName: "foo");
            var now  = DateTime.UtcNow;

            File.SetLastWriteTimeUtc(src, now);
            File.SetLastWriteTimeUtc(dest, now.AddSeconds(-1));               // destination is older

            dest = dest.Replace("foo", "Foo");
            var task = new CopyIfChanged {
                BuildEngine      = new MockBuildEngine(TestContext.Out),
                SourceFiles      = ToArray(src),
                DestinationFiles = ToArray(dest),
            };

            Assert.IsTrue(task.Execute(), "task.Execute() should have succeeded.");
            Assert.AreEqual(1, task.ModifiedFiles.Length, "Changes should have been made.");
            FileAssert.AreEqual(src, dest);

            var files = Directory.GetFiles(Path.GetDirectoryName(dest), "Foo");

            Assert.AreEqual("Foo", Path.GetFileName(files [0]), "File name should match");
        }