Beispiel #1
0
        public static void Test_GDMSpouseToFamilyLink(GDMTree tree, GDMSpouseToFamilyLink spouseLink)
        {
            Assert.IsNotNull(tree.GetPtrValue <GDMFamilyRecord>(spouseLink));

            using (spouseLink = new GDMSpouseToFamilyLink()) {
                Assert.IsNotNull(spouseLink);
            }
        }
        public string GetUID(GDMTree tree)
        {
            string result = null;

            try {
                var mmRec = tree.GetPtrValue <GDMMultimediaRecord>(this);
                if (mmRec != null)
                {
                    ExtRect cutoutArea = IsPrimaryCutout ? CutoutPosition.Value : ExtRect.CreateEmpty();
                    result = mmRec.UID + "-" + GKUtils.GetRectUID(cutoutArea.Left, cutoutArea.Top, cutoutArea.Right, cutoutArea.Bottom);
                }
            } catch (Exception ex) {
                Logger.WriteError("GDMMultimediaLink.GetUID()", ex);
                result = null;
            }
            return(result);
        }
Beispiel #3
0
        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.XRef = tree.CreateIndividual().XRef;
            famRec.Wife.XRef    = tree.CreateIndividual().XRef;

            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(tree.GetPtrValue(childLink));

            famRec.RemoveChild(indiv);
            Assert.AreEqual(-1, famRec.IndexOfChild(indiv));

            //

            Assert.Throws(typeof(ArgumentException), () => {
                famRec.AddEvent(new GDMIndividualEvent());
            });

            famRec.ReplaceXRefs(new GDMXRefReplacer());

            //

            famRec.Husband.XRef = indiv.XRef;
            Assert.AreEqual(indiv, tree.GetPtrValue(famRec.Husband));
            famRec.Husband.XRef = string.Empty;

            //

            famRec.Wife.XRef = indiv.XRef;
            Assert.AreEqual(indiv, tree.GetPtrValue(famRec.Wife));
            famRec.Wife.XRef = string.Empty;

            //

            indiv.Sex = GDMSex.svMale;
            famRec.AddSpouse(indiv);
            Assert.AreEqual(0, indiv.IndexOfSpouse(famRec));
            Test_GDMSpouseToFamilyLink(tree, indiv.SpouseToFamilyLinks[0]);
            Assert.IsNull(tree.GetSpouseBy(famRec, indiv));
            famRec.RemoveSpouse(indiv);

            indiv.Sex = GDMSex.svFemale;
            famRec.AddSpouse(indiv);
            Assert.AreEqual(0, indiv.IndexOfSpouse(famRec));
            Test_GDMSpouseToFamilyLink(tree, indiv.SpouseToFamilyLinks[0]);
            Assert.IsNull(tree.GetSpouseBy(famRec, indiv));
            famRec.RemoveSpouse(indiv);

            //

            tree.SortChilds(famRec);

            //

            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());
        }