Beispiel #1
0
        public void Test_IndiMathes()
        {
            GDMTree tree = new GDMTree();

            Assert.IsNotNull(tree);

            GDMIndividualRecord ind1, ind2;
            GDMCustomEvent      ev1, ev2;
            GDMDateValue        dtVal1, dtVal2;

            ind1     = tree.CreateIndividual();
            ind1.Sex = GDMSex.svMale;
            GDMPersonalName pn = ind1.AddPersonalName(new GDMPersonalName(ind1));

            pn.SetNameParts("Ivan Ivanov", "Fedoroff", "");

            ind2     = tree.CreateIndividual();
            ind2.Sex = GDMSex.svMale;
            pn       = ind2.AddPersonalName(new GDMPersonalName(ind2));
            pn.SetNameParts("Ivan Ivanovich", "Fedoroff", "");

            ev1    = new GDMIndividualEvent(ind1, (int)GEDCOMTagType.BIRT, "");
            dtVal1 = ev1.Date;
            ind1.AddEvent(ev1);

            ev2    = new GDMIndividualEvent(ind2, (int)GEDCOMTagType.BIRT, "");
            dtVal2 = ev2.Date;
            ind2.AddEvent(ev2);

            float       res;
            MatchParams mParams;

            mParams.NamesIndistinctThreshold = 1.0f;
            mParams.DatesCheck       = true;
            mParams.YearsInaccuracy  = 0;
            mParams.CheckEventPlaces = false;

            // null
            res = dtVal1.IsMatch(null, mParams);
            Assert.AreEqual(0.0f, res);

            // null
            res = ev1.IsMatch(null, mParams);
            Assert.AreEqual(0.0f, res);

            // dtVal1 -> dtVal2, delta = 0
            dtVal1.SetDateTime(DateTime.Parse("10.10.2013"));
            dtVal2.SetDateTime(DateTime.Parse("10.10.2013"));
            res = dtVal1.IsMatch(dtVal2, mParams);
            Assert.AreEqual(100.0f, res);

            // ev1 -> ev2, delta = 0
            res = ev1.IsMatch(ev2, mParams);
            Assert.AreEqual(100.0f, res);

            // dtVal1 -> dtVal2, delta = 3
            mParams.YearsInaccuracy = 3;

            dtVal2.SetDateTime(DateTime.Parse("10.10.2015"));
            res = dtVal1.IsMatch(dtVal2, mParams);
            Assert.AreEqual(100.0f, res);

            // ev1 -> ev2, delta = 3
            res = ev1.IsMatch(ev2, mParams);
            Assert.AreEqual(100.0f, res);

            dtVal2.SetDateTime(DateTime.Parse("10.10.2009"));
            res = dtVal1.IsMatch(dtVal2, mParams);
            Assert.AreEqual(0.0f, res);

            // ev1 -> ev2, delta = 3
            res = ev1.IsMatch(ev2, mParams);
            Assert.AreEqual(0.0f, res);

            // //

            res = ind1.IsMatch(null, mParams);
            Assert.AreEqual(0.0f, res);

            res = ind1.IsMatch(ind2, mParams);
            Assert.AreEqual(0.0f, res);

            // Ivanov - Ivanov(ich) : 3 chars of difference -> 0.88
            mParams.NamesIndistinctThreshold = 0.85f;
            mParams.YearsInaccuracy          = 4;

            res = ind1.IsMatch(ind2, mParams);
            Assert.AreEqual(100.0f, res);
        }