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(ind3.GetParentsFamily()); GDMIndividualRecord ind2 = fContext.Tree.XRefIndex_Find("I2") as GDMIndividualRecord; Assert.IsNotNull(ind2.GetMarriageFamily()); // GDMIndividualRecord indiRec = fContext.Tree.XRefIndex_Find("I4") as GDMIndividualRecord; Assert.IsNull(indiRec.GetMarriageFamily()); Assert.IsNotNull(indiRec.GetMarriageFamily(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.Aliases); Assert.IsNotNull(indiRec.Associations); Assert.IsNotNull(indiRec.UserReferences); // for GEDCOMRecord Assert.Throws(typeof(ArgumentException), () => { indiRec.AddEvent(new GDMFamilyEvent(null)); }); GDMIndividualRecord father, mother; GDMFamilyRecord fam = indiRec.GetParentsFamily(); if (fam == null) { father = null; mother = null; } else { father = fam.Husband.Individual; mother = fam.Wife.Individual; } 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, false); }); 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, mmLink.Value); 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(indi); // test with empty PersonalNames Assert.AreEqual("", parts.Surname); Assert.AreEqual("", parts.Name); Assert.AreEqual("", parts.Patronymic); indi.AddPersonalName(new GDMPersonalName(indi)); // test with empty Name parts = GKUtils.GetNameParts(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); 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(indi.GetParentsFamily()); Assert.IsNotNull(indi.GetParentsFamily(true)); // MoveTo test GDMIndividualRecord ind = fContext.Tree.XRefIndex_Find("I2") as GDMIndividualRecord; indi.AddAssociation("test", ind); indi.Aliases.Add(new GDMAlias(indi)); using (GDMIndividualRecord indi3 = new GDMIndividualRecord(fContext.Tree)) { indi.MoveTo(indi3, false); st = GKUtils.GetNameString(indi3, true, true); Assert.AreEqual("Petrov Ivan [BigHead]", st); } indi.ResetOwner(fContext.Tree); Assert.AreEqual(fContext.Tree, indi.GetTree()); } indiRec.ReplaceXRefs(new GDMXRefReplacer()); }
public void Test_Common() { GDMTree tree = new GDMTree(); Assert.IsNotNull(tree); GDMIndividualRecord indiv = tree.CreateIndividual(); Assert.IsNotNull(indiv); GDMFamilyRecord famRec = tree.CreateFamily(); Assert.IsNotNull(famRec); famRec.Restriction = GDMRestriction.rnLocked; Assert.AreEqual(GDMRestriction.rnLocked, famRec.Restriction); famRec.AddChild(indiv); Assert.AreEqual(0, famRec.IndexOfChild(indiv)); famRec.Husband.Value = tree.CreateIndividual(); famRec.Wife.Value = tree.CreateIndividual(); using (GDMFamilyRecord fam2 = tree.CreateFamily()) { Assert.Throws(typeof(ArgumentException), () => { fam2.Assign(null); }); fam2.Assign(famRec); string buf = TestUtils.GetTagStreamText(fam2, 0); Assert.AreEqual("0 @F2@ FAM\r\n" + "1 RESN locked\r\n" + "1 HUSB @I2@\r\n" + "1 WIFE @I3@\r\n" + "1 CHIL @I1@\r\n", buf); } // Integrity test GDMChildToFamilyLink childLink = indiv.ChildToFamilyLinks[0]; Assert.IsNotNull(childLink.Family); famRec.RemoveChild(indiv); Assert.AreEqual(-1, famRec.IndexOfChild(indiv)); // Assert.Throws(typeof(ArgumentException), () => { famRec.AddEvent(new GDMIndividualEvent(null)); }); famRec.ReplaceXRefs(new GDMXRefReplacer()); // famRec.Husband.Value = indiv; Assert.AreEqual(indiv, famRec.Husband.Individual); famRec.Husband.Value = null; // famRec.Wife.Value = indiv; Assert.AreEqual(indiv, famRec.Wife.Individual); famRec.Wife.Value = null; // indiv.Sex = GDMSex.svMale; famRec.AddSpouse(indiv); Assert.AreEqual(0, indiv.IndexOfSpouse(famRec)); Test_GDMSpouseToFamilyLink(indiv.SpouseToFamilyLinks[0]); Assert.IsNull(famRec.GetSpouseBy(indiv)); famRec.RemoveSpouse(indiv); indiv.Sex = GDMSex.svFemale; famRec.AddSpouse(indiv); Assert.AreEqual(0, indiv.IndexOfSpouse(famRec)); Test_GDMSpouseToFamilyLink(indiv.SpouseToFamilyLinks[0]); Assert.IsNull(famRec.GetSpouseBy(indiv)); famRec.RemoveSpouse(indiv); // famRec.SortChilds(); // famRec.AddChild(null); famRec.RemoveChild(null); famRec.AddSpouse(null); famRec.RemoveSpouse(null); // famRec.AddSpouse(indiv); famRec.AddChild(tree.CreateIndividual()); famRec.AddChild(tree.CreateIndividual()); famRec.AddChild(tree.CreateIndividual()); Assert.AreEqual(3, famRec.Children.Count); Assert.IsFalse(famRec.IsEmpty()); famRec.Clear(); Assert.IsTrue(famRec.IsEmpty()); }