protected void DoTestToString_WithConditions(bool iAddConditions, string iSeparator, bool iSeparatorLast, string iExpected)
        {
            UnitItem vUnit = new UnitItem("unit_name", "unit_path", true, "");
            if (iAddConditions)
            {
                vUnit.StartingConditions = "{$condition1}";
                vUnit.EndingConditions = "{$condition2}";
            }

            string vActual = vUnit.ToString("  ", iSeparator, iSeparatorLast);

            Assert.AreEqual(iExpected, vActual);
        }
 protected void DoTestPathChange(UnitItem iUnitItem, string iInitialPath, string iNewPath, string iMessage)
 {
     Assert.AreEqual(iInitialPath, iUnitItem.Path, "Path wasn't set properly. " + iMessage);
     iUnitItem.Path = iNewPath;
     Assert.AreEqual(iNewPath, iUnitItem.Path, "Path wasn't changed correctly. " + iMessage);
 }
        protected void DoTestPathChange(string iInitialPath, string iNewPath)
        {
            UnitItem vUnit = new UnitItem("unit_name", iInitialPath, true, "");
            DoTestPathChange(vUnit, iInitialPath, iNewPath, "");

            vUnit = new UnitItem("", iInitialPath, true, "");
            DoTestPathChange(vUnit, iInitialPath, iNewPath, "Created with empty name.");
        }
 protected void DoTestNameChange(string iInitialName, string iNewName)
 {
     UnitItem vUnit = new UnitItem(iInitialName);
     DoTestNameChange(vUnit, iInitialName, iNewName);
 }
 protected void DoTestNameChange(UnitItem iUnitItem, string iInitialName, string iNewName)
 {
     Assert.AreEqual(iInitialName, iUnitItem.Name, "Name wasn't set properly.");
     iUnitItem.Name = iNewName;
     Assert.AreEqual(iNewName, iUnitItem.Name, "Name wasn't changed correctly.");
 }
 protected void DoTestInsert(UnitList iList, UnitItem iUnitItem, int iIndex)
 {
     int vOldCount = iList.Count;
     iList.Insert(iIndex, iUnitItem);
     Assert.AreEqual(vOldCount + 1, iList.Count, "Item wasn't inserted properly");
     Assert.AreEqual(iUnitItem, iList[iIndex], "Item wasn't assigned correctly");
 }
 public void ToString_RelativePath_WithoutBackslash()
 {
     UnitItem vUnit = new UnitItem("unit_name", @"..\..", true, "");
     string vExpected = "unit_name in '..\\..\\unit_name.pas'";
     string vActual = vUnit.ToString("", "", false);
     Assert.AreEqual(vExpected, vActual);
 }
        protected void DoTestHasForm(string iForm, bool iExpected)
        {
            UnitItem vUnit = new UnitItem("Created with unit name only");
            vUnit.Form = iForm;
            DoTestHasForm(vUnit, iForm, iExpected);

            vUnit = new UnitItem("Created with empty path and form", "", false, iForm);
            DoTestHasForm(vUnit, iForm, iExpected);
        }
 protected void DoTestHasForm(UnitItem iUnitItem, string iExpectedFormName, bool iExpectedHasForm)
 {
     Assert.AreEqual(iExpectedHasForm, iUnitItem.HasForm, "HasForm value is wrong. " + iUnitItem.Name);
     Assert.AreEqual(iExpectedFormName, iUnitItem.Form, "Form value is wrong. " + iUnitItem.Name);
 }
 public void ToString_WithPath_WithoutBacklash()
 {
     UnitItem vUnit = new UnitItem("unit_name", @"c:\temp", true, "");
     string vExpected = "unit_name in 'c:\\temp\\unit_name.pas'";
     string vActual = vUnit.ToString("", "", false);
     Assert.AreEqual(vExpected, vActual);
 }
 protected void DoTestCreate_Name(string iExpectedName)
 {
     UnitItem vUnit = new UnitItem(iExpectedName);
     Assert.AreEqual(iExpectedName, vUnit.Name, "Name wasn't set properly");
     Assert.AreEqual("", vUnit.Path, "Path wasn't set to empty string");
 }
 public void ToString_WithoutPath()
 {
     UnitItem vUnit = new UnitItem("unit_name");
     Assert.AreEqual("unit_name", vUnit.ToString("", "", false));
 }
        public void ToString_WithForm()
        {
            string vExpected =
                "  unit_name {unit_name};";

            UnitItem vUnit = new UnitItem("unit_name", "", false, "unit_name");
            string vActual = vUnit.ToString("  ", ";", true);
            Assert.AreEqual(vExpected, vActual);
        }
        public void ToString_StartingConditionOnly()
        {
            string vExpected =
                "  {$begin}\n" +
                "    unit_name;";

            UnitItem vUnit = new UnitItem("unit_name");
            vUnit.StartingConditions = "{$begin}";
            string vActual = vUnit.ToString("  ", ";", false);

            Assert.AreEqual(vExpected, vActual);
        }
        public void ToString_EndingConditionOnly()
        {
            string vExpected =
                "    unit_name,\n" +
                "  {$end}";

            UnitItem vUnit = new UnitItem("unit_name");
            vUnit.EndingConditions = "{$end}";
            string vActual = vUnit.ToString("  ", ",", false);

            Assert.AreEqual(vExpected, vActual);
        }
 public void Create_NameAndPath()
 {
     UnitItem vUnit = new UnitItem("unit_name", "unit_path", true, "");
     Assert.AreEqual("unit_name", vUnit.Name, "Name wasn't set properly");
     Assert.AreEqual("unit_path", vUnit.Path, "Path wasn't set properly");
 }
        protected UnitList GetDefaultUnits(int iCount, bool iWithPaths, bool iRelative, bool iWithConditions)
        {
            UnitList vResult = new UnitList();
            for (int vUnitIdx = 0; vUnitIdx < iCount; vUnitIdx++)
            {
                string vUnitName = "Unit" + vUnitIdx.ToString();
                string vUnitPath = "";
                if (iWithPaths)
                    if (iRelative)
                        vUnitPath = "..\\.." + "DefaultPath" + vUnitIdx.ToString();
                    else
                        vUnitPath = @"c:\windows\temp\DefaultPath" + vUnitIdx.ToString() + "\\" + vUnitName + ".pas";

                UnitItem vUnit = new UnitItem(vUnitName, vUnitPath, iWithPaths, "");
                if (iWithConditions)
                {
                    vUnit.StartingConditions = "{$IFDEF TestCondition}";
                    vUnit.EndingConditions = "{$ENDIF}";
                }

                vResult.Add(vUnit);
            }

            return vResult;
        }
 protected void DoTestHasStartingConditions(string iConditions, bool iExpected)
 {
     UnitItem vUnit = new UnitItem("unit_name");
     vUnit.StartingConditions = iConditions;
     DoTestHasConditions(iExpected, vUnit.HasStartingConditions, iConditions, vUnit.StartingConditions, "Starting");
 }
        protected static UnitItem SplitUnitInfo(string iText)
        {
            MatchCollection vMatches = ExecuteExpression(iText, cUnitsAndConditions);
            foreach (Match vMatch in vMatches)
            {
                string vUnitName = GetMatchResult(4, vMatch).Trim();
                if (vUnitName == "")
                    continue;

                string vUnitPath = GetMatchResult(6, vMatch).Trim();
                bool vHasPath = (vUnitPath != "");
                if (vHasPath)
                    vUnitPath = System.IO.Path.GetDirectoryName(vUnitPath);

                string vForm = GetMatchResult(8, vMatch).Trim();

                UnitItem vUnit = new UnitItem(vUnitName, vUnitPath, vHasPath, vForm);

                vUnit.StartingConditions = GetMatchResult(1, vMatch);
                vUnit.EndingConditions = GetMatchResult(9, vMatch);
                return vUnit;
            }

            return null;
        }
 public void ToString_RelativePath_BlankPath()
 {
     UnitItem vUnit = new UnitItem("unit_name", "", true, "");
     string vExpected = "unit_name in 'unit_name.pas'";
     string vActual = vUnit.ToString("", "", false);
     Assert.AreEqual(vExpected, vActual);
 }