public void AdvancedSearchingForNotesTests() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); //_SetupForLayoutPanelTests (); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid1"; basicNote.Caption = "note1"; panel.AddNote(basicNote); basicNote.CreateParent(panel); panel.SaveLayout(); FAKE_NoteDataXML_Panel DiversionPanel = new FAKE_NoteDataXML_Panel(); DiversionPanel.Caption = "WeAdd this to make the FindFail later by having an empty layout that sends buggy searches down the wrong corridor"; panel.AddNote(DiversionPanel); DiversionPanel.CreateParent(panel); FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.Caption = "PanelA"; panel.AddNote(panelA); panelA.CreateParent(panel); basicNote = new NoteDataXML(); basicNote.GuidForNote = "thisguid2"; basicNote.Caption = "note2"; panelA.AddNote(basicNote); // Panel A has 1 note basicNote.CreateParent(panelA.myLayoutPanel()); // DO need to call it when adding notes like this (to a subpanel, I think) panel.SaveLayout(); NoteDataInterface finder = null; finder = panel.FindNoteByGuid("thisguid1"); Assert.NotNull(finder.ParentNotePanel); _w.output("C: " + finder.Caption); Assert.AreEqual(finder.Caption, "note1"); Assert.NotNull(finder.ParentNotePanel); finder = null; // this note is on a subpanel finder = panel.FindNoteByGuid("thisguid2"); Assert.NotNull(finder); Assert.AreEqual(finder.Caption, "note2"); finder = panel.GoToNote(finder); // added this February 2013 because this code stopped finding notes within subpanels for some reason Assert.NotNull(finder.ParentNotePanel); // find notes inside of notes with the GUI code and such // now test the fast search function NoteDataInterface foundNote2 = panel.GetNoteOnSameLayout(finder.GuidForNote, false); Assert.NotNull(foundNote2); Assert.AreEqual(finder.GuidForNote, foundNote2.GuidForNote); Assert.NotNull(foundNote2.ParentNotePanel); }
public void TestThatChildInheritsKeywordsAndOtherDetailsOfParent() { System.Windows.Forms.Form form = new System.Windows.Forms.Form(); _TestSingleTon.Instance._SetupForLayoutPanelTests(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panel); form.Show(); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.Caption = "note1"; panel.AddNote(basicNote); //basicNote.CreateParent(panel); //panel.MoveNote( // create four panels A and B at root level. C inside A. D inside C FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.Caption = "PanelA"; panelA.GuidForNote = "panela"; FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel(); panelB.Caption = "PanelB"; panelB.GuidForNote = "panelb"; FAKE_NoteDataXML_Panel panelC = new FAKE_NoteDataXML_Panel(); panelC.Caption = "PanelC"; _w.output("panels made"); panel.AddNote(panelA); // 1 panel.AddNote(panelB); // 2 //panelA.CreateParent(panel); should not need to call this when doing LayoutPanel.AddNote because it calls CreateParent insid eof it basicNote = new NoteDataXML(); basicNote.Caption = "note2"; panelA.AddNote(basicNote); // Panel A has 1 note basicNote.CreateParent(panelA.myLayoutPanel()); // DO need to call it when adding notes like this (to a subpanel, I think) panel.SaveLayout(); Assert.AreEqual(1, panelA.CountNotes(), "Panel A holds one note"); // So this counts as + 2 // so we have (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6 Assert.AreEqual(6, panel.CountNotes(), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); //COUNT SHOULD BE: panelA has 1 note //COUNT Total should be: Default Note + Note + PanelA + Panel B + (Note Inside Panel A) = 5 panelA.AddNote(panelC); // panelC is now part of Panel 2 panelC.CreateParent(panelA.myLayoutPanel()); panel.SaveLayout(); // NEED TO SAVE before conts will be accurated //COUNT SHOULD BE: panelA has 2 notes (Panel C + the Note I add) Assert.AreEqual(2, panelA.CountNotes(), "two notes in panelA"); Assert.AreEqual(7, panel.CountNotes(), "total of SEVEN notes"); Assert.AreEqual(0, panelB.CountNotes(), "0 count worked?"); // The Preamble Above is just standard creation // Now we want to test adjusting some fields panel.NotesForYou().Section = "thepanelsection"; panel.NotesForYou().Keywords = "fish,fries,in,the,sky"; panel.NotesForYou().Notebook = "freshnote"; panel.NotesForYou().Subtype = "thebestsub"; panel.SaveLayout(); // now reload panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); panel.LoadLayout("mynewpanel", false, null); panelA = null; panelB = null; panelA = (FAKE_NoteDataXML_Panel)panel.FindNoteByGuid("panela"); panelB = (FAKE_NoteDataXML_Panel)panel.FindNoteByGuid("panelb"); Assert.AreEqual(panel.GUID, panelA.GetParent_ParentGuid()); Assert.AreEqual(panel.GUID, panelB.GetParent_ParentGuid()); Assert.AreEqual(2, panelA.CountNotes(), "two notes in panelA"); Assert.AreEqual(7, panel.CountNotes(), "total of SEVEN notes"); Assert.AreEqual(0, panelB.CountNotes(), "0 count worked?"); // just make sure that the Parent itself got the changes we made!! Assert.AreEqual("thepanelsection", panel.NotesForYou().Section); Assert.AreEqual("fish,fries,in,the,sky", panel.NotesForYou().Keywords); Assert.AreEqual("freshnote", panel.NotesForYou().Notebook); Assert.AreEqual("thebestsub", panel.NotesForYou().Subtype); // now test the Children // this should FAIL utnil I write the needed code Assert.AreEqual("thepanelsection", panelA.GetParent_Section()); Assert.AreEqual("thepanelsection", panelB.GetParent_Section()); Assert.AreEqual("fish,fries,in,the,sky", panelA.GetParent_Keywords()); Assert.AreEqual("fish,fries,in,the,sky", panelB.GetParent_Keywords()); Assert.AreEqual("freshnote", panelA.GetParent_Notebook()); Assert.AreEqual("freshnote", panelB.GetParent_Notebook()); Assert.AreEqual("thebestsub", panelA.GetParent_Subtype()); Assert.AreEqual("thebestsub", panelB.GetParent_Subtype()); }
public void TimelineAndTableAlwaysTogether() { _w.output("START"); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); _TestSingleTon.Instance._SetupForLayoutPanelTests(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panel); form.Show(); //NOTE: For now remember that htis ADDS 1 Extra notes panel.NewLayout("mynewpanel", true, null); NoteDataXML basicNote = new NoteDataXML(); basicNote.Caption = "note1"; panel.AddNote(basicNote); //basicNote.CreateParent(panel); //panel.MoveNote( // create four panels A and B at root level. C inside A. D inside C FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.Caption = "PanelA"; panelA.GuidForNote = "panela"; FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel(); panelB.Caption = "PanelB"; panelB.GuidForNote = "panelb"; FAKE_NoteDataXML_Panel panelC = new FAKE_NoteDataXML_Panel(); panelC.Caption = "PanelC"; panelC.GuidForNote = "panelc"; _w.output("panels made"); panel.AddNote(panelA); // 1 panel.AddNote(panelB); // 2 //panelA.CreateParent(panel); should not need to call this when doing LayoutPanel.AddNote because it calls CreateParent insid eof it basicNote = new NoteDataXML(); basicNote.Caption = "note2"; panelA.AddNote(basicNote); // Panel A has 1 note basicNote.CreateParent(panelA.myLayoutPanel()); // DO need to call it when adding notes like this (to a subpanel, I think) panel.SaveLayout(); Assert.AreEqual(1, panelA.CountNotes(), "Panel A holds one note"); // So this counts as + 2 // so we have (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6 _w.output("STARTCOUNT"); Assert.AreEqual(6, panel.CountNotes(), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); _w.output("ENDCOUNT"); // add timeline into a PANEL // count 1 row NoteDataXML_Timeline MyTimeLine = new NoteDataXML_Timeline(100, 100); MyTimeLine.Caption = "My Timeline!"; panelA.AddNote(MyTimeLine); MyTimeLine.CreateParent(panelA.GetPanelsLayout()); panel.SaveLayout(); // I needed this save else it would not work? Assert.AreEqual(8, panel.CountNotes(), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); string guidOfTimeline = MyTimeLine.GuidForNote; string guidOfTimelineTable = guidOfTimeline + "table"; NoteDataXML_Table FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable); Assert.NotNull(FoundTable); Assert.AreEqual(1, FoundTable.RowCount()); FoundTable = null; // move the TABLE associated with the timeline OUT to parent // count 1 row panelA.myLayoutPanel().MoveNote(guidOfTimelineTable, "up"); // And for kicks add another timeline just to see if it messages anytnig up NoteDataXML_Timeline MyTimeLine2 = new NoteDataXML_Timeline(100, 1020); MyTimeLine2.Caption = "My Timeline! #2"; panel.AddNote(MyTimeLine2); panel.SaveLayout(); Assert.AreEqual(10, panel.CountNotes(), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); Assert.Null(FoundTable); FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable); Assert.NotNull(FoundTable); Assert.AreEqual(1, FoundTable.RowCount()); // move the TABLE into ANOTHER panel // count 1 row _w.output("Moving into panelb now"); panel.MoveNote(guidOfTimelineTable, "panelb"); panel.SaveLayout(); Assert.AreEqual(10, panel.CountNotes(), "Total notes SHOULD BE 6 : (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5 + (NEW) LinkTable = 6"); _w.output("done counting"); FoundTable = null; Assert.Null(FoundTable); FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable); Assert.NotNull(FoundTable); Assert.AreEqual(1, FoundTable.RowCount()); form.Dispose(); }