public void TestCheckTrackFile() { List <(int, string)> patterns = new() { (2, "*"), (3, "*/cats/*"), (0, "*.jpeg"), (1, "*/dogs/*.jpeg") }; string[] files = new string[] { "/ninjas/hello/batman.jpeg", "/.jpeg", "/af.jpeg", "/cats/jj.jpeg", "/cats/hhh.txt", "/log.txt", "/dogs/goodboy.jpeg", "/cats/dogs/goodboy.jpeg" }; int[] correctoutput = new int[] { 0, 0, 0, 0, 3, 2, 1, 1 }; for (int i = 0; i < files.Length; i++) { Assert.AreEqual(BackupCalculation.FileTrackClass(files[i], patterns), correctoutput[i]); } }
public void TestCheckTrackAnyDirectoryChild() { List <(int, string)> patterns = new() { (2, "*"), (1, "*/cats"), (0, "*.jpeg"), (3, "*/dogs/*.jpeg"), (0, "/dogs*") }; string[] directories = new string[] { "/ninjas/hello", "/af", "/cats", "/dogs/goodboy", "/cats/dogs/goodboy", "/dogs" }; bool[] correctoutput = new bool[] { true, true, true, false, true, false }; for (int i = 0; i < directories.Length; i++) { var res = BackupCalculation.CheckTrackAnyDirectoryChild(directories[i], patterns); Assert.AreEqual(res, correctoutput[i]); } }
public void TestPathMatchesPattern() { string path1 = "a/b/c/d/efg/h.i"; string pattern1 = "*c*g*"; Assert.IsTrue(BackupCalculation.PatternMatchesPath(path1, pattern1)); }