Example #1
0
        public void TestSyncPlaceHolders()
        {
            TestCreatePlaceHolders();
            var file1 = new FileInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "b", "c", "file1"));

            file1.Create().Close();
            var dir12 = new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "d", "dir1", "dir2"));

            dir12.Create();

            var config = MainClass.CreateConfiguration();

            config.Directory = _tmpDirInfo;

            var cmd = new SyncCommand();

            cmd.Execute(config);

            Assert.IsFalse(new FileInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "b", "c", ".emptydir")).Exists);
            Assert.AreEqual(1, new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "b", "c")).GetFiles().Length);

            Assert.IsTrue(new FileInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "d", "dir1", "dir2", ".emptydir")).Exists);
            Assert.AreEqual(1, new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "d", "dir1", "dir2")).GetFiles().Length);

            Assert.IsEmpty(_tmpDirInfo.GetFiles());
            Assert.IsEmpty(new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a")).GetFiles());
            Assert.IsEmpty(new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "b")).GetFiles());
            Assert.IsTrue(new FileInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "b", "c", "file1")).Exists);
            Assert.IsEmpty(new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "d")).GetFiles());
            Assert.IsEmpty(new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "d", ".git")).GetFiles());
            Assert.IsEmpty(new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "d", ".git", "store")).GetFiles());
        }
Example #2
0
        public void TestCreatePlaceHoldersWithFollowSymbolicLinks2()
        {
            var config = MainClass.CreateConfiguration();

            config.FollowSymbolicLinks = true;
            config.Directory           = _tmpDirInfo3;

            var cmd = new SyncCommand();

            cmd.Execute(config);

            Assert.AreEqual(1, _tmpDirInfo3.GetFileSystemInfos().Length);
        }
Example #3
0
        public void TestCreatePlaceHoldersWithFollowSymbolicLinks3()
        {
            var config = MainClass.CreateConfiguration();

            config.FollowSymbolicLinks = true;
            config.Directory           = _tmpDirInfo4;

            var cmd = new SyncCommand();

            cmd.Execute(config);

            Assert.AreEqual(1, _tmpDirInfo5.GetFileSystemInfos().Length);
            Assert.IsTrue(new FileInfo(PathUtil.Combine(_tmpDirInfo5.FullName, "dir3", "dir4", ".emptydir")).Exists);
        }
Example #4
0
        public void TestCreatePlaceHolders2()
        {
            var symlinkTestDir = _tmpDirInfo6;

            symlinkTestDir.Create();
            symlinkTestDir.CreateSubdirectory(PathUtil.Combine("foo", "empty"));
            SymbolicLinkHelper.CreateSymbolicLink(new DirectoryInfo(PathUtil.Combine("foo", "empty")), new FileInfo(PathUtil.Combine(TmpDirPath6, "empty")));

            var config = MainClass.CreateConfiguration();

            config.FollowSymbolicLinks = false;
            config.Directory           = symlinkTestDir;

            var cmd = new SyncCommand();

            cmd.Execute(config);

            Assert.AreEqual(1, new DirectoryInfo(PathUtil.Combine(TmpDirPath6, "foo", "empty")).GetFileSystemInfos().Length);
        }
Example #5
0
        public void TestCreatePlaceHolders()
        {
            var config = MainClass.CreateConfiguration();

            config.Directory = _tmpDirInfo;

            var cmd = new SyncCommand();

            cmd.Execute(config);

            Assert.IsTrue(new FileInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "b", "c", ".emptydir")).Exists);
            Assert.AreEqual(1, new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "b", "c")).GetFiles().Length);
            Assert.IsTrue(new FileInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "d", ".emptydir")).Exists);
            Assert.AreEqual(1, new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "d")).GetFiles().Length);
            Assert.AreEqual(2, new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "e")).GetFileSystemInfos().Length);
            Assert.IsEmpty(_tmpDirInfo.GetFiles());
            Assert.IsEmpty(new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a")).GetFiles());
            Assert.IsEmpty(new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "b")).GetFiles());
            Assert.IsEmpty(new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "d", ".git")).GetFiles());
            Assert.IsEmpty(new DirectoryInfo(PathUtil.Combine(_tmpDirInfo.FullName, "a", "d", ".git", "store")).GetFiles());
            Assert.IsEmpty(_tmpDirInfo2.GetFiles());
        }
Example #6
0
        public static void Main(string[] args)
        {
            args = GetDecoratedArgs(args);

            try
            {
                var config = ParseConfiguration(args);

                ICommand cmd;

                if (config.Help)
                {
                    cmd = new HelpCommand {
                        Writer = Console.Out
                    }
                }
                ;
                else if (config.CleanUp)
                {
                    cmd = new CleanCommand();
                }
                else if (config.Purge)
                {
                    cmd = new PurgeCommand();
                }
                else
                {
                    cmd = new SyncCommand();
                }

                cmd.Execute(config);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }