public void Test_SetNote() { string[] lines = new string [] { "This is a test line 1", "This is a test line 2", "This is a test line 3" }; StringList value = new StringList(lines); GDMNoteRecord instance = new GDMNoteRecord(null); instance.Lines.AddRange(lines); Assert.AreEqual(value.Text, instance.Lines.Text); }
public void Test_SetNoteText2() { string text = "Yet another test"; string text0 = "Initial text"; GDMNoteRecord instance = new GDMNoteRecord(null); instance.ParseString(text0); instance.SetNoteText(text); StringList value = new StringList(text); Assert.AreEqual(value.Text, instance.Lines.Text); }
/// <summary> /// The MoveTo() merges records and their references, but does not change the text in the target. /// </summary> /// <param name="targetRecord"></param> /// <param name="clearDest"></param> public override void MoveTo(GDMRecord targetRecord, bool clearDest) { GDMNoteRecord targetNote = (targetRecord as GDMNoteRecord); if (targetNote == null) { throw new ArgumentException(@"Argument is null or wrong type", "targetRecord"); } string targetText = targetNote.Lines.Text; base.MoveTo(targetRecord, clearDest); targetNote.Lines.Text = targetText; }
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()); } } }
public void Test_AddNoteText2() { string text1 = "This is a test"; string text2 = "This is another test"; GDMNoteRecord instance = new GDMNoteRecord(null); instance.ParseString(text1); instance.AddNoteText(text2); StringList value = new StringList(text1); value.Add(text2); Assert.AreEqual(value.Text, instance.Lines.Text); }
public void Test_IsMatch3() { var matchParams = new MatchParams(); GDMNoteRecord instance1 = new GDMNoteRecord(null); instance1.ParseString("This is a test"); GDMNoteRecord instance2 = new GDMNoteRecord(null); instance2.ParseString("This is a test"); float result = instance1.IsMatch(instance2, matchParams); // TODO matchParams is not used Assert.AreEqual(100.0F, result, 0.0); }
private static void GEDCOMNotesTest(GDMNoteRecord noteRec, GDMIndividualRecord indiv) { GDMNotes notes = indiv.AddNote(noteRec); Assert.IsTrue(notes.IsPointer, "notes.IsPointer"); Assert.Throws <InvalidOperationException>(() => { var lines = notes.Lines; }, "Notes is a pointer"); Assert.AreEqual(notes.XRef, noteRec.XRef); Assert.IsFalse(notes.IsEmpty()); // its pointer notes.Clear(); }
public override float IsMatch(GDMTag tag, MatchParams matchParams) { GDMNoteRecord note = tag as GDMNoteRecord; if (note == null) { return(0.0f); } float match = 0.0f; if (string.Compare(fLines.Text, note.Lines.Text, true) == 0) { match = 100.0f; } return(match); }
public bool DeleteNoteRecord(GDMNoteRecord nRec) { if (nRec == null) { return(false); } int num = fRecords.Count; for (int i = 0; i < num; i++) { GDMRecord rec = fRecords[i]; for (int j = rec.Notes.Count - 1; j >= 0; j--) { if (rec.Notes[j].Value == nRec) { rec.Notes.DeleteAt(j); } } } DeleteRecord(nRec); return(true); }
public void Test_Common() { GDMTree tree = new GDMTree(); Assert.IsNotNull(tree); Assert.IsNotNull(tree.GetSubmitter()); // Tests of event handlers tree.OnChange += OnTreeChange; tree.OnChanging += OnTreeChanging; tree.OnProgress += OnTreeProgress; tree.BeginUpdate(); Assert.IsTrue(tree.IsUpdated()); GDMRecord rec; GDMIndividualRecord iRec = tree.CreateIndividual(); Assert.IsNotNull(iRec, "CreateIndividual() != null"); string xref = iRec.XRef; rec = tree.XRefIndex_Find(xref); Assert.IsNotNull(rec); Assert.AreEqual(xref, rec.XRef); string uid = iRec.UID; rec = tree.FindUID(uid); Assert.IsNotNull(rec); Assert.AreEqual(uid, rec.UID); Assert.IsNull(tree.FindUID("")); // GDMFamilyRecord famRec = tree.CreateFamily(); Assert.IsNotNull(famRec, "CreateFamily() != null"); // GDMNoteRecord noteRec = tree.CreateNote(); Assert.IsNotNull(noteRec, "CreateNote() != null"); // GDMRepositoryRecord repRec = tree.CreateRepository(); Assert.IsNotNull(repRec, "CreateRepository() != null"); // GDMSourceRecord srcRec = tree.CreateSource(); Assert.IsNotNull(srcRec, "CreateSource() != null"); // GDMMultimediaRecord mmRec = tree.CreateMultimedia(); Assert.IsNotNull(mmRec, "CreateMultimedia() != null"); // GDMRecord sbmrRec = tree.AddRecord(new GDMSubmitterRecord(tree)); Assert.IsNotNull(sbmrRec, "sbmrRec != null"); tree.NewXRef(sbmrRec); string submXRef = sbmrRec.XRef; // GDMSubmissionRecord submRec = tree.AddRecord(new GDMSubmissionRecord(tree)) as GDMSubmissionRecord; Assert.IsNotNull(submRec, "rec1 != null"); tree.NewXRef(submRec); // GDMGroupRecord groupRec = tree.CreateGroup(); Assert.IsNotNull(groupRec, "CreateGroup() != null"); // GDMTaskRecord taskRec = tree.CreateTask(); Assert.IsNotNull(taskRec, "CreateTask() != null"); // GDMCommunicationRecord commRec = tree.CreateCommunication(); Assert.IsNotNull(commRec, "CreateCommunication() != null"); // GDMResearchRecord resRec = tree.CreateResearch(); Assert.IsNotNull(resRec, "CreateResearch() != null"); // GDMLocationRecord locRec = tree.CreateLocation(); Assert.IsNotNull(locRec, "CreateLocation() != null"); tree.EndUpdate(); Assert.IsFalse(tree.IsUpdated()); tree.OnChange -= OnTreeChange; tree.OnChanging -= OnTreeChanging; tree.OnProgress -= OnTreeProgress; int size = 0; var enum1 = tree.GetEnumerator(GDMRecordType.rtNone); GDMRecord rec1; enum1.Reset(); while (enum1.MoveNext(out rec1)) { size++; } Assert.AreEqual(14, size); for (int i = 0; i < tree.RecordsCount; i++) { GDMRecord rec2 = tree[i]; Assert.IsNotNull(rec2); string xref2 = rec2.XRef; GDMRecord rec3 = tree.XRefIndex_Find(xref2); Assert.IsNotNull(rec3); Assert.AreEqual(rec2, rec3); /*string uid = rec2.UID; * GEDCOMRecord rec4 = tree.FindUID(uid); * Assert.IsNotNull(rec4); * Assert.AreEqual(rec2, rec4);*/ int idx = tree.IndexOf(rec2); Assert.AreEqual(i, idx); } var recordsX = tree.GetRecords <GDMIndividualRecord>(); Assert.IsNotNull(recordsX); Assert.AreEqual(1, recordsX.Count); int[] stats = tree.GetRecordStats(); Assert.IsNotNull(stats); Assert.AreEqual(14, stats.Length); Assert.IsFalse(tree.IsEmpty); Assert.IsFalse(tree.DeleteFamilyRecord(null)); Assert.IsTrue(tree.DeleteFamilyRecord(famRec)); Assert.IsFalse(tree.DeleteNoteRecord(null)); Assert.IsTrue(tree.DeleteNoteRecord(noteRec)); Assert.IsFalse(tree.DeleteSourceRecord(null)); Assert.IsTrue(tree.DeleteSourceRecord(srcRec)); Assert.IsFalse(tree.DeleteGroupRecord(null)); Assert.IsTrue(tree.DeleteGroupRecord(groupRec)); Assert.IsFalse(tree.DeleteLocationRecord(null)); Assert.IsTrue(tree.DeleteLocationRecord(locRec)); Assert.IsFalse(tree.DeleteResearchRecord(null)); Assert.IsTrue(tree.DeleteResearchRecord(resRec)); Assert.IsFalse(tree.DeleteCommunicationRecord(null)); Assert.IsTrue(tree.DeleteCommunicationRecord(commRec)); Assert.IsFalse(tree.DeleteTaskRecord(null)); Assert.IsTrue(tree.DeleteTaskRecord(taskRec)); Assert.IsFalse(tree.DeleteMediaRecord(null)); Assert.IsTrue(tree.DeleteMediaRecord(mmRec)); Assert.IsFalse(tree.DeleteIndividualRecord(null)); Assert.IsTrue(tree.DeleteIndividualRecord(iRec)); Assert.IsFalse(tree.DeleteRepositoryRecord(null)); Assert.IsTrue(tree.DeleteRepositoryRecord(repRec)); tree.Clear(); Assert.AreEqual(0, tree.RecordsCount); Assert.IsTrue(tree.IsEmpty); tree.State = GDMTreeState.osReady; Assert.AreEqual(GDMTreeState.osReady, tree.State); // Tests of GEDCOMTree.Extract() using (GDMTree tree2 = new GDMTree()) { GDMIndividualRecord iRec2 = tree.AddRecord(new GDMIndividualRecord(tree2)) as GDMIndividualRecord; Assert.IsNotNull(iRec2); tree2.NewXRef(iRec2); tree2.AddRecord(iRec2); int rIdx = tree2.IndexOf(iRec2); Assert.IsTrue(rIdx >= 0); GDMRecord extractedRec = tree2.Extract(rIdx); Assert.AreEqual(iRec2, extractedRec); Assert.IsTrue(tree2.IndexOf(iRec2) < 0); } }