public void CopyNoteTest() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); FAKE_LayoutPanel panelToUse = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panelToUse); // needed else DataGrid does not initialize form.Show(); //form.Visible = false; _w.output("boom"); // March 2013 -- notelist relies on having this YOM2013.DefaultLayouts.CreateASystemLayout(form, null); //NOTE: For now remember that htis ADDS 1 Extra notes string panelname = System.Guid.NewGuid().ToString(); panelToUse.NewLayout(panelname, true, null); LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel"); _w.output("herefirst"); Timer SaveTimer = new Timer(); SaveTimer.Interval = 300; SaveTimer.Tick += HandleSaveTimerTick; SaveTimer.Start(); // ADD 1 of each type foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) { for (int i = 0; i < 2; i++) { NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance(t); panelToUse.AddNote(note); note.CreateParent(panelToUse); note.UpdateAfterLoad(); panelToUse.CopyNote(note); panelToUse.PasteNote(); } } panelToUse.SaveLayout(); //int propercount= 4 * LayoutDetails.Instance.ListOfTypesToStoreInXML().Length; Assert.AreEqual(46, panelToUse.CountNotes()); // // Now we test pasting one of our notes onto another Layout // string panelname2 = System.Guid.NewGuid().ToString(); FAKE_LayoutPanel PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); PanelOtherGuy.NewLayout(panelname2, true, null); PanelOtherGuy.SaveLayout(); form.Controls.Add(PanelOtherGuy); Assert.AreEqual(2, PanelOtherGuy.CountNotes(), "count1"); // ADD 1 of each type //foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) { for (int i = 0; i < 10; i++) { NoteDataInterface note = new NoteDataXML_RichText(); PanelOtherGuy.AddNote(note); note.CreateParent(PanelOtherGuy); note.UpdateAfterLoad(); } } Assert.AreEqual(12, PanelOtherGuy.CountNotes(), "count2"); PanelOtherGuy.PasteNote(); Assert.AreEqual(13, PanelOtherGuy.CountNotes(), "count2"); PanelOtherGuy.SaveLayout(); FAKE_NoteDataXML_Text Noter = new FAKE_NoteDataXML_Text(); Noter.Caption = "Hello there"; PanelOtherGuy.AddNote(Noter); Noter.GetRichTextBox().Text = "bear"; PanelOtherGuy.SaveLayout(); PanelOtherGuy.CopyNote(Noter); NoteDataXML_RichText CopyOfTextNote = (NoteDataXML_RichText)PanelOtherGuy.PasteNote(); Assert.AreEqual("Hello there", CopyOfTextNote.Caption); Assert.AreEqual("bear", CopyOfTextNote.GetRichTextBox().Text); // // // Table Copy Test // // NoteDataXML_Table randomTables = new NoteDataXML_Table(100, 100, new ColumnDetails[2] { new ColumnDetails("id", 100), new ColumnDetails("tables", 100) }); randomTables.Caption = LayoutDetails.SYSTEM_RANDOM_TABLES; // randomTables.Columns = new appframe.ColumnDetails[2]{new appframe.ColumnDetails("id",100), new appframe.ColumnDetails("tables",100)}; PanelOtherGuy.AddNote(randomTables); //randomTables.CreateParent(PanelOtherGuy); randomTables.AddRow(new object[2] { "1", "example|colors" }); randomTables.AddRow(new object[2] { "2", "example|colorPROMPTS" }); PanelOtherGuy.SaveLayout(); PanelOtherGuy.CopyNote(randomTables); NoteDataXML_Table CopyOfTable = (NoteDataXML_Table)PanelOtherGuy.PasteNote(); Assert.AreEqual(2, CopyOfTable.RowCount()); }
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(); }