Beispiel #1
0
        public void MultipleCleanups()
        {
            using (var directoryTester = new DirectoryTester($"{this.GetType().Name}/AA"))
            {
                directoryTester.UpdateTo(new string[]
                {
                    $"aa.txt < 1",
                    $"aa.txt{HelixConsts.StagedHxExtention} < 2",
                    $"bb.txt{HelixConsts.BackupExtention} < 2",
                    $"cc/",
                    $"cc/dd.txt{HelixConsts.BackupExtention} < 4",
                });

                CleanupCommand.Cleanup(new CleanupOptions {
                    DecrDirectory = directoryTester.DirectoryPath
                });

                directoryTester.AssertEqual(new string[]
                {
                    $"aa.txt < 1",
                    $"bb.txt < 2",
                    $"cc/",
                    $"cc/dd.txt < 4",
                });
            }
        }
        public void WildcardMatching()
        {
            using (DirectoryTester tester = new DirectoryTester("test1"))
            {
                tester.UpdateTo(new string[]
                {
                    "file1.txt:5 < aa",
                });

                tester.AssertEqual(new string[]
                {
                    "file1.txt:* < aa"
                });
                tester.AssertEqual(new string[]
                {
                    "file1.txt:5 < *"
                });

                Assert.ThrowsException <DirectoryTester.DirectoryMismatchException>(
                    () => tester.AssertEqual(new string[] { "file2.txt" }));
                Assert.ThrowsException <DirectoryTester.DirectoryMismatchException>(
                    () => tester.AssertEqual(new string[] { "file1.txt:4 < aa" }));
                Assert.ThrowsException <DirectoryTester.DirectoryMismatchException>(
                    () => tester.AssertEqual(new string[] { "file1.txt:5 < qq" }));
            }
        }
 public void DirectoryAreEqual(DirectoryTester tester, string content, string message)
 {
     if (string.IsNullOrEmpty(message))
     {
         Assert.AreEqual(new DirectoryTester.DirectoryEntryCollection(content).ToString(), tester.GetContent().ToString());
     }
     else
     {
         Assert.IsTrue(new DirectoryTester.DirectoryEntryCollection(content).ToString() == tester.GetContent().ToString(),
                       message);
     }
 }
        public IntegratedDirectoryTester()
        {
            BaseDir = this.GetType().Name;
            Decr1   = new DirectoryTester($"{BaseDir}/Decr1", new Regex(@"\.helix.*"));
            Decr2   = new DirectoryTester($"{BaseDir}/Decr2", new Regex(@"\.helix.*"));
            Encr1   = new DirectoryTester($"{BaseDir}/Encr1");
            Encr2   = new DirectoryTester($"{BaseDir}/Encr2");

            Decr1.Clear(true);
            Decr2.Clear(true);
            Encr1.Clear(true);
            Encr2.Clear(true);
            Assert.IsFalse(Directory.Exists(Decr1.DirectoryPath));
            Assert.IsFalse(Directory.Exists(Decr2.DirectoryPath));
            Assert.IsFalse(Directory.Exists(Encr1.DirectoryPath));
            Assert.IsFalse(Directory.Exists(Encr2.DirectoryPath));
        }
Beispiel #5
0
 public void CleanupWithStagedFiles()
 {
     using (var directoryTester = new DirectoryTester($"{this.GetType().Name}/AA"))
     {
         directoryTester.UpdateTo(new string[]
         {
             $"aa.txt < 1",
             $"aa.txt{HelixConsts.StagedHxExtention} < 2",
         });
         CleanupCommand.Cleanup(new CleanupOptions {
             DecrDirectory = directoryTester.DirectoryPath
         });
         directoryTester.AssertEqual(new string[]
         {
             "aa.txt < 1",
         });
     }
 }
        public void DirectoryTester_Test()
        {
            using (DirectoryTester tester = new DirectoryTester("test1"))
            {
                tester.UpdateTo(new string[]
                {
                    "bb/file1.txt:0 < aa",
                    "aa/file2.txt:2 < bb",
                    "xxx/:0 "
                });

                tester.AssertEqual(new string[]
                {
                    "bb/file1.txt:0 < aa",
                    "aa/file2.txt:2 < bb",
                    "xxx/:0 "
                });
            }
        }
Beispiel #7
0
        public void WhatIf()
        {
            //What If
            using (var directoryTester = new DirectoryTester($"{this.GetType().Name}/AA"))
            {
                directoryTester.UpdateTo(new string[]
                {
                    $"aa.txt < 1",
                    $"aa.txt{HelixConsts.StagedHxExtention} < 2",
                    $"bb.txt{HelixConsts.BackupExtention} < 2",
                });

                CleanupCommand.Cleanup(new CleanupOptions {
                    DecrDirectory = directoryTester.DirectoryPath, WhatIf = true
                });

                directoryTester.AssertEqual(new string[]
                {
                    $"aa.txt < 1",
                    $"aa.txt{HelixConsts.StagedHxExtention} < 2",
                    $"bb.txt{HelixConsts.BackupExtention} < 2",
                });
            }
        }