public override void Assign(GDMTag source) { GDMSourceCitation sourceObj = (source as GDMSourceCitation); if (sourceObj == null) { throw new ArgumentException(@"Argument is null or wrong type", "source"); } base.Assign(sourceObj); fCertaintyAssessment = sourceObj.fCertaintyAssessment; fPage = sourceObj.fPage; fData.Assign(sourceObj.fData); fDescription.Assign(sourceObj.fDescription); fText.Assign(sourceObj.fText); if (sourceObj.fNotes != null) { AssignList(sourceObj.fNotes, Notes); } if (sourceObj.fMultimediaLinks != null) { AssignList(sourceObj.fMultimediaLinks, MultimediaLinks); } }
public void Test_GDMSourceCitation() { GDMIndividualRecord indiv = new GDMIndividualRecord(fContext.Tree); GDMSourceRecord sourRec = new GDMSourceRecord(fContext.Tree); using (GDMSourceCitation srcCit = indiv.AddSource(sourRec, "p2", 3)) { Assert.IsNotNull(srcCit); int idx = indiv.IndexOfSource(sourRec); Assert.AreEqual(0, idx); Assert.AreEqual("p2", srcCit.Page); Assert.AreEqual(3, srcCit.CertaintyAssessment); Assert.AreEqual(3, srcCit.GetValidCertaintyAssessment()); Assert.IsTrue(srcCit.IsPointer, "srcCit.IsPointer"); Assert.IsFalse(srcCit.IsEmpty(), "srcCit.IsEmpty()"); // its pointer Assert.Throws(typeof(ArgumentException), () => { srcCit.Assign(null); }); srcCit.Clear(); srcCit.Value = null; Assert.IsTrue(srcCit.IsEmpty(), "srcCit.IsEmpty()"); // its pointer srcCit.Description.Text = "test"; Assert.AreEqual("test", srcCit.Description.Text); } }
public float GetCertaintyAssessment() { float result = 0; float wsum = 0; if (fEvents != null) { int num1 = fEvents.Count; for (int i = 0; i < num1; i++) { GDMCustomEvent evt = fEvents[i]; if (!evt.HasSourceCitations) { continue; } int num2 = evt.SourceCitations.Count; for (int k = 0; k < num2; k++) { GDMSourceCitation cit = evt.SourceCitations[k]; int ca = cit.GetValidCertaintyAssessment(); int weight = (ca + 1); result += (CA_VALUES[ca] * weight); wsum += weight; } } } if (HasSourceCitations) { int num3 = SourceCitations.Count; for (int i = 0; i < num3; i++) { GDMSourceCitation cit = SourceCitations[i]; int ca = cit.GetValidCertaintyAssessment(); int weight = (ca + 1); result += (CA_VALUES[ca] * weight); wsum += weight; } } if (wsum != 0.0f) { result /= wsum; } else { result = 0.0f; } return(result); }
public GDMSourceCitation AddSource(GDMSourceRecord sourceRec, string page, int quality) { GDMSourceCitation cit = null; if (sourceRec != null) { cit = new GDMSourceCitation(this); cit.Value = sourceRec; cit.Page = page; cit.CertaintyAssessment = quality; fSourceCitations.Add(cit); } return(cit); }
public override void Assign(GDMTag source) { GDMSourceCitation sourceObj = (source as GDMSourceCitation); if (sourceObj == null) { throw new ArgumentException(@"Argument is null or wrong type", "source"); } base.Assign(sourceObj); fCertaintyAssessment = sourceObj.fCertaintyAssessment; fPage = sourceObj.fPage; fDescription.Assign(sourceObj.fDescription); }
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); } }
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()); }