Ejemplo n.º 1
0
        public bool testComponent()
        {
            TestUtilities.title("Testing FileNameEditor", '=');
            TestUtilities.putLine();

            TestUtilities.title("Testing extension edits");
            FileName fileName  = "SomeFile.cs.2";
            FileName test1Name = addXmlExt(fileName);
            bool     t1        = test1Name.Contains(".xml");

            showResult(t1, test1Name, "addXmlExt");

            FileName test2Name = removeXmlExt(test1Name);
            bool     t2        = test2Name == fileName;

            showResult(t2, test2Name, "removeXmlExt");

            FileName test3Name = removeXmlExt(test2Name);
            bool     t3        = test3Name == fileName;

            showResult(t3, test3Name, "removeXmlExt");
            TestUtilities.putLine();

            TestUtilities.title("Testing path construction");
            DirName stagingdir  = "Fawcett";
            FullDir stagingpath = stagingPath(stagingdir);
            bool    t4          = (stagingpath.Contains("C:/") || stagingpath.Contains("../")) && stagingpath.Contains(stagingdir);

            showResult(t4, stagingpath, "stagingPath");

            DirName category    = "SomeCategory";
            FullDir storagepath = storagePath(category);
            bool    t5          = (storagepath.Contains("C:/") || storagepath.Contains("../")) && storagepath.Contains(category);

            showResult(t5, storagepath, "storagePath");

            FileName someFileName = "someFileName";
            FileSpec filespec     = fileSpec(storagepath, someFileName);
            bool     t6           = filespec.Contains("/someFileName");

            showResult(t6, filespec, "fileSpec");

            FileRef fileref = storageFolderRef(filespec);
            bool    t7      = fileref.IndexOf('/') == fileref.LastIndexOf('/');

            showResult(t7, fileref, "storageFolderRef");

            DirName cat = extractCategory(fileref);
            bool    t8  = cat == category;

            showResult(t8, cat, "extractCategory");

            FileName file = extractFileName(fileref);
            bool     t9   = file == someFileName;

            showResult(t8, file, "extractFileName");

            return(t1 && t2 && t3 && t4 && t5 && t6 && t7 && t8 && t9);
        }
Ejemplo n.º 2
0
        /*----< populate dependency and version info from storage >----*/

        public void analyzeDependencies()
        {
            IVersion version = RepoEnvironment.version;

            if (version == null)
            {
                version = new Version();
            }

            List <DirName> cats = categories();

            foreach (DirName cat in cats)
            {
                List <FileSpec> fileNames = files(cat);
                foreach (FileName fileName in fileNames)
                {
                    //FileSpec fileSpec = System.IO.Path.Combine(cat + "/", fileName);
                    FileSpec fileSpec = makeFileRef(cat, fileName);
                    if (fileSpec.Contains(".xml"))
                    {
                        string   path = System.IO.Path.Combine(RepoEnvironment.storagePath, fileSpec);
                        MetaData md   = new MetaData();
                        md.load(path);
                        foreach (string pkg in md.dependencies)
                        {
                            dependency.addChild(fileSpec, pkg);
                            dependency.addParent(pkg, fileSpec);
                        }
                    }
                    int    ver = RepoEnvironment.version.getVersion(fileSpec);
                    string key = RepoEnvironment.version.removeVersion(fileSpec);
                    versionChain.addVersion(key, ver, false);
                }
                foreach (FileName fileName in fileNames)
                {
                    FileSpec fileSpec = System.IO.Path.Combine(cat, fileName);
                    string   key      = RepoEnvironment.version.removeVersion(fileSpec);
                    versionChain.sort(key);
                }
            }
        }