public void Test_Common() { GDMIndividualRecord iRec = fContext.Tree.XRefIndex_Find("I1") as GDMIndividualRecord; GDMCustomEvent evt, evtd; GEDCOMRecordTest(iRec); evt = iRec.FindEvent(GEDCOMTagType.BIRT); Assert.IsNotNull(evt); evtd = iRec.FindEvent(GEDCOMTagType.DEAT); Assert.IsNotNull(evtd); Assert.IsFalse(iRec.IsLive()); GDMIndividualRecord ind3 = fContext.Tree.XRefIndex_Find("I3") as GDMIndividualRecord; Assert.IsNotNull(fContext.Tree.GetParentsFamily(ind3)); GDMIndividualRecord ind2 = fContext.Tree.XRefIndex_Find("I2") as GDMIndividualRecord; Assert.IsNotNull(fContext.Tree.GetMarriageFamily(ind2)); // TODO: transfer to BaseContext tests GDMIndividualRecord indiRec = fContext.Tree.XRefIndex_Find("I4") as GDMIndividualRecord; Assert.IsNull(fContext.GetMarriageFamily(indiRec, false)); Assert.IsNotNull(fContext.GetMarriageFamily(indiRec, true)); // Assert.Throws(typeof(ArgumentException), () => { indiRec.Assign(null); }); indiRec.AutomatedRecordID = "test11"; Assert.AreEqual("test11", indiRec.AutomatedRecordID); Assert.AreEqual(GDMRecordType.rtIndividual, indiRec.RecordType); Assert.AreEqual(4, indiRec.GetId()); Assert.AreEqual("4", indiRec.GetXRefNum()); Assert.AreEqual(-1, indiRec.IndexOfSource(null)); indiRec.AddUserRef("test userref"); Assert.AreEqual("test userref", indiRec.UserReferences[0].StringValue); // Assert.IsNotNull(indiRec.Associations); Assert.IsNotNull(indiRec.UserReferences); // for GEDCOMRecord Assert.Throws(typeof(ArgumentException), () => { indiRec.AddEvent(new GDMFamilyEvent()); }); GDMIndividualRecord father, mother; fContext.Tree.GetParents(indiRec, out father, out mother); Assert.IsNull(father); Assert.IsNull(mother); indiRec.Sex = GDMSex.svMale; Assert.AreEqual(GDMSex.svMale, indiRec.Sex); indiRec.Restriction = GDMRestriction.rnLocked; Assert.AreEqual(GDMRestriction.rnLocked, indiRec.Restriction); indiRec.Patriarch = true; Assert.AreEqual(true, indiRec.Patriarch); indiRec.Patriarch = false; Assert.AreEqual(false, indiRec.Patriarch); indiRec.Bookmark = true; Assert.AreEqual(true, indiRec.Bookmark); indiRec.Bookmark = false; Assert.AreEqual(false, indiRec.Bookmark); Assert.Throws(typeof(ArgumentException), () => { indiRec.MoveTo(null); }); using (GDMIndividualRecord copyIndi = new GDMIndividualRecord(null)) { Assert.IsNotNull(copyIndi); Assert.Throws(typeof(ArgumentException), () => { copyIndi.Assign(null); }); copyIndi.Assign(indiRec); Assert.AreEqual(100.0f, indiRec.IsMatch(copyIndi, new MatchParams())); } Assert.IsFalse(indiRec.IsEmpty()); indiRec.Clear(); Assert.IsTrue(indiRec.IsEmpty()); float ca = indiRec.GetCertaintyAssessment(); Assert.AreEqual(0.0f, ca); Assert.IsNull(indiRec.GetPrimaryMultimediaLink()); GDMMultimediaLink mmLink = indiRec.SetPrimaryMultimediaLink(null); Assert.IsNull(mmLink); GDMMultimediaRecord mmRec = fContext.Tree.CreateMultimedia(); mmLink = indiRec.SetPrimaryMultimediaLink(mmRec); Assert.IsNotNull(mmLink); mmLink = indiRec.GetPrimaryMultimediaLink(); Assert.AreEqual(mmRec, fContext.Tree.GetPtrValue <GDMMultimediaRecord>(mmLink)); Assert.AreEqual(-1, indiRec.IndexOfGroup(null)); Assert.AreEqual(-1, indiRec.IndexOfSpouse(null)); GDMIndividualRecord indi2 = fContext.Tree.XRefIndex_Find("I2") as GDMIndividualRecord; GDMAssociation asso = indiRec.AddAssociation("test", indi2); Assert.IsNotNull(asso); using (GDMIndividualRecord indi = new GDMIndividualRecord(fContext.Tree)) { Assert.IsNotNull(indi); var parts = GKUtils.GetNameParts(fContext.Tree, indi); // test with empty PersonalNames Assert.AreEqual("", parts.Surname); Assert.AreEqual("", parts.Name); Assert.AreEqual("", parts.Patronymic); indi.AddPersonalName(new GDMPersonalName()); // test with empty Name parts = GKUtils.GetNameParts(fContext.Tree, indi); Assert.AreEqual("", parts.Surname); Assert.AreEqual("", parts.Name); Assert.AreEqual("", parts.Patronymic); indi.PersonalNames.Clear(); string st; Assert.AreEqual("", GKUtils.GetNameString(indi, true, false)); Assert.AreEqual("", GKUtils.GetNickString(indi)); GDMPersonalName pName = new GDMPersonalName(); indi.AddPersonalName(pName); pName.Pieces.Nickname = "BigHead"; pName.SetNameParts("Ivan", "Petrov", ""); st = GKUtils.GetNameString(indi, true, true); Assert.AreEqual("Petrov Ivan [BigHead]", st); st = GKUtils.GetNameString(indi, false, true); Assert.AreEqual("Ivan Petrov [BigHead]", st); Assert.AreEqual("BigHead", GKUtils.GetNickString(indi)); Assert.IsNull(fContext.Tree.GetParentsFamily(indi)); // TODO: move to BaseContext tests Assert.IsNotNull(fContext.GetParentsFamily(indi, true)); // MoveTo test GDMIndividualRecord ind = fContext.Tree.XRefIndex_Find("I2") as GDMIndividualRecord; indi.AddAssociation("test", ind); using (GDMIndividualRecord indi3 = new GDMIndividualRecord(fContext.Tree)) { indi.MoveTo(indi3); st = GKUtils.GetNameString(indi3, true, true); Assert.AreEqual("Petrov Ivan [BigHead]", st); } indi.ResetTree(fContext.Tree); } indiRec.ReplaceXRefs(new GDMXRefReplacer()); fContext.Tree.SortSpouses(indiRec); Assert.AreEqual(0, fContext.Tree.GetTotalChildrenCount(indiRec)); }