コード例 #1
0
        public void Test_Common3()
        {
            GDMNoteRecord       noteRec = fContext.Tree.CreateNote();
            GDMIndividualRecord indiv   = fContext.Tree.CreateIndividual();

            noteRec.SetNotesArray(new string[] { "This", "notes", "test" });

            string ctx = GKUtils.MergeStrings(noteRec.Lines);

            Assert.AreEqual("This notes test", ctx);

            noteRec.Lines.Text = "This\r\nnotes2\r\ntest2";
            Assert.AreEqual("This", noteRec.Lines[0]);
            Assert.AreEqual("notes2", noteRec.Lines[1]);
            Assert.AreEqual("test2", noteRec.Lines[2]);

            Assert.Throws(typeof(ArgumentNullException), () => { GKUtils.MergeStrings(null); });

            ctx = GKUtils.MergeStrings(noteRec.Lines);
            Assert.AreEqual("This notes2 test2", ctx);

            noteRec.Clear();
            noteRec.AddNoteText("Test text");
            Assert.AreEqual("Test text", noteRec.Lines.Text.Trim());

            GEDCOMNotesTest(noteRec, indiv);

            Assert.IsFalse(noteRec.IsEmpty());
            noteRec.Clear();
            Assert.IsTrue(noteRec.IsEmpty());
        }
コード例 #2
0
        public void Test_Common()
        {
            using (GDMNoteRecord noteRec = new GDMNoteRecord(null)) {
                Assert.AreEqual(GDMRecordType.rtNote, noteRec.RecordType);

                noteRec.AddNoteText("text");
                Assert.AreEqual("text", noteRec.Lines.Text.Trim());

                Assert.Throws(typeof(ArgumentNullException), () => {
                    noteRec.SetNoteText(null);
                });

                noteRec.SetNoteText("Test text");
                Assert.AreEqual("Test text", noteRec.Lines.Text.Trim());

                using (GDMNoteRecord noteRec2 = new GDMNoteRecord(null)) {
                    noteRec2.SetNoteText("Test text");
                    Assert.AreEqual("Test text", noteRec2.Lines.Text.Trim());

                    Assert.AreEqual(100.0f, noteRec.IsMatch(noteRec2, new MatchParams()), 0.01f);

                    Assert.IsFalse(noteRec2.IsEmpty());
                    noteRec2.Clear();
                    Assert.IsTrue(noteRec2.IsEmpty());

                    Assert.AreEqual(0.0f, noteRec.IsMatch(noteRec2, new MatchParams()), 0.01f);

                    Assert.AreEqual(0.0f, noteRec.IsMatch(null, new MatchParams()), 0.01f);
                }

                Assert.Throws(typeof(ArgumentException), () => {
                    noteRec.MoveTo(null);
                });

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

                using (GDMNoteRecord noteRec3 = new GDMNoteRecord(null)) {
                    noteRec3.SetNoteText("Test text 3");
                    Assert.AreEqual("Test text 3", noteRec3.Lines.Text.Trim());

                    noteRec.MoveTo(noteRec3);

                    Assert.AreEqual("Test text 3", noteRec3.Lines.Text.Trim());
                }
            }
        }