Ejemplo n.º 1
0
        public void Test_Common()
        {
            using (GDMPlace place = new GDMPlace(null)) {
                Assert.IsNotNull(place);

                place.Form = "abrakadabra";
                Assert.AreEqual("abrakadabra", place.Form);

                Assert.IsNotNull(place.Map);
                Assert.IsNotNull(place.Location);

                var note = new GDMNotes(place);
                note.Lines.Text = "place notes";
                place.Notes.Add(note);

                using (GDMPlace place2 = new GDMPlace(null)) {
                    Assert.Throws(typeof(ArgumentException), () => {
                        place2.Assign(null);
                    });

                    place2.Assign(place);

                    string buf = TestUtils.GetTagStreamText(place2, 1);
                    Assert.AreEqual("1 PLAC\r\n" +
                                    "2 NOTE place notes\r\n" +
                                    "2 FORM abrakadabra\r\n", buf);
                }

                place.ReplaceXRefs(new GDMXRefReplacer());

                Assert.IsFalse(place.IsEmpty());
                place.Clear();
                Assert.IsTrue(place.IsEmpty());
            }
        }
Ejemplo n.º 2
0
        public void Test_Common()
        {
            using (GDMSourceData data = new GDMSourceData(null)) {
                Assert.IsNotNull(data);

                data.Agency = "test agency";
                Assert.AreEqual("test agency", data.Agency);

                GDMTag evenTag = data.Events.Add(new GDMSourceEvent(data));
                Assert.IsNotNull(evenTag);

                GDMSourceEvent evt = data.Events[0];
                Assert.AreEqual(evenTag, evt);

                evt.StringValue = "BIRT";

                var note = new GDMNotes(data);
                note.Lines.Text = "test sourcedata notes";
                data.Notes.Add(note);

                string buf = TestUtils.GetTagStreamText(data, 0);
                Assert.AreEqual("1 DATA\r\n" +
                                "2 NOTE test sourcedata notes\r\n" +
                                "2 AGNC test agency\r\n" +
                                "2 EVEN BIRT\r\n", buf);

                data.ReplaceXRefs(new GDMXRefReplacer());

                Assert.IsFalse(data.IsEmpty());
                data.Clear();
                Assert.IsTrue(data.IsEmpty());
            }
        }
Ejemplo n.º 3
0
 public void Test_GEDCOMNotes()
 {
     using (GDMNotes notes = new GDMNotes()) {
         Assert.IsTrue(notes.IsEmpty());
         notes.Lines.Text = "Test note";
         Assert.IsFalse(notes.IsEmpty());
         Assert.AreEqual("Test note", notes.Lines.Text);
     }
 }
Ejemplo n.º 4
0
        private static void GEDCOMNotesTest(GDMNoteRecord noteRec, GDMIndividualRecord indiv)
        {
            GDMNotes notes = indiv.AddNote(noteRec);

            Assert.AreEqual(notes.Lines.Text, noteRec.Lines.Text);

            Assert.IsTrue(notes.IsPointer, "notes.IsPointer");

            Assert.IsFalse(notes.IsEmpty()); // its pointer

            notes.Clear();
        }
Ejemplo n.º 5
0
        public GDMNotes AddNote(GDMNoteRecord noteRec)
        {
            GDMNotes note = null;

            if (noteRec != null)
            {
                note       = new GDMNotes(this);
                note.Value = noteRec;
                fNotes.Add(note);
            }

            return(note);
        }
Ejemplo n.º 6
0
        private static void GEDCOMNotesTest(GDMNoteRecord noteRec, GDMIndividualRecord indiv)
        {
            GDMNotes notes = indiv.AddNote(noteRec);

            Assert.IsTrue(notes.IsPointer, "notes.IsPointer");

            Assert.Throws <InvalidOperationException>(() => {
                var lines = notes.Lines;
            }, "Notes is a pointer");

            Assert.AreEqual(notes.XRef, noteRec.XRef);

            Assert.IsFalse(notes.IsEmpty()); // its pointer

            notes.Clear();
        }
Ejemplo n.º 7
0
        public GDMLines GetNoteLines(GDMNotes notes)
        {
            GDMLines lines;

            if (!notes.IsPointer)
            {
                lines = notes.Lines;
            }
            else
            {
                var notesRecord = GetPtrValue <GDMNoteRecord>(notes);
                lines = (notesRecord != null) ? notesRecord.Lines : new GDMLines();
            }

            return(lines);
        }
Ejemplo n.º 8
0
        public void Test_Common()
        {
            using (GDMPlace place = new GDMPlace()) {
                Assert.IsNotNull(place);

                place.Form = "abrakadabra";
                Assert.AreEqual("abrakadabra", place.Form);

                Assert.IsNotNull(place.Map);
                Assert.IsNotNull(place.Location);

                var note = new GDMNotes();
                note.Lines.Text = "place notes";
                place.Notes.Add(note);

                using (GDMPlace place2 = new GDMPlace()) {
                    Assert.Throws(typeof(ArgumentException), () => {
                        place2.Assign(null);
                    });

                    var iRec = new GDMIndividualRecord(null);
                    var evt  = new GDMIndividualEvent();
                    evt.SetName("BIRT");
                    iRec.Events.Add(evt);
                    //place2.Assign(place);
                    evt.Place.Assign(place);

                    string buf = TestUtils.GetTagStreamText(iRec, 1);
                    Assert.AreEqual("0 INDI\r\n" +
                                    "1 SEX U\r\n" +
                                    "1 BIRT\r\n" +
                                    "2 PLAC\r\n" +
                                    "3 NOTE place notes\r\n" +
                                    "3 FORM abrakadabra\r\n", buf);
                }

                place.ReplaceXRefs(new GDMXRefReplacer());

                Assert.IsFalse(place.IsEmpty());
                place.Clear();
                Assert.IsTrue(place.IsEmpty());
            }
        }
Ejemplo n.º 9
0
        public void Test_Common()
        {
            using (GDMIndividualAttribute customEvent = new GDMIndividualAttribute()) {
                Assert.IsNotNull(customEvent);

                Assert.IsNotNull(customEvent.Address);

                customEvent.Date.ParseString("28 DEC 1990");
                string dateTest = "28.12.1990";
                Assert.AreEqual(TestUtils.ParseDT(dateTest), customEvent.Date.GetDateTime());
                Assert.AreEqual(1990, customEvent.GetChronologicalYear());

                Assert.AreEqual(TestUtils.ParseDT(dateTest), customEvent.Date.Date);
                customEvent.Place.ParseString("Ivanovo");
                Assert.AreEqual("Ivanovo", customEvent.Place.StringValue);

                Assert.IsNotNull(customEvent.Place);

                customEvent.Agency = "test agency";
                Assert.AreEqual("test agency", customEvent.Agency);

                customEvent.Classification = "test type";
                Assert.AreEqual("test type", customEvent.Classification);

                customEvent.Cause = "test cause";
                Assert.AreEqual("test cause", customEvent.Cause);

                customEvent.ReligiousAffilation = "test aff";
                Assert.AreEqual("test aff", customEvent.ReligiousAffilation);

                customEvent.Restriction = GDMRestriction.rnLocked;
                Assert.AreEqual(GDMRestriction.rnLocked, customEvent.Restriction);


                GDMLines strs = new GDMLines("test");
                customEvent.PhysicalDescription = strs;
                Assert.AreEqual(strs.Text, customEvent.PhysicalDescription.Text);

                customEvent.Address.AddEmailAddress("email");
                Assert.AreEqual("email", customEvent.Address.EmailAddresses[0].StringValue);
            }

            using (GDMIndividualEvent customEvent = new GDMIndividualEvent()) {
                Assert.IsNotNull(customEvent);

                // stream test
                customEvent.SetName(GEDCOMTagName.BIRT);
                customEvent.Date.ParseString("20 SEP 1970");
                customEvent.Place.StringValue   = "test place";
                customEvent.Agency              = "Agency";
                customEvent.Classification      = "custom";
                customEvent.ReligiousAffilation = "rel_aff";
                customEvent.Cause = "Cause";
                customEvent.Address.AddressLine1 = "adr1";
                customEvent.Restriction          = GDMRestriction.rnConfidential;

                var note = new GDMNotes();
                note.Lines.Text = "event notes";
                customEvent.Notes.Add(note);

                var sourCit = new GDMSourceCitation();
                sourCit.Description.Text = "event sour desc";
                customEvent.SourceCitations.Add(sourCit);

                var mmLink = new GDMMultimediaLink();
                mmLink.Title = "event media title";
                customEvent.MultimediaLinks.Add(mmLink);

                using (GDMIndividualEvent copyEvent = new GDMIndividualEvent()) {
                    Assert.IsNotNull(copyEvent);
                    copyEvent.Assign(customEvent);

                    var iRec = new GDMIndividualRecord(null);
                    iRec.Events.Add(copyEvent);
                    string buf1 = TestUtils.GetTagStreamText(iRec, 0);
                    Assert.AreEqual("0 INDI\r\n" +
                                    "1 SEX U\r\n" +
                                    "1 BIRT\r\n" +
                                    "2 TYPE custom\r\n" +
                                    "2 DATE 20 SEP 1970\r\n" +
                                    "2 PLAC test place\r\n" +
                                    "2 ADDR\r\n" +
                                    "3 ADR1 adr1\r\n" +
                                    "2 CAUS Cause\r\n" +
                                    "2 AGNC Agency\r\n" +
                                    "2 RELI rel_aff\r\n" +
                                    "2 RESN confidential\r\n" +
                                    "2 NOTE event notes\r\n" +
                                    "2 SOUR event sour desc\r\n" +
                                    "2 OBJE\r\n" +
                                    "3 TITL event media title\r\n", buf1);
                }

                customEvent.Address.AddEmailAddress("email");
                Assert.AreEqual("email", customEvent.Address.EmailAddresses[0].StringValue);
            }

            using (GDMFamilyEvent customEvent = new GDMFamilyEvent()) {
                Assert.IsNotNull(customEvent);

                customEvent.Address.AddEmailAddress("email");
                Assert.AreEqual("email", customEvent.Address.EmailAddresses[0].StringValue);
            }
        }
Ejemplo n.º 10
0
        public void Test_Common()
        {
            GDMIndividualRecord iRec = fContext.Tree.XRefIndex_Find("I1") as GDMIndividualRecord;

            GDMPersonalName pName = iRec.PersonalNames[0];

            Assert.AreEqual("Ivanov", pName.Surname);
            Assert.AreEqual("Ivan Ivanovich", pName.FirstPart);

            pName.SetNameParts("Ivan Ivanovich", "Ivanov", "testLastPart");
            Assert.AreEqual("Ivanov", pName.Surname);
            Assert.AreEqual("Ivan Ivanovich", pName.FirstPart);
            Assert.AreEqual("testLastPart", pName.LastPart);

//            GEDCOMPersonalNamePieces pieces = pName.Pieces;
//            Assert.AreEqual(pieces.Surname, "surname");
//            Assert.AreEqual(pieces.Name, "name");
//            Assert.AreEqual(pieces.PatronymicName, "patr");

            var parts = GKUtils.GetNameParts(iRec);

            Assert.AreEqual("Ivanov", parts.Surname);
            Assert.AreEqual("Ivan", parts.Name);
            Assert.AreEqual("Ivanovich", parts.Patronymic);


            GDMPersonalName persName = new GDMPersonalName(iRec);

            iRec.AddPersonalName(persName);

            persName          = iRec.PersonalNames[0];
            persName.NameType = GDMNameType.ntBirth;
            Assert.AreEqual(GDMNameType.ntBirth, persName.NameType);

            //

            persName.SetNameParts("Petr", "Ivanov", "Fedoroff");

            //persName.Surname = "Ivanov";
            Assert.AreEqual("Petr", persName.FirstPart);
            Assert.AreEqual("Ivanov", persName.Surname);
            Assert.AreEqual("Fedoroff", persName.LastPart);

            Assert.AreEqual("Petr Ivanov Fedoroff", persName.FullName);

            persName.FirstPart = "Petr";
            Assert.AreEqual("Petr", persName.FirstPart);

            persName.Surname = "Test";
            Assert.AreEqual("Test", persName.Surname);

            persName.LastPart = "Fedoroff";
            Assert.AreEqual("Fedoroff", persName.LastPart);

            //

            GDMPersonalNamePieces pnPieces = persName.Pieces;

            pnPieces.Prefix = "Prefix";
            Assert.AreEqual("Prefix", pnPieces.Prefix);

            pnPieces.Given = "Given";
            Assert.AreEqual("Given", pnPieces.Given);

            pnPieces.Nickname = "Nickname";
            Assert.AreEqual("Nickname", pnPieces.Nickname);

            pnPieces.SurnamePrefix = "SurnamePrefix";
            Assert.AreEqual("SurnamePrefix", pnPieces.SurnamePrefix);

            pnPieces.Surname = "Surname";
            Assert.AreEqual("Surname", pnPieces.Surname);

            pnPieces.Suffix = "Suffix";
            Assert.AreEqual("Suffix", pnPieces.Suffix);

            pnPieces.PatronymicName = "PatronymicName";
            Assert.AreEqual("PatronymicName", pnPieces.PatronymicName);

            pnPieces.MarriedName = "MarriedName";
            Assert.AreEqual("MarriedName", pnPieces.MarriedName);

            pnPieces.ReligiousName = "ReligiousName";
            Assert.AreEqual("ReligiousName", pnPieces.ReligiousName);

            pnPieces.CensusName = "CensusName";
            Assert.AreEqual("CensusName", pnPieces.CensusName);

            Assert.Throws(typeof(ArgumentException), () => {
                pnPieces.Assign(null);
            });

            //

            Assert.AreEqual(GDMLanguageID.Unknown, persName.Language);
            persName.Language = GDMLanguageID.English;
            Assert.AreEqual(GDMLanguageID.English, persName.Language);
            persName.Language = GDMLanguageID.Unknown;
            Assert.AreEqual(GDMLanguageID.Unknown, persName.Language);
            persName.Language = GDMLanguageID.Polish;
            Assert.AreEqual(GDMLanguageID.Polish, persName.Language);

            //

            var note = new GDMNotes(persName);

            note.Lines.Text = "persname notes";
            persName.Notes.Add(note);

            var sourCit = new GDMSourceCitation(persName);

            sourCit.Description.Text = "persname sour desc";
            persName.SourceCitations.Add(sourCit);

            //

            string buf = TestUtils.GetTagStreamText(persName, 1);

            Assert.AreEqual("1 NAME Petr /Test/ Fedoroff\r\n" +
                            "2 LANG Polish\r\n" + // extension
                            "2 TYPE birth\r\n" +
                            "2 NOTE persname notes\r\n" +
                            "2 SOUR persname sour desc\r\n" +
                            "2 SURN Surname\r\n" +
                            "2 GIVN Given\r\n" +
                            "2 _PATN PatronymicName\r\n" +
                            "2 NPFX Prefix\r\n" +
                            "2 NICK Nickname\r\n" +
                            "2 SPFX SurnamePrefix\r\n" +
                            "2 NSFX Suffix\r\n" +
                            "2 _MARN MarriedName\r\n" +
                            "2 _RELN ReligiousName\r\n" +
                            "2 _CENN CensusName\r\n", buf);

            persName.Language = GDMLanguageID.Unknown;

            using (GDMPersonalName nameCopy = new GDMPersonalName(iRec)) {
                Assert.Throws(typeof(ArgumentException), () => { nameCopy.Assign(null); });

                iRec.AddPersonalName(nameCopy);
                nameCopy.Assign(persName);

                string buf2 = TestUtils.GetTagStreamText(nameCopy, 1);
                Assert.AreEqual("1 NAME Petr /Test/ Fedoroff\r\n" +
                                "2 TYPE birth\r\n" +
                                "2 NOTE persname notes\r\n" +
                                "2 SOUR persname sour desc\r\n" +
                                "2 SURN Surname\r\n" +
                                "2 GIVN Given\r\n" +
                                "2 _PATN PatronymicName\r\n" +
                                "2 NPFX Prefix\r\n" +
                                "2 NICK Nickname\r\n" +
                                "2 SPFX SurnamePrefix\r\n" +
                                "2 NSFX Suffix\r\n" +
                                "2 _MARN MarriedName\r\n" +
                                "2 _RELN ReligiousName\r\n" +
                                "2 _CENN CensusName\r\n", buf2);

                iRec.PersonalNames.Delete(nameCopy);
            }

            using (GDMPersonalName name1 = new GDMPersonalName(null)) {
                Assert.AreEqual("", name1.FirstPart);
                Assert.AreEqual("", name1.Surname);

                Assert.AreEqual(0.0f, name1.IsMatch(null, false));

                using (GDMPersonalName name2 = new GDMPersonalName(null)) {
                    Assert.AreEqual(0.0f, name1.IsMatch(name2, false));

                    name1.SetNameParts("Ivan", "Dub", "");
                    name2.SetNameParts("Ivan", "Dub", "");
                    Assert.AreEqual(100.0f, name1.IsMatch(name2, false));

                    name1.SetNameParts("Ivan", "Dub", "");
                    name2.SetNameParts("Ivan", "Dub2", "");
                    Assert.AreEqual(12.5f, name1.IsMatch(name2, false));

                    name1.SetNameParts("Ivan", "Dub", "");
                    name2.SetNameParts("Ivan2", "Dub", "");
                    Assert.AreEqual(50.0f, name1.IsMatch(name2, false));
                }
            }

            persName.ResetOwner(fContext.Tree);
            Assert.AreEqual(fContext.Tree, persName.GetTree());

            persName.Clear();
            Assert.IsTrue(persName.IsEmpty());
        }