Esempio n. 1
0
        public void NotCopyAnIdenticalFile()
        {
            SetupCurrentTestFolder("test-identical-files");

            var sourceFileInfo = new KoreFileInfo(Path.Combine(_sourceFolder, _primaryTestFileName));

            sourceFileInfo.EnsureExists();

            using (var streamWriter = new StreamWriter(sourceFileInfo.FullName))
            {
                streamWriter.Write('c');
            }

            var destinationFileInfo = new KoreFileInfo(Path.Combine(_destinationFolder, _primaryTestFileName));

            destinationFileInfo.EnsureExists();

            var now = DateTime.Now;

            sourceFileInfo.LastWriteTime      = now;
            destinationFileInfo.LastWriteTime = now;


            _kontrol.Sync();

            Assert.IsTrue(destinationFileInfo.Exists);
            Assert.IsTrue(sourceFileInfo.Exists);
            Assert.AreEqual(0, destinationFileInfo.Size);
        }
Esempio n. 2
0
        public void DeleteAnOrphanDestinationFile()
        {
            SetupCurrentTestFolder("test-oprhanr-destination-file");

            var destinationFileInfo = new KoreFileInfo(Path.Combine(_destinationFolder, _primaryTestFileName));

            destinationFileInfo.EnsureExists();

            _kontrol.Sync();

            Assert.IsFalse(destinationFileInfo.Exists);
        }
Esempio n. 3
0
        public void SupportMultipleSyncPairs()
        {
            _currentTest = Path.Combine(CurrentWorkingFolder, "test-multiple-sync-pairs");

            var sourceFolder1 = Path.Combine(_currentTest, "src1");

            EnsureFolderExists(sourceFolder1);

            var sourceFolder2 = Path.Combine(_currentTest, "src2");

            EnsureFolderExists(sourceFolder2);

            var destinationFolder1 = Path.Combine(_currentTest, "dest1");

            EnsureFolderExists(destinationFolder1);

            var destinationFolder2 = Path.Combine(_currentTest, "dest2");

            EnsureFolderExists(destinationFolder2);

            var fileName1       = "file1.txt";
            var sourceFileInfo1 = new KoreFileInfo(Path.Combine(sourceFolder1, fileName1));

            sourceFileInfo1.EnsureExists();

            var fileName2       = "file2.exe";
            var sourceFileInfo2 = new KoreFileInfo(Path.Combine(sourceFolder2, fileName2));

            sourceFileInfo2.EnsureExists();

            _kontrol.Settings.SyncPairs.Add(new SyncPair
            {
                Source      = sourceFolder1,
                Destination = destinationFolder1,
                Level       = SyncLevel.Flat
            });

            _kontrol.Settings.SyncPairs.Add(new SyncPair
            {
                Source      = sourceFolder2,
                Destination = destinationFolder2,
                Level       = SyncLevel.Flat
            });

            _kontrol.Sync();

            var destinationFileInfo1 = new KoreFileInfo(Path.Combine(destinationFolder1, fileName1));
            var destinationFileInfo2 = new KoreFileInfo(Path.Combine(destinationFolder2, fileName2));

            Assert.IsTrue(destinationFileInfo1.Exists);
            Assert.IsTrue(destinationFileInfo2.Exists);
        }
Esempio n. 4
0
        public void CopyANewSourceFile()
        {
            SetupCurrentTestFolder("test-new-source-file");

            var sourceFileInfo = new KoreFileInfo(Path.Combine(_sourceFolder, _primaryTestFileName));

            sourceFileInfo.EnsureExists();

            _kontrol.Sync();

            var destinationFileInfo = new KoreFileInfo(Path.Combine(_destinationFolder, _primaryTestFileName));

            Assert.IsTrue(destinationFileInfo.Exists);
        }
Esempio n. 5
0
        public void CopiesContentAtDestinationUnderSourceParentIfLevelIsParent()
        {
            SetupCurrentTestFolder("test-sync-options-copy-content", SyncLevel.Parent);

            var sourceFileInfo = new KoreFileInfo(Path.Combine(_sourceFolder, _primaryTestFileName));

            sourceFileInfo.EnsureExists();

            _kontrol.Sync();

            var destinationFileInfo = new KoreFileInfo(Path.Combine(_destinationFolder, "src", _primaryTestFileName));

            Assert.IsTrue(destinationFileInfo.Exists);
        }
Esempio n. 6
0
        public void CopyANewerDestinationFile()
        {
            SetupCurrentTestFolder("test-newer-destination-file");

            var now = DateTime.Now;

            var sourceFileInfo = new KoreFileInfo(Path.Combine(_sourceFolder, _primaryTestFileName));

            sourceFileInfo.EnsureExists();
            sourceFileInfo.LastWriteTime = now.AddSeconds(-1);

            var destinationFileInfo = new KoreFileInfo(Path.Combine(_destinationFolder, _primaryTestFileName));

            destinationFileInfo.EnsureExists();
            destinationFileInfo.LastWriteTime = now;

            _kontrol.Sync();

            Assert.AreEqual(now, sourceFileInfo.LastWriteTime);
        }
Esempio n. 7
0
        public void MakeScanInformationAvailable()
        {
            SetupCurrentTestFolder("test-scan-info");

            var now = DateTime.Now;

            var sourceFileInfo = new KoreFileInfo(Path.Combine(_sourceFolder, _primaryTestFileName));

            sourceFileInfo.EnsureExists();
            sourceFileInfo.LastWriteTime = now;

            var destinationFileInfo = new KoreFileInfo(Path.Combine(_destinationFolder, _primaryTestFileName));

            destinationFileInfo.EnsureExists();
            destinationFileInfo.LastWriteTime = now.AddSeconds(-1);

            _kontrol.Sync();

            Assert.AreEqual(1u, _kontrol.SyncInfo.SourceFiles);
            Assert.AreEqual(1u, _kontrol.SyncInfo.DestinationFiles);
            Assert.AreEqual(SyncStatus.Complete, _kontrol.SyncInfo.Status);
        }