Пример #1
0
        public void TestMovingNotes()
        {
            _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");

            //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)

            _w.output("START COUNT SUB");
            Assert.AreEqual(2, panelA.CountNotes(), "two notes in panelA");
            _w.output("END COUNT SUB");

            Assert.AreEqual(7, panel.CountNotes(), "total of SEVEN notes");

            _w.output("START COUNT SUB2");
            Assert.AreEqual(0, panelB.CountNotes(), "0 count worked?");
            _w.output("END COUNT SUB2");
            //COUNT Total should be: Default Note + Note + PanelA + Panel B + (NoteInside Panel A) + (Panel C Inside Panel A) = 6

            FAKE_NoteDataXML_Panel panelD = new FAKE_NoteDataXML_Panel();

            panelD.Caption = "PanelD";
            panelC.AddNote(panelD);              // panelC which is inside PANELA now adds panelD (which is empty?)
            panelD.CreateParent(panelC.myLayoutPanel());



            panel.SaveLayout();
            _w.output("START COUNT SUB3");
            Assert.AreEqual(0, panelD.CountNotes(), "No notes in panelD");
            _w.output("START COUNT SUB3");

            /*
             * NoteDataXML_RichText extra = new NoteDataXML_RichText();
             * panelD.AddNote (extra); //this was here only to test that there is an error with counting EMPTY panels
             * extra.CreateParent(panelD.myLayoutPanel());
             * panel.SaveLayout();*/
            // update on ERROR: Every note in D is being counted DOUBLE


            // weird error: If a panel is empty it will register as +1 (i.e, counted twice)

            // PanelC and PanelA are adding this note
//			AddChildrenToList, TYPE: TEMPORARY, scanning children...47d43f01-a031-42d1-8539-bb7ae284a9e1 from PanelC

//			AddChildrenToList, TYPE: TEMPORARY, scanning children...47d43f01-a031-42d1-8539-bb7ae284a9e1 from PanelA

            //OK: Every note is claiming ownership of the TEXT NOTE, which is the problem, I think.
            _w.output("START COUNT SUB4");
            Assert.AreEqual(1, panelC.CountNotes(), "1 notes in panelC");
            _w.output("E COUNT SUB4");
            Assert.AreEqual(0, panelD.CountNotes(), "1 note in panelD");
            _w.output("_------------------------------");
            _w.output("panel.CountNotes=" + panel.CountNotes());

            _w.output("_------------------------------");
            Assert.AreEqual(8, panel.CountNotes(), "We have only added one panel so we should be up to 8");

            Assert.AreEqual(3, panelA.CountNotes());

            Assert.AreEqual(8, panel.CountNotes(), "number of notes in main panel");
            Assert.AreEqual(0, panelB.CountNotes(), "testt");
            Assert.AreEqual(1, panelC.CountNotes(), "testt");

            // add a note to panel d (we want to make sure this note does not disappear while D is being moved around
            NoteDataXML noteford = new NoteDataXML();

            noteford.Caption = "note for d";
            panelD.AddNote(noteford);


            // Move panel D from panelC into PANEL A
            panelC.myLayoutPanel().MoveNote(panelD.GuidForNote, "up");
            panel.SaveLayout();
            Assert.AreEqual(4, panelA.CountNotes());               // 4 because I added a note to D which is inside A
            Assert.AreEqual(9, panel.CountNotes());
            Assert.AreEqual(0, panelC.CountNotes());
            Assert.AreEqual(0, panelB.CountNotes());
            Assert.AreEqual(1, panelD.CountNotes());
            // Move panel D from panelA into ROOT
            panelA.myLayoutPanel().MoveNote(panelD.GuidForNote, "up");
            panel.SaveLayout();
            Assert.AreEqual(2, panelA.CountNotes());
            Assert.AreEqual(9, panel.CountNotes());
            Assert.AreEqual(0, panelC.CountNotes());               // ** FINE HERE
            _w.output("do c twice, what happens?");
            Assert.AreEqual(0, panelC.CountNotes());
            Assert.AreEqual(0, panelB.CountNotes());
            Assert.AreEqual(1, panelD.CountNotes());


            lg.Instance.Loudness = Loud.ACRITICAL;

            _w.output("START COUNT SUB5");
            NoteDataXML_RichText richy = new NoteDataXML_RichText();

            richy.GuidForNote = "richy";
            panel.AddNote(richy);
            richy.CreateParent(panel);
            panel.SaveLayout();
            _w.output("do c THRICE, what happens?");
            Assert.AreEqual(0, panelC.CountNotes());
            _w.output("E COUNT SUB5");
            // now move note into A
            _w.output("move richy FROM PANEL into PanelA (PanelA also holds PanelC). The exact logic seems to be that IN THE FOLLOWING MOVE, PANELA Gets Disposed of??!?");
            panel.MoveNote(richy.GuidForNote, panelA.GuidForNote);
            panel.SaveLayout();
            _w.output("do c 4x, what happens?");
            Assert.AreEqual(0, panelC.CountNotes());


            _w.output("done move richy");
            Assert.AreEqual(3, panelA.CountNotes());
            Assert.AreEqual(10, panel.CountNotes());
            _w.output("countc");
            Assert.AreEqual(0, panelC.CountNotes());                // * Jan 19 2013 - brok ehere
            _w.output("e countc");
            _w.output("countb");

            Assert.AreEqual(0, panelB.CountNotes());
            _w.output("e countb");

            _w.output("Panel A Notes " + panelA.CountNotes().ToString());
            _w.output("Total Notes " + panel.CountNotes());
            // also see if this test or another could replicate the problems I had in previous version with RefhresTabs
            panel.SaveLayout();

            // now do a test to load it
            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.LoadLayout("mynewpanel", false, null);
            _w.output("getting notes for " + panel.Caption);
            System.Collections.ArrayList TheNotes = panel.GetAllNotes();

            //	System.Collections.Generic.List<NoteDataInterface> list = new System.Collections.Generic.List<NoteDataInterface> ();
            //list.AddRange ((NoteDataInterface[])TheNotes.ToArray ());
            int count = 0;

            foreach (NoteDataInterface note in TheNotes)
            {
                if (note.GuidForNote == CoreUtilities.Links.LinkTable.STICKY_TABLE)
                {
                    count++;
                }
            }
            // make sure there is only one linktable
            Assert.AreEqual(1, count);

            //.NoteDataInterface[] found = (NoteDataInterface)list.Find (NoteDataInterface=>NoteDataInterface.GuidForNote == CoreUtilities.Links.LinkTable.STICKY_TABLE );
            //	Assert.True (false);
        }
Пример #2
0
        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();
        }