Esempio n. 1
0
        /// <summary>
        /// Creates new UnitItem object and fills it will all required information that can be used in a project file. Requires valid RelativePath builder and UnitFormFinder.
        /// It finds corresponding form for the unit automatically. Path is always set relatively to the BasePath.
        /// </summary>
        /// <param name="aUnitFileName"></param>
        /// <returns></returns>
        public UnitItem Create(string aUnitFileName)
        {
            UnitItem vResult = new UnitItem();

            vResult.Name    = Path.GetFileNameWithoutExtension(aUnitFileName);
            vResult.UsePath = UsePaths;
            if (!aUnitFileName.Equals(""))
            {
                vResult.Path = Path.GetDirectoryName(aUnitFileName);
            }
            vResult.Path = RelativePath.GetRelativeFileName(BasePath, vResult.Path);
            vResult.Form = UnitFormReader.GetUnitForm(aUnitFileName);

            return(vResult);
        }
        protected void DoGetRelativeFileName(bool iRelativeToPath, string iBaseFileName, string iFileName, string iExpected)
        {
            try
            {
                if (iRelativeToPath)
                {
                    iBaseFileName = PathUtils.AddEndingDirectorySeparator(Path.GetDirectoryName(iBaseFileName));
                }

                string vActual = RelativePath.GetRelativeFileName(iBaseFileName, iFileName);
                Assert.AreEqual(iExpected, vActual, GetTestFailMessage(iBaseFileName, iFileName));
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message + "; " + GetTestFailMessage(iBaseFileName, iFileName));
            }
        }