Beispiel #1
0
        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());
        }