Exemple #1
0
 private void TestFindPath(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string tagname = parameters[0].Trim();
     string path = parameters[1].Trim();
     bool filtered = bool.Parse(parameters[2].Trim());
     Tag tag = FindTag(tagname);
     if (tag != null)
     {
         TaggedPath taggedpath = tag.FindPath(path, filtered);
         testcase.Actual = ((taggedpath != null) ? "Not null" : "Null");
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemple #2
0
 private void TestRetrieveDescendants(TestCase testcase)
 {
     string path = testcase.Parameters;
     List<string> descendants = _logic.RetrieveDescendants(path);
     descendants.Sort();
     string result = "";
     foreach (string descendant in descendants)
     {
         result += (descendant + " ");
     }
     testcase.Actual = result.Trim();
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #3
0
 private void TestDeleteTag(TestCase testcase)
 {
     string tagname = testcase.Parameters;
     try
     {
         Tag tag = _logic.DeleteTag(tagname);
         testcase.Actual = string.Format("{0}", tag.IsDeleted.ToString());
     }
     catch (TagNotFoundException)
     {
         testcase.Actual = "TagNotFoundException";
     }
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #4
0
 private void TestTagFolder(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string path = parameters[0].Trim();
     string tagname = parameters[1].Trim();
     try
     {
         Tag tag = _logic.TagFolder(path, tagname);
         testcase.Actual = string.Format("{0}, {1}", tag.TagName, tag.UnfilteredPathList.Count.ToString());
     }
     catch (PathAlreadyExistsException)
     {
         testcase.Actual = "PathAlreadyExistsException";
     }
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #5
0
 private void TestRetrieveAllTags(TestCase testcase)
 {
     bool getdeleted = bool.Parse(testcase.Parameters);
     List<Tag> taglist = _logic.RetrieveAllTags(getdeleted);
     testcase.Actual = taglist.Count.ToString();
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #6
0
 private void TestRenameFolder(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string oldpath = parameters[0].Trim();
     string newpath = parameters[1].Trim();
     int renamedCount = _logic.RenameFolder(oldpath, newpath);
     //List<string> renamedpathlist = new List<string>();
     //foreach (string p in _logic.GetAllPaths())
     //{
     //    if (p.StartsWith(newpath))
     //    {
     //        renamedpathlist.Add(p);
     //    }
     //}
     //renamedpathlist.Sort();
     //string result = "";
     //foreach (string renamed in renamedpathlist)
     //{
     //    result += (renamed + " ");
     //}
     testcase.Actual = renamedCount.ToString();
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #7
0
 private void TestRenamePath(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string tagname = parameters[0].Trim();
     string oldpath = parameters[1].Trim();
     string newpath = parameters[2].Trim();
     Tag tag = FindTag(tagname);
     if (tag != null)
     {
         string renamecount = tag.RenamePath(oldpath, newpath, DateTime.Now.Ticks).ToString();
         testcase.Actual = renamecount;
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemple #8
0
 private void TestRetrievePathByLogicalId(TestCase testcase)
 {
     string logicalid = testcase.Parameters;
     List<string> pathlist = _logic.RetrievePathByLogicalId(logicalid);
     string result = "";
     foreach (string path in pathlist)
     {
         result += (path + " ");
     }
     testcase.Actual = pathlist.Count.ToString();
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #9
0
 private void TestRemoveAllPaths(TestCase testcase)
 {
     string tagname = testcase.Parameters;
     Tag tag = FindTag(tagname);
     bool allremoved = true;
     if (tag != null)
     {
         tag.RemoveAllPaths();
         foreach (TaggedPath path in tag.UnfilteredPathList)
         {
             if (!path.IsDeleted)
             {
                 allremoved = false;
                 break;
             }
         }
         testcase.Actual = allremoved.ToString();
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemple #10
0
 private void TestRemovePathString(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string tagname = parameters[0].Trim();
     string path = parameters[1].Trim();
     Tag tag = FindTag(tagname);
     if (tag != null)
     {
         string success = tag.RemovePath(path, DateTime.Now.Ticks).ToString();
         TaggedPath removedpath = tag.FindPath(path, false);
         string isdeleted = removedpath.IsDeleted.ToString();
         testcase.Actual = string.Format("{0}, {1}", success, isdeleted);
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemple #11
0
 private void TestContainsParent(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string tagname = parameters[0].Trim();
     string path = parameters[1].Trim();
     bool ignores = bool.Parse(parameters[2].Trim());
     Tag tag = FindTag(tagname);
     string success;
     if (tag != null)
     {
         if (ignores)
         {
             success = tag.ContainsParentIgnoreDeleted(path).ToString();
         }
         else
         {
             success = tag.ContainsParent(path).ToString();
         }
         testcase.Actual = success;
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemple #12
0
 private void TestCreateTrailingPath(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string tagname = parameters[0].Trim();
     string path = parameters[1].Trim();
     Tag tag = FindTag(tagname);
     if (tag != null)
     {
         string result = tag.CreateTrailingPath(path);
         testcase.Actual = ((result != null) ? result : "Null");
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemple #13
0
 private void TestAddFilter(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string tagname = parameters[0].Trim();
     string pattern = parameters[1].Trim();
     FilterMode mode = (bool.Parse(parameters[2].Trim()) ? FilterMode.INCLUDE : FilterMode.EXCLUDE);
     Tag tag = FindTag(tagname);
     if (tag != null)
     {
         Filter filter = FilterFactory.CreateExtensionFilter(pattern, mode);
         tag.AddFilter(filter, DateTime.Now.Ticks);
         testcase.Actual = tag.Filters.Count.ToString();
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemple #14
0
 private void TestRetrieveAncestors(TestCase testcase)
 {
     string path = testcase.Parameters;
     List<string> ancestors = _logic.RetrieveAncestors(path);
     ancestors.Sort();
     string result = "";
     foreach (string ancestor in ancestors)
     {
         result += (ancestor + " ");
     }
     testcase.Actual = result.Trim();
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #15
0
 private void TestAddPathString(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string tagname = parameters[0].Trim();
     string path = parameters[1].Trim();
     Tag tag = FindTag(tagname);
     if (tag != null)
     {
         string success = tag.AddPath(path, DateTime.Now.Ticks).ToString();
         testcase.Actual = success;
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemple #16
0
        //private void TestRetrieveParentByPath(TestCase testcase)
        //{
        //    string path = testcase.Parameters;
        //    List<string> parentpathlist = _logic.RetrieveParentByPath(path);
        //    parentpathlist.Sort();
        //    string result = "";
        //    foreach (string parentpath in parentpathlist)
        //    {
        //        result += (parentpath + " ");
        //    }
        //    testcase.Actual = result.Trim();
        //    testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
        //}

        private void TestFindSimilarPathForFolder(TestCase testcase)
        {
            string path = testcase.Parameters;
            List<string> pathlist = _logic.FindSimilarPathForFolder(path);
            pathlist.Sort();
            string result = "";
            foreach (string p in pathlist)
            {
                result += (p + " ");
            }
            testcase.Actual = result.Trim();
            testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
        }
Exemple #17
0
 private void TestRemoveTag(TestCase testcase)
 {
     string tagname = testcase.Parameters;
     Tag tag = FindTag(tagname);
     if (tag != null)
     {
         tag.Remove(DateTime.Now.Ticks);
         string isdeleted = tag.IsDeleted.ToString();
         string pathcount = tag.UnfilteredPathList.Count.ToString();
         testcase.Actual = string.Format("{0}, {1}", isdeleted, pathcount);
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemple #18
0
 private void TestRetrieveTagByPath(TestCase testcase)
 {
     string path = testcase.Parameters;
     List<Tag> taglist = _logic.RetrieveTagByPath(path);
     string result = "";
     List<string> tagnamelist = new List<string>();
     foreach (Tag tag in taglist)
     {
         tagnamelist.Add(tag.TagName);
     }
     tagnamelist.Sort();
     foreach (string tagname in tagnamelist)
     {
         result += (tagname + " ");
     }
     testcase.Actual = result.Trim();
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #19
0
 private void TestCreateTag(TestCase testcase)
 {
     string tagname = testcase.Parameters;
     Tag tag = new Tag(tagname, DateTime.Now.Ticks);
     _taglist.Add(tag);
     testcase.Actual = _taglist.Count.ToString();
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #20
0
 private void TestRetrieveTag(TestCase testcase)
 {
     string tagname = testcase.Parameters;
     Tag tag = _logic.RetrieveTag(tagname);
     testcase.Actual = (tag != null ? "Not null" : "Null");
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #21
0
        private void TestFolderFilter(TestCase testcase)
        {
            string[] parameters = testcase.Parameters.Split(',');
            string[] paths = parameters[0].Trim().Split(' ');
            string pattern = parameters[1].Trim();
            if (pattern.StartsWith("*") && pattern.EndsWith("*"))
            {
                //contain pattern
                pattern = pattern.Trim('*');
                pattern = Regex.Escape(pattern);
                pattern = @"\S[A-Za-z:]*(" + pattern;
                pattern = pattern + @")\S[A-Za-z]*";
            }
            else if (!pattern.StartsWith("*") && pattern.EndsWith("*"))
            {
                //startswith pattern only
                pattern = pattern.Trim('*');
                pattern = Regex.Escape(pattern);
                pattern = @"\b(" + pattern;
                pattern = pattern + @")\S*";
            }
            else if (pattern.StartsWith("*") && !pattern.EndsWith("*"))
            {
                //endswith pattern only
                pattern = pattern.Trim('*');
                pattern = Regex.Escape(pattern);
                pattern = @"\S*(" + pattern;
                pattern = pattern + @")\b";
            }
            else
            {
                //invalid filter pattern

            }
            List<string> filteredPaths = new List<string>();
            foreach (string path in paths)
            {
                Match match = Regex.Match(path, pattern);
                if (match.Success)
                {
                    filteredPaths.Add(match.Value);
                }
            }
            //string path = @"C:\A\B\C\E\F\ C:\A\ C:\D\ D:\B\ E:\F\ G:\H\B\";
            //string pattern = @"C:\A\*";
            string result = "";
            foreach (string filteredPath in filteredPaths)
            {
                result += (filteredPath + " ");
            }
            testcase.Actual = result.Trim();
            testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
        }
Exemple #22
0
 private void TestRenameTag(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string oldname = parameters[0].Trim();
     string newname = parameters[1].Trim();
     try
     {
         _logic.RenameTag(oldname, newname);
         testcase.Actual = "";
     }
     catch (TagAlreadyExistsException)
     {
         testcase.Actual = "TagAlreadyExistsException";
     }
     catch (TagNotFoundException)
     {
         testcase.Actual = "TagNotFoundException";
     }
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #23
0
 private void TestSaveToXml(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     List<string> locations = new List<string>();
     for (int i = 0; i < parameters.Length; i++)
     {
         locations.Add(parameters[i].Trim());
     }
     try
     {
         _logic.SaveTo(locations);
         testcase.Actual = "";
     }
     catch (IOException)
     {
         testcase.Actual = "IOException";
     }
     catch (Exception)
     {
         testcase.Actual = "Exception";
     }
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #24
0
 private void TestUntagFolder(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string path, tagname;
     path = parameters[0].Trim();
     int result;
     switch (parameters.Length)
     {
         case 1:
             try
             {
                 result = _logic.UntagFolder(path);
                 testcase.Actual = result.ToString();
             }
             catch (TagNotFoundException)
             {
                 testcase.Actual = "TagNotFoundException";
             }
             break;
         case 2:
             tagname = parameters[1].Trim();
             try
             {
                 result = _logic.UntagFolder(path, tagname);
                 testcase.Actual = result.ToString();
             }
             catch (TagNotFoundException)
             {
                 testcase.Actual = "TagNotFoundException";
             }
             break;
         default:
             throw new Exception("Invalid parameters.");
     }
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #25
0
 private void TestGetAllPaths(TestCase testcase)
 {
     List<string> pathList = _logic.GetAllPaths();
     string result = "";
     pathList.Sort();
     foreach (string path in pathList)
     {
         result += (path + " ");
     }
     testcase.Actual = result.Trim();
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #26
0
 private void TestCreateTag(TestCase testcase)
 {
     string tagname = testcase.Parameters;
     try
     {
         Tag tag = _logic.CreateTag(tagname);
         testcase.Actual = string.Format("{0}, {1}, {2}, {3}, {4}", tag.TagName, tag.IsDeleted.ToString(), tag.DeletedDate.ToString(), tag.UnfilteredPathList.Count.ToString(), tag.Filters.Count.ToString());
     }
     catch (TagAlreadyExistsException)
     {
         testcase.Actual = "TagAlreadyExistsException";
     }
     testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
 }
Exemple #27
0
 private void TestFindAncestorsDescendants(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string tagname = parameters[0].Trim();
     string path = parameters[1].Trim();
     bool ancestors = bool.Parse(parameters[2].Trim());
     Tag tag = FindTag(tagname);
     if (tag != null)
     {
         List<string> results = new List<string>();
         if (ancestors)
         {
             results = tag.FindAncestors(path);
         }
         else
         {
             results = tag.FindDescendants(path);
         }
         testcase.Actual = results.Count.ToString();
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }