コード例 #1
0
ファイル: Importer.cs プロジェクト: fire-eggs/GEDKeeper
        private ImportUtils.PersonLineRet ParsePersonLine(string str)
        {
            switch (NumbersType)
            {
            case PersonNumbersType.pnDAboville:
                return(ImportUtils.ParsePersonLine_DAboville(str));

            case PersonNumbersType.pnKonovalov:
                return(ImportUtils.ParsePersonLine_Konovalov(str));

            default:
                return(null);
            }
        }
コード例 #2
0
        public void Test_ValidCases()
        {
            string pid;

            pid = ImportUtils.IsPersonLine_Konovalov("1. Ivan");
            Assert.AreEqual("1.", pid, "[v1]");

            pid = ImportUtils.IsPersonLine_Konovalov("2-1. Ivan");
            Assert.AreEqual("2-1.", pid);

            pid = ImportUtils.IsPersonLine_Konovalov("11-21. Ivan");
            Assert.AreEqual("11-21.", pid);

            pid = ImportUtils.IsPersonLine_Konovalov("11-21/1. Ivan");
            Assert.AreEqual("11-21/1.", pid);

            pid = ImportUtils.IsPersonLine_Konovalov("11-21/?. Ivan");
            Assert.AreEqual("11-21/?.", pid, "[v2]");

            pid = ImportUtils.IsPersonLine_Konovalov("11-21/1 (test+2, test). Ivan");
            Assert.AreEqual("11-21/1 (test+2, test).", pid);



            var plRet = ImportUtils.ParsePersonLine_Konovalov("11-21/1 (test+2, test). Ivan");

            Assert.AreEqual("11", plRet.PersId);
            Assert.AreEqual("21", plRet.ParentId);
            Assert.AreEqual("1", plRet.MarNum);
            Assert.AreEqual("(test+2, test)", plRet.ExtData);
            Assert.IsNotNull(plRet);

            plRet = ImportUtils.ParsePersonLine_Konovalov("11-21/?. Ivan");
            Assert.AreEqual("11", plRet.PersId);
            Assert.AreEqual("21", plRet.ParentId);
            Assert.AreEqual("?", plRet.MarNum);
            Assert.AreEqual("", plRet.ExtData);
            Assert.IsNotNull(plRet);



            pid = ImportUtils.IsPersonLine_DAboville("1. Ivan");
            Assert.AreEqual("1.", pid, "[v2-1]");

            pid = ImportUtils.IsPersonLine_DAboville("1.1. Ivan");
            Assert.AreEqual("1.1.", pid, "[v2-2]");

            pid = ImportUtils.IsPersonLine_DAboville("11.21.31.11. Ivan");
            Assert.AreEqual("11.21.31.11.", pid, "[v2-3]");



            plRet = ImportUtils.ParsePersonLine_DAboville("1. Ivan");
            Assert.AreEqual("1.", plRet.PersId);
            Assert.AreEqual("", plRet.ParentId);
            Assert.AreEqual("", plRet.MarNum);
            Assert.AreEqual("", plRet.ExtData);
            Assert.IsNotNull(plRet);

            plRet = ImportUtils.ParsePersonLine_DAboville("11.21.31.11. Ivan");
            Assert.AreEqual("11.21.31.11.", plRet.PersId);
            Assert.AreEqual("11.21.31.", plRet.ParentId);
            Assert.AreEqual("", plRet.MarNum);
            Assert.AreEqual("", plRet.ExtData);
            Assert.IsNotNull(plRet);



            var slRet = ImportUtils.ParseSpouseLine("Ж: Ivanova");

            Assert.AreEqual("Ж", slRet.Spouse, "[v3-1]");
            Assert.AreEqual(1, slRet.MarrNum, "[v3-1]");
            Assert.AreEqual("", slRet.ExtData);
            Assert.IsNotNull(slRet, "[v3-1]");

            slRet = ImportUtils.ParseSpouseLine("Ж2 (test): Ivanova");
            Assert.AreEqual("Ж", slRet.Spouse, "[v3-2]");
            Assert.AreEqual(2, slRet.MarrNum, "[v3-2]");
            Assert.AreEqual("(test)", slRet.ExtData, "[v3-2]");
            Assert.IsNotNull(slRet, "[v3-2]");

            slRet = ImportUtils.ParseSpouseLine("Ж - Ivanova");
            Assert.AreEqual("Ж", slRet.Spouse, "[v3-3]");
            Assert.AreEqual(1, slRet.MarrNum, "[v3-3]");
            Assert.AreEqual("", slRet.ExtData);
            Assert.IsNotNull(slRet, "[v3-3]");

            slRet = ImportUtils.ParseSpouseLine("Ж3 (test2) - Ivanova");
            Assert.AreEqual("Ж", slRet.Spouse, "[v3-4]");
            Assert.AreEqual(3, slRet.MarrNum, "[v3-4]");
            Assert.AreEqual("(test2)", slRet.ExtData, "[v3-4]");
            Assert.IsNotNull(slRet, "[v3-4]");
        }