示例#1
0
        /// <summary>
        /// Compares to.
        /// Implements the interface
        /// </summary>
        /// <returns>
        /// The to.
        /// </returns>
        /// <param name='obj'>
        /// Object.
        /// </param>
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            NoteDataXML otherNote = obj as NoteDataXML;

            if (otherNote != null)
            {
                return(this.Caption.CompareTo(otherNote.Caption));
            }
            else
            {
                throw new Exception("Object is a NoteDataXML");
            }
        }
        public void TestAddItemsToStoryboard()
        {
            _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);

            NoteDataXML_GroupEm StoryBoard = new NoteDataXML_GroupEm();
            panel.AddNote (StoryBoard);

            //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";
            panel.AddNote (panelA);  // 1

            StoryBoard = new NoteDataXML_GroupEm();
            StoryBoard.GuidForNote = "storyboard2";
            StoryBoard.Caption = "storyboard";
            panelA.AddNote (StoryBoard);
            StoryBoard.CreateParent(panelA.GetPanelsLayout());

            Assert.AreEqual (0, StoryBoard.CountStoryBoardItems());

            CoreUtilities.Links.LinkTableRecord record = new CoreUtilities.Links.LinkTableRecord();
            record.sFileName = "PanelA";//StoryBoard.GuidForNote;
            record.sKey = "*";
            record.sText="*";
            record.sSource = StoryBoard.GuidForNote;
            panel.GetLinkTable().Add (record);
            Assert.AreEqual (1,panel.GetLinkTable ().Count());
            StoryBoard.Refresh();
            Assert.AreEqual (1, StoryBoard.CountStoryBoardItems());
        }
示例#3
0
        public void TestDefaultHeightAndWidth()
        {
            // nest several panels
            _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 test = new NoteDataXML(425,380);
            test.GuidForNote = "thisguid1";
            test.Caption = "note1";

            panel.AddNote(test);
            test.CreateParent(panel);
            panel.SaveLayout();

            Assert.AreEqual (test.Height, 425);
            Assert.AreEqual (test.Width, 380);
        }
        public void CountPanelsSubType()
        {
            System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            //FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            Assert.False (MasterOfLayouts.ExistsByGUID("testlayout"));

            _w.output("here");
            //-- do unit tests counting store 6 textboxes and know this (countbytype)
            //_setupforlayoutests ();

            _w.output("here");
            int count = 25;

            //	FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testlayout", false, null);
            form.Controls.Add (layoutPanel);
            form.Show ();

            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }
            _w.output (String.Format ("{0} Notes in Layout before save", layoutPanel.GetAllNotes ().Count.ToString ()));

            for (int i = 0; i < 6; i++) {
                note = new NoteDataXML_Panel ();

                note.Caption = "Panel";
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
                ((NoteDataXML_Panel)note).Add10TestNotes();
            }

            layoutPanel.SaveLayout();
            layoutPanel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            //_w.output(String.Format ("{0} Objects Saved", layoutPanel.ObjectsSaved().ToString()));
            layoutPanel.LoadLayout("testlayout",false, null);

            //			layout = new FakeLayoutDatabase ("testguid");
            //
            //			layout.LoadFrom(layoutPanel);

            // now count RichText notes
            int count2 = 0;
            int subnotecount = 0;
            foreach (NoteDataInterface _note in layoutPanel.GetAllNotes ())
            {
                if (_note.GetType() == typeof(NoteDataXML_Panel))
                {
                    count2++;
                    subnotecount = subnotecount + ((NoteDataXML_Panel)_note).GetChildNotes().Count;
                }

            }

            // total note count should be (once I get GetNotes working on Child Notes = 60 + 6 + 25 = 91

            _w.output(String.Format ("{0} Objects Loaded", layoutPanel.GetAllNotes().Count));
            //NOT DONE YET
            Assert.AreEqual (6, count2);
            Assert.AreEqual (60, subnotecount);
            Assert.AreEqual (count2, layoutPanel.GetAvailableFolders().Count);

            // had to change because a linktable makes 91 become 92
            Assert.AreEqual (92, layoutPanel.GetAllNotes().Count);
        }
 public void TestAddToStart()
 {
     _TestSingleTon.Instance._SetupForLayoutPanelTests();
     FakeLayoutDatabase layout = new FakeLayoutDatabase ("DeleteMe");
     //	LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
     layout.SaveTo ();
     NoteDataXML test = new NoteDataXML();
     test.GuidForNote = CoreUtilities.Links.LinkTable.STICKY_TABLE;
     layout.AddToStart(test);
 }
        public void SaveAndLoadStressLoad()
        {
            System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            int linktable = 1;
            int extranodeadded = 1;
            _w.output("this is a slow test. 6 minutes?");
            int count = 200;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);
            form.Controls.Add (layoutPanel);
            form.Show ();

            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {
                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }
            //_w.output(String.Format ("{0} Notes in Layout before save", layout.GetNotes().Count.ToString()));
            layoutPanel.SaveLayout();

            //_w.output(String.Format ("{0} Objects Saved", layout.ObjectsSaved().ToString()));
            //layoutPanel = new FakeLayoutDatabase ("testguid");
             layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            layoutPanel.LoadLayout("testguid", false, null);
            //layoutPanel.LoadFrom(layoutPanel);

            //_w.output(String.Format ("{0} Objects Loaded", layout.GetNotes().Count));
            //NOT DONE YET
            Assert.AreEqual (count + linktable + extranodeadded, layoutPanel.GetAllNotes().Count);
        }
        public void LayoutExists()
        {
            System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            _w.output("1");
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            _w.output("2");
            int count = 25;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);

            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }
            layoutPanel.SaveLayout();
            layoutPanel.Dispose ();
            Assert.True (MasterOfLayouts.ExistsByGUID("testguid"));
        }
示例#8
0
        /// <summary>
        /// Saves to the XML file.
        /// 
        /// Notice the GUID is NOT allowed to be passed in. It is stored in the document when Loaded or Created
        /// </summary>
        /// <returns>
        /// The to.
        /// </returns>
        public void SaveTo()
        {
            if (LayoutGUID == CoreUtilities.Constants.BLANK) {
                throw new Exception ("GUID need to be set before calling SaveTo");
            }
            string XMLAsString = CoreUtilities.Constants.BLANK;

            // we are storing a LIST of NoteDataXML objects
            //	CoreUtilities.General.Serialize(dataForThisLayout, CreateFileName());
            try {

                NoteDataXML[] ListAsDataObjectsOfType = new NoteDataXML[dataForThisLayout.Count];
                dataForThisLayout.CopyTo (ListAsDataObjectsOfType);

                System.Xml.Serialization.XmlSerializer x3 =
                    new System.Xml.Serialization.XmlSerializer (typeof(NoteDataXML[]),
                                                                new Type[1] {typeof(NoteDataXML)});

                // Okay: I gave up and accept utf-16 encoding
            //http://www.codeproject.com/Articles/58287/XML-Serialization-Tips-Tricks
            // Needed to pass Namespace because I wanted to override encoding, next parameter
                //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
            //	ns.Add ("", "");

                System.IO.StringWriter sw = new System.IO.StringWriter();
                //sw.Encoding = "";
                x3.Serialize (sw, ListAsDataObjectsOfType);
                //x3.Serialize (sw, ListAsDataObjectsOfType,ns, "utf-8");
                XMLAsString =sw.ToString();
                sw.Close ();

                /* Various attempts, got them all to work as I narrowed the right approach down

                // this works (just individual note)
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer (typeof(NoteDataXML));
                x.Serialize (Console.Out, (NoteDataXML)dataForThisLayout[0]);

                // this current WORKS (After resolving to a True data type rather than Interface). Collection of notes
                System.Xml.Serialization.XmlSerializer x2 =
                    new System.Xml.Serialization.XmlSerializer (typeof(List<NoteDataXML>),
                                                                new Type[1] {typeof(NoteDataXML)});
                x2.Serialize (Console.Out, dataForThisLayout);
                // Okay: Was able to serialize NoteDataXML now need to figure out list

                List<NoteDataInterface> test =  new List<NoteDataInterface>();

                // convert the list of interfaces to a list of notes
                // OKAY: This worked too. I can convert all this back to using an Interface
                NoteDataXML boo = new NoteDataXML();
                boo.Caption = "snakes eat fish";
                test.Add (boo);
                NoteDataXML[] xml2 = new NoteDataXML[test.Count];
                 test.CopyTo (xml2);

                System.Xml.Serialization.XmlSerializer x3 =
                    new System.Xml.Serialization.XmlSerializer (typeof(NoteDataXML[]),
                                                                new Type[1] {typeof(NoteDataXML)});
                x3.Serialize (Console.Out, xml2);
            */
            } catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            }
            //testthis?
            //	return XMLAsString;
        }
示例#9
0
        /// <summary>
        /// Saves to the XML file.
        ///
        /// Notice the GUID is NOT allowed to be passed in. It is stored in the document when Loaded or Created
        /// </summary>
        /// <returns>
        /// The to.
        /// </returns>
        public void SaveTo()
        {
            if (LayoutGUID == CoreUtilities.Constants.BLANK)
            {
                throw new Exception("GUID need to be set before calling SaveTo");
            }
            string XMLAsString = CoreUtilities.Constants.BLANK;

            // we are storing a LIST of NoteDataXML objects
            //	CoreUtilities.General.Serialize(dataForThisLayout, CreateFileName());
            try {
                NoteDataXML[] ListAsDataObjectsOfType = new NoteDataXML[dataForThisLayout.Count];
                dataForThisLayout.CopyTo(ListAsDataObjectsOfType);


                System.Xml.Serialization.XmlSerializer x3 =
                    new System.Xml.Serialization.XmlSerializer(typeof(NoteDataXML[]),
                                                               new Type[1] {
                    typeof(NoteDataXML)
                });


                // Okay: I gave up and accept utf-16 encoding
                //http://www.codeproject.com/Articles/58287/XML-Serialization-Tips-Tricks
                // Needed to pass Namespace because I wanted to override encoding, next parameter
                //XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                //	ns.Add ("", "");


                System.IO.StringWriter sw = new System.IO.StringWriter();
                //sw.Encoding = "";
                x3.Serialize(sw, ListAsDataObjectsOfType);
                //x3.Serialize (sw, ListAsDataObjectsOfType,ns, "utf-8");
                XMLAsString = sw.ToString();
                sw.Close();

                /* Various attempts, got them all to work as I narrowed the right approach down
                 *
                 * // this works (just individual note)
                 * System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer (typeof(NoteDataXML));
                 * x.Serialize (Console.Out, (NoteDataXML)dataForThisLayout[0]);
                 *
                 *
                 * // this current WORKS (After resolving to a True data type rather than Interface). Collection of notes
                 * System.Xml.Serialization.XmlSerializer x2 =
                 *      new System.Xml.Serialization.XmlSerializer (typeof(List<NoteDataXML>),
                 *                                                  new Type[1] {typeof(NoteDataXML)});
                 * x2.Serialize (Console.Out, dataForThisLayout);
                 * // Okay: Was able to serialize NoteDataXML now need to figure out list
                 *
                 *
                 *
                 * List<NoteDataInterface> test =  new List<NoteDataInterface>();
                 *
                 * // convert the list of interfaces to a list of notes
                 * // OKAY: This worked too. I can convert all this back to using an Interface
                 * NoteDataXML boo = new NoteDataXML();
                 * boo.Caption = "snakes eat fish";
                 * test.Add (boo);
                 * NoteDataXML[] xml2 = new NoteDataXML[test.Count];
                 * test.CopyTo (xml2);
                 *
                 *
                 * System.Xml.Serialization.XmlSerializer x3 =
                 *      new System.Xml.Serialization.XmlSerializer (typeof(NoteDataXML[]),
                 *                                                  new Type[1] {typeof(NoteDataXML)});
                 * x3.Serialize (Console.Out, xml2);
                 */
            } catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            }
            //testthis?
            //	return XMLAsString;
        }
示例#10
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 ();
        }
        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 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 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);
        }
        public void SetCurrentTextNoteAndDetectThisInParentLayouts()
        {
            // nest several panels
            _TestSingleTon.Instance._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 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();

            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel();
            panelB.Caption = "PanelB";
            panelA.AddNote(panelB);
            panelB.CreateParent(panelA.myLayoutPanel());

            FAKE_NoteDataXML_Panel panelC = new FAKE_NoteDataXML_Panel();
            panelC.Caption = "PanelC";
            panelB.AddNote(panelC);
            panelC.CreateParent(panelB.myLayoutPanel());

            FAKE_NoteDataXML_Panel panelD = new FAKE_NoteDataXML_Panel();
            panelD.Caption = "PanelD";
            panelC.AddNote(panelC);
            panelD.CreateParent(panelC.myLayoutPanel());

            //Add a text note
            FAKE_NoteDataXML_Text texter = new FAKE_NoteDataXML_Text();
            panelD.AddNote(texter);
            texter.CreateParent(panelD.myLayoutPanel());

            // Set this text note as active
            texter.SetActive();

            // Go back to each of the owner panels and make sure their CurrentTextNote is equal to this one
            Assert.AreEqual (panelD.myLayoutPanel().CurrentTextNote, texter);
            Assert.AreEqual (panelC.myLayoutPanel().CurrentTextNote, texter);
            Assert.AreEqual (panelB.myLayoutPanel().CurrentTextNote, texter);
            Assert.AreEqual (panelA.myLayoutPanel().CurrentTextNote, texter);
            Assert.AreEqual (panel.CurrentTextNote, texter);
        }
        public void MoveNoteOutOfParent_SaveShouldHappenAutomatically()
        {
            _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);

            LayoutDetails.Instance.CurrentLayout = panel;
                form.Controls.Add (panel);
                form.Show ();

                //NOTE: For now remember that htis ADDS 1 Extra notes
                panel.NewLayout ("mynewpanel", true, null);
            panel.SetCaption("TheMainPanel");
                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)
            basicNote.BringToFrontAndShow();
            NoteDataXML_RichText textNote = new NoteDataXML_RichText();
            textNote.Caption = "howdy";
            //	((FAKE_LayoutPanel)panelA.GetPanelsLayout()).SetCaption("boohowcrashmenow");
            panelA.AddNote (textNote);
            textNote.CreateParent(panelA.myLayoutPanel());

            textNote.BringToFrontAndShow();
            textNote.TestEnter ();
            panelA.GetPanelsLayout().TestForceError();
            // the current layout can never be set to a subplayout
            Assert.AreNotEqual(panelA.GetPanelsLayout(), LayoutDetails.Instance.CurrentLayout, "the current layout can never be set to a subplayout");
                panel.SaveLayout ();
                Assert.AreEqual (2, panelA.CountNotes (), "Panel A holds TWo 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 (7, panel.CountNotes (), "Total notes SHOULD BE 7 :  (1 + 1 note on it)panel A + (1+1textnote)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");

                _w.output ("ENDCOUNT");

                // now we move basicNote out
                // WITOUT calling save  ****
                // it should still ahve saved

            panelA.myLayoutPanel ().MoveNote(basicNote.GuidForNote, "up");
            Assert.AreEqual (1, panelA.CountNotes (), "Panel A holds 1 note -- because we moved one out");
            Assert.AreEqual (7, panel.CountNotes (), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");
            panel = null;
            panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            panel.LoadLayout("mynewpanel", false, null);
            //Assert.AreEqual (0, panelA.CountNotes (), "Panel A holds one note");
            Assert.AreEqual (7, panel.CountNotes (), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");
        }
        public void IdentifySubpanels()
        {
            // get the link into a subpanel and make the counts are as expected
            _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 panelA = new FAKE_NoteDataXML_Panel ();
            panelA.Caption = "PanelA";
            panelA.GuidForNote = "panela";
            panel.AddNote (panelA);
            panelA.CreateParent (panel);

            panel.SaveLayout ();
            System.Collections.Generic.List<string> linkstome = MasterOfLayouts.ReciprocalLinks ("mynewpanel");
            Assert.AreEqual (0, linkstome.Count);

            NoteDataXML_LinkNote link = new NoteDataXML_LinkNote ();

            panelA.AddNote (link);
            link.CreateParent (panelA.GetPanelsLayout ());
            link.SetLink ("mynewpanel.thisguid1");
            panel.SaveLayout ();

            linkstome = MasterOfLayouts.ReciprocalLinks ("mynewpanel");

            Assert.AreEqual (true,MasterOfLayouts.ExistsByGUID("panela"),"1");
            Assert.AreEqual (true,MasterOfLayouts.IsSubpanel("panela"),"2");
            Assert.AreEqual (true,MasterOfLayouts.ExistsByGUID("mynewpanel"),"3");
            Assert.AreEqual (false,MasterOfLayouts.IsSubpanel("mynewpanel"),"4");

            System.Collections.Generic.List<string> children = MasterOfLayouts.GetListOfChildren("mynewpanel");
            Assert.AreEqual(1, children.Count);

            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel ();
            panelB.Caption = "PanelB";
            panelB.GuidForNote = "panelB";
            panel.AddNote (panelB);
            panelB.CreateParent (panel);

            panel.SaveLayout ();

            children = MasterOfLayouts.GetListOfChildren("mynewpanel");
            Assert.AreEqual(2, children.Count);
            Assert.AreEqual ("panela", children[0]);
            Assert.AreEqual ("panelB", children[1]);
        }
        public void TestExistsByName()
        {
            //_SetupForLayoutPanelTests ();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout("mynewpanel3", true, null);
            panel.SetName("frank");
            NoteDataXML basicNote = new NoteDataXML();
            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption = "note1";

            panel.AddNote(basicNote);
            basicNote.CreateParent(panel);
            panel.SaveLayout();
            Assert.False (MasterOfLayouts.ExistsByName("dasdfasd"));
            Assert.True (MasterOfLayouts.ExistsByName("frank"));
        }
 public void TestToString()
 {
     NoteDataXML note = new NoteDataXML();
     note.Caption = "boo";
     Assert.AreNotEqual(0, note.ToString().Length);
 }
        public void AnEmptyPanelStillHasAParent()
        {
            lg.Instance.OutputToConstoleToo = true;
            Form form = new Form();
            string ThisLayoutGUID = "mynewpanelXA";
            // create a layout
            _TestSingleTon.Instance._SetupForLayoutPanelTests ();
            //	_SetupForLayoutPanelTests ();

            FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            form.Controls.Add (panel);
            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout (ThisLayoutGUID, true, null);

            NoteDataXML basicNote = new NoteDataXML ();
            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption = "note1";

            panel.AddNote (basicNote);
            //basicNote.CreateParent (panel);
            panel.SaveLayout ();

            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel ();
            panelA.Caption = "PanelA";
            panelA.GuidForNote = "panela";
            panel.AddNote (panelA);
            panelA.CreateParent (panel);

            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel ();
            panelB.Caption = "PanelBBBBB";
            panelB.GuidForNote = "panelBB";
            panelA.AddNote (panelB);
            panelB.CreateParent (panelA.GetPanelsLayout());

            FAKE_NoteDataXML_Text textNote = new FAKE_NoteDataXML_Text ();

            panelA.AddNote (textNote);
            textNote.CreateParent (panelA.GetPanelsLayout ());
            textNote.Caption = "My text";
            textNote.GetRichTextBox ().Text = "Hello there." +Environment.NewLine +"I am still here, are you?" + Environment.NewLine+"Yep!";
            panel.SaveLayout ();
            Assert.AreEqual (6, panel.CountNotes ());
            _w.output(panelB.GetPanelsLayout().ParentGUID);

            // get parent GUID directlyf rom database
            FAKE_LayoutPanel SubPanelB = new FAKE_LayoutPanel ("panelBB", true);
            form.Controls.Add (SubPanelB);
            SubPanelB.LoadLayout("panelBB", true, null);

            Assert.AreNotEqual(Constants.BLANK, SubPanelB.GetLayoutDatabase().ParentGuid);
        }
        /// <summary>
        /// Saves to the XML file.
        /// 
        /// Notice the GUID is NOT allowed to be passed in. It is stored in the document when Loaded or Created
        /// </summary>
        /// <returns>
        /// The to.
        /// </returns>
        public bool SaveTo()
        {
            //
            // MAJOR
            // - Testing for Read Only.
            // - Ran into an issue where I was backing up files and got an Exception inside of YOM because I hit SAVE
            //   at the same time.
            // - Here we test if the file is readonly

            System.IO.FileInfo fInfo = new System.IO.FileInfo(LayoutDetails.Instance.YOM_DATABASE);
            if (fInfo == null || fInfo.IsReadOnly) {
                NewMessage.Show ("The database is in read only mode right now. Wait a second and try again.");
                return false;
            }
            DateEdited = DateTime.Now;

            bool saveworked= false;
            if (false == AmSaving) {
                AmSaving = true;

                if (LayoutGUID == CoreUtilities.Constants.BLANK) {
                    throw new Exception ("GUID need to be set before calling SaveTo");
                }
                string XMLAsString = CoreUtilities.Constants.BLANK;
                string LinkTableString = CoreUtilities.Constants.BLANK;
                BaseDatabase MyDatabase = CreateDatabase ();

                if (MyDatabase == null) {
                    throw new Exception ("Unable to create database in SaveTo");
                }

                // I did major changes and for some reason
                // when I store a ParentGUID in LayoutPanel (to avoid ahving no ParentGUID) it is the wrong GUID??
                if (IsSubPanel == true && ParentGuid == Constants.BLANK)
                {
                    if (dataForThisLayout.Count > 0)
                    {
                        // any note cointains a reference to layout

                        //NewMessage.Show (dataForThisLayout[0].Caption +  " I am a child. My parent is " + dataForThisLayout[0].GetAbsoluteParent());
                        ParentGuid = dataForThisLayout[0].GetAbsoluteParent();
                    }

                }

                // we are storing a LIST of NoteDataXML objects
                //	CoreUtilities.General.Serialize(dataForThisLayout, CreateFileName());
                try {

                    if (dataForThisLayout != null  && dataForThisLayout.Count > 0)
                    {
            //						try causes an Exception LATER ON!
            //						{
            //
            //						dataForThisLayout.Sort ();
            //						}
            //						catch (Exception ex)
            //						{
            //							NewMessage.Show (ex.ToString());
            //						}

                    // the -1 is because we never save the LInkTable out. So there is always one note we skip
                        int SKIPLINKTABLE = 1;

                        // skip linktables if we are a child
                        if (IsSubPanel == true)
                        {
                            //NewMessage.Show ("subpanel!");
                            // a child won't have a linktable so we don't have to account for it
                            SKIPLINKTABLE = 0;
                        }
                        else
                        {
                            if (MyLinkTableNote == null) NewMessage.Show ("Saving with no valid MyLinkTableNote " + LayoutGUID);
                            NoteDataXML note = (NoteDataXML)dataForThisLayout.Find (NoteDataInterface=>NoteDataInterface.GuidForNote == LinkTable.STICKY_TABLE );
                            if (note == null) NewMessage.Show ("Saving with no Link Table found in list of notes " + LayoutGUID);
                        }
                        int NumberOfNotesToCopy = dataForThisLayout.Count-CountSystemNotes()-SKIPLINKTABLE;
                        lg.Instance.Line("SaveTo", ProblemType.MESSAGE, String.Format ("Number of Notes to copy = {0} On GUID'{1}' Name'{2}' IsSubpanel '{3}' Starting Count {4} System Notes {5} SkipLinkTable {6}",
                                                                                       NumberOfNotesToCopy, this.LayoutGUID, this.Name, IsSubPanel, dataForThisLayout.Count, CountSystemNotes(), SKIPLINKTABLE));
                        NoteDataXML[] ListAsDataObjectsOfType = new NoteDataXML[NumberOfNotesToCopy];

                //	dataForThisLayout.CopyTo (ListAsDataObjectsOfType);

                        // the sort is important because it forces a LINKTABLE to the top of the stack. If it is not saved out there,
                        // then on load anytning needing it will create a new linktable

                        int position = 0;
                    // Remove System Notes (these should never end up in save data

                        // we need to iterate through the ENTIRE original list.
                        for (int i = 0; i < dataForThisLayout.Count  ; i++)					{

                            // we skip System Notes and the LinkTable
                            if (dataForThisLayout[i].GetType () != typeof(NoteDataXML_SystemOnly) && dataForThisLayout[i].GuidForNote != LinkTable.STICKY_TABLE)
                        {

            //								if (ListAsDataObjectsOfType[i].GuidForNote == CoreUtilities.Links.LinkTable.STICKY_TABLE)
            //								{
            //									// tables get moved to front of list, so LinkTable
            //									// is also loaded before other objects
            //									dataForThisLayout.Insert (0, ListAsDataObjectsOfType[i]);
            //								}
            //								else
                                try
                                {
                                    lg.Instance.Line("LayoutDatabase->SaveTo", ProblemType.MESSAGE, String.Format ("Trying to set Note with Caption {0}", dataForThisLayout[i].Caption));
                                // We add SkipLinkTable because the first position of dataForThisLayout is always the LINK TABLE which we want to skip
                                ListAsDataObjectsOfType[position] = (NoteDataXML)dataForThisLayout[i];
                                }
                                catch (Exception ex)
                                {
                                    NewMessage.Show ("Setting Position = " +position.ToString() + ex.ToString());
                                }
                                lg.Instance.Line("LayoutDatabase->SaveTo", ProblemType.MESSAGE, String.Format ("writing position {0} with caption {1}", position, dataForThisLayout[i].Caption));
                                position = position +1;
                        }
                            else
                            {
                                lg.Instance.Line("LayoutDatabase->SaveTo", ProblemType.MESSAGE, String.Format ("SKIPPED writing position {0} with caption {1} and GUID{2} and Type {3}",
                                                                                                               position, dataForThisLayout[i].Caption, dataForThisLayout[i].GuidForNote, dataForThisLayout[i].GetType ().ToString()));
                            }

                        }

                    // doing some data tracking to try to detect save failures later
                    if (ListAsDataObjectsOfType.Length < debug_ObjectCount) {
                        lg.Instance.Line ("LayoutDatabase.SaveTo", ProblemType.WARNING, String.Format ("Less objects being saved than loaded. Loaded {0}. Saved {0}.",
                                                                                                  ListAsDataObjectsOfType.Length, debug_ObjectCount));
                    }

                    foreach (NoteDataInterface note in ListAsDataObjectsOfType) {
                        // saves the actual UI elements
                            if (note == null)
                            {
                                NewMessage.Show (String.Format ("LayoutDatabase->SNull note on {0}", this.Name));
                            }
                            else
                            {
                            try
                            {

                        lg.Instance.Line("SaveTo", ProblemType.MESSAGE, String.Format ("Trying to save note of type {0} with Guid {1}", note.GetType().ToString (), note.GuidForNote));
                        note.Save ();
                            }
                            catch (Exception ex)
                            {
                                NewMessage.Show (ex.ToString ());
                            }
                            }

                        }

                    debug_ObjectCount = ListAsDataObjectsOfType.Length;

                        System.Xml.Serialization.XmlSerializer x3 = null;

                    /*This worked but would need to iterate and get a list of all potential types present, not just the first, else it will fail withmixed types
                System.Xml.Serialization.XmlSerializer x4 =
                    new System.Xml.Serialization.XmlSerializer (ListAsDataObjectsOfType.GetType(),
                                                                new Type[1] {ListAsDataObjectsOfType[0].GetType()});
            */

                        // FIRST serialize the LInkTable, so it is stored in a seperate column
                        System.IO.StringWriter sw = null;
                        // skip linktables if we are a child
                        if (IsSubPanel == false)
                        {
                            sw = new System.IO.StringWriter ();
                            //sw.Encoding = "";
                            x3 = new System.Xml.Serialization.XmlSerializer (typeof(NoteDataXML_Table));
                            x3.Serialize (sw, MyLinkTableNote);
                            x3 = null;
                            //x3.Serialize (sw, ListAsDataObjectsOfType,ns, "utf-8");
                            LinkTableString = sw.ToString ();
                            sw.Close ();
                            // we don't have to remove the note from the list because it was not included in the list of notes to save
                        }

                        // Now serialize the list of notes
                    x3 =	new System.Xml.Serialization.XmlSerializer (typeof(NoteDataXML[]),
                                                                    LayoutDetails.Instance.ListOfTypesToStoreInXML ());
                     sw = new System.IO.StringWriter ();
                    //sw.Encoding = "";
                    x3.Serialize (sw, ListAsDataObjectsOfType);
                    //x3.Serialize (sw, ListAsDataObjectsOfType,ns, "utf-8");
                    XMLAsString = sw.ToString ();
                    lg.Instance.Line("LayoutDatabase->SaveTo", ProblemType.MESSAGE, String.Format ("Guid = '{0}'", LayoutGUID));
            //						lg.Instance.Line("LayoutDatabase->SaveTo", ProblemType.MESSAGE, String.Format ("Xml = {0}", XMLAsString));

                sw.Close ();

                    }

                    // here is where we need to test whether the Data exists

                    if (MyDatabase.Exists (dbConstants.table_name, dbConstants.GUID, LayoutGUID) == false) {
                        lg.Instance.Line ("LayoutDatabase.SaveTo", ProblemType.MESSAGE, "We have new data. Adding it.GUID=" + LayoutGUID);
                        // IF NOT, Insert
                        MyDatabase.InsertData (dbConstants.table_name,
                                      dbConstants.Columns,
                                      new object[dbConstants.ColumnCount]
                                      {DBNull.Value,LayoutGUID, XMLAsString, Status,Name,ShowTabs,
                            IsSubPanel, MaximizeTabs, Stars, Hits, DateCreated,DateEdited, Notebook, Section, Subtype, Source, Words, Keywords, LinkTableString,
                        BackgroundColor.ToArgb(), Blurb, ParentGuid});

                    } else {

                        lg.Instance.Line ("LayoutDatabase.SaveTo", ProblemType.MESSAGE, "We are UPDATING existing Row." + LayoutGUID);
                        MyDatabase.UpdateSpecificColumnData (dbConstants.table_name,
                                                        new string[dbConstants.ColumnCount - 1]
                                                             {dbConstants.GUID, dbConstants.XML, dbConstants.STATUS,
                        dbConstants.NAME, dbConstants.SHOWTABS, dbConstants.SUBPANEL, dbConstants.MAXIMIZETABS,
                            dbConstants.STARS,dbConstants.HITS,dbConstants.DATECREATED,
                        dbConstants.DATEEDITED, dbConstants.NOTEBOOK, dbConstants.SECTION,
                        dbConstants.TYPE, dbConstants.SOURCE, dbConstants.WORDS, dbConstants.KEYWORDS, dbConstants.LINKTABLE,
                            dbConstants.BACKGROUNDCOLOR, dbConstants.BLURB, dbConstants.PARENT_GUID},
                                                    new object[dbConstants.ColumnCount - 1]
                                                    {
                        LayoutGUID as string,
                        XMLAsString as string,
                        Status as string
                    ,Name,
                        ShowTabs,
                        IsSubPanel,
                            MaximizeTabs,
                        Stars,
                        Hits,
                        DateCreated,
                        DateEdited,
                        Notebook,
                        Section,
                        Subtype,
                        Source,
                        Words,
                        Keywords,
                        LinkTableString,
                        BackgroundColor.ToArgb(),
                        Blurb,
                        ParentGuid
                        },
                dbConstants.GUID, LayoutGUID);
                    }

                } catch (Exception ex) {
                    AmSaving = false;
                    lg.Instance.Line ("LayoutDatabase.SaveTo", ProblemType.EXCEPTION,"save exception happened " + ex.ToString());
                    //throw new Exception (String.Format ("Must call CreateParent before calling Save or Update!! Exception: {0}", ex.ToString ()));
                    NewMessage.Show ((String.Format ("Must call CreateParent before calling Save or Update!! Exception: {0}", ex.ToString ())));
                    //lg.Instance.Line("LayoutDatabase.SaveTo", ProblemType.EXCEPTION, ex.ToString());
                }
                AmSaving = false;
                saveworked = true;

                // We removed the LinkTable to save the dataout, now we must add it again.
                //AddToStart(MyLinkTableNote); WE do not have to do this because we only remove the note from the list to be saved, not the true list

            } else {
                // we were already saving information when this was called again
                saveworked = false;
            }
            return saveworked;
        }
        public void BuildReciprocalLinks()
        {
            _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();

            // #2

            panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            panel.NewLayout("mynewpanel2", true, null);
            basicNote = new NoteDataXML();
            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption = "note1";

            panel.AddNote(basicNote);
            basicNote.CreateParent(panel);
            panel.SaveLayout();

            NoteDataXML_LinkNote note = new NoteDataXML_LinkNote();

            panel.AddNote (note);
            note.CreateParent(panel);
            note.SetLink("mynewpanel.thisguid1");
            panel.SaveLayout();

            System.Collections.Generic.List<string> linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel2");
            Assert.AreEqual(0, linkstome.Count);
            linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel");
            Assert.AreEqual(1, linkstome.Count);
        }
        public void CountSpecificSubType()
        {
            //-- do unit tests counting store 6 textboxes and know this (countbytype)

            System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            int count = 25;
            //	FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);

            // jan152013 - tweak to allow this to work with new system without rewriting all the tstings in LayoutDatabasetest
            LayoutDatabase layout = layoutPanel.GetLayoutDatabase();

            form.Controls.Add (layoutPanel);
            form.Show ();

            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();
                layout.Add (note);
                note.CreateParent(layoutPanel);
            }
            _w.output (String.Format ("{0} Notes in Layout before save", layout.GetNotes ().Count.ToString ()));

            for (int i = 0; i < 6; i++) {
                note = new NoteDataXML_RichText ();

                note.Caption = "richText";
                layout.Add (note);
                note.CreateParent(layoutPanel);
            }

            layout.SaveTo();

            //	_w.output(String.Format ("{0} Objects Saved", layout.ObjectsSaved().ToString()));
            layout = new FakeLayoutDatabase ("testguid");

            layout.LoadFrom(layoutPanel);

            // now count RichText notes
            int count2 = 0;
            foreach (NoteDataInterface _note in layout.GetNotes ())
            {
                if (_note.GetType() == typeof(NoteDataXML_RichText))
                    {
                    count2++;
                }

                }

            _w.output(String.Format ("{0} Objects Loaded", layout.GetNotes().Count));

            // added linktable
            Assert.AreEqual (7, count2);
        }
        public void CountSizeOfCombinedTableAfterReciprocalLinks()
        {
            _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();

            // #2

            panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            panel.NewLayout("mynewpanel2", true, null);
            basicNote = new NoteDataXML();
            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption = "note1";

            panel.AddNote(basicNote);
            basicNote.CreateParent(panel);
            panel.SaveLayout();

            NoteDataXML_LinkNote note = new NoteDataXML_LinkNote();

            panel.AddNote (note);
            note.CreateParent(panel);
            note.SetLink("mynewpanel.thisguid1");
            panel.SaveLayout();

            // #3

            panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            panel.NewLayout("mynewpanel3", true, null);
            basicNote = new NoteDataXML();
            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption = "note1";

            panel.AddNote(basicNote);
            basicNote.CreateParent(panel);
            panel.SaveLayout();

            note = new NoteDataXML_LinkNote();

            panel.AddNote (note);
            note.CreateParent(panel);
            note.SetLink("mynewpanel2.thisguid1");
            panel.SaveLayout();

            Assert.AreEqual(2, Fake_MasterOfLayouts.GetRowCountOfCombinedLinkTableAfterCallToReciprocalLinks());
        }
        public void LayoutShouldNotExist()
        {
            _setupforlayoutests ();
            int count = 25;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);
            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }
            //	layout.SaveTo(); no save, so note should not exist

            Assert.False (MasterOfLayouts.ExistsByGUID("testguid"));
        }
        public void DeleteTests()
        {
            // nest several panels
                //_SetupForLayoutPanelTests ();
            _TestSingleTon.Instance._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 panelA = new FAKE_NoteDataXML_Panel ();
            panelA.Caption = "PanelA";
            panelA.GuidForNote = "panela";
            panel.AddNote (panelA);
            panelA.CreateParent (panel);

            FAKE_NoteDataXML_Text textNote = new FAKE_NoteDataXML_Text ();

            panelA.AddNote (textNote);
            textNote.CreateParent (panelA.GetPanelsLayout ());
            textNote.Caption = "My text";
            textNote.GetRichTextBox ().Text = "Hello there.";
            panel.SaveLayout ();
            Assert.AreEqual (2, MasterOfLayouts.Count (true));
            Assert.True (MasterOfLayouts.ExistsByGUID("mynewpanel"));
            MasterOfLayouts.DeleteLayout("mynewpanel");
            Assert.False (MasterOfLayouts.ExistsByGUID("mynewpanel"));
            Assert.AreEqual (0, MasterOfLayouts.Count (true));
        }
        public void SaveAndLoadTest_Works()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            int linktable = 1;
            int extranodeadded = 1;
            int count = 25;
            ///FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);
            //layout.LoadFrom(layoutPanel);
            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {
                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote (note);
            }

            layoutPanel.SaveLayout();
            _w.output("save worked");
            //layout = new FakeLayoutDatabase ("testguid");
            layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            layoutPanel.LoadLayout("testguid", false, null);
            //layout.LoadFrom(layoutPanel);

            //	_w.output (layout.Backup ());
            //_w.output(layout.GetNotes().Count.ToString());
            Assert.AreEqual(count+linktable +extranodeadded, layoutPanel.GetAllNotes().Count);
        }
        public void ExportImport()
        {
            lg.Instance.OutputToConstoleToo = true;
            Form form = new Form();
            string ThisLayoutGUID = "mynewpanelXA";
            // create a layout
            _TestSingleTon.Instance._SetupForLayoutPanelTests ();
            //	_SetupForLayoutPanelTests ();

            FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            form.Controls.Add (panel);
            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout (ThisLayoutGUID, true, null);

            NoteDataXML basicNote = new NoteDataXML ();
            basicNote.GuidForNote = "thisguid1";
            basicNote.Caption = "note1";

            panel.AddNote (basicNote);
            //basicNote.CreateParent (panel);
            panel.SaveLayout ();

            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel ();
            panelA.Caption = "PanelA";
            panelA.GuidForNote = "panela";
            panel.AddNote (panelA);
            panelA.CreateParent (panel);

            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel ();
            panelB.Caption = "PanelBBBBB2";
            panelB.GuidForNote = "panelBB";

            panelA.AddNote (panelB);
            panelB.CreateParent (panelA.GetPanelsLayout());
            FAKE_NoteDataXML_Text textNoteA = new FAKE_NoteDataXML_Text ();

            panelB.AddNote (textNoteA);
            textNoteA.GuidForNote = "My Text Note For the B Panel";
            textNoteA.CreateParent (panelB.GetPanelsLayout ());
            textNoteA.Caption = "My text B";

            FAKE_NoteDataXML_Text textNote = new FAKE_NoteDataXML_Text ();

            panelA.AddNote (textNote);
            textNote.GuidForNote = "Text Note For Panel A";
            textNote.CreateParent (panelA.GetPanelsLayout ());
            textNote.Caption = "My text A";
            textNote.GetRichTextBox ().Text = "Hello there." +Environment.NewLine +"I am still here, are you?" + Environment.NewLine+"Yep!";
            panel.SaveLayout ();
            Assert.AreEqual (7, panel.CountNotes (), "Count1");

            // Note count: Default Note + BasicNote+ PanelA + LinkTable + MyText  + PanbelB + My Text B  =7

            //test existence
            Assert.True (MasterOfLayouts.ExistsByGUID (ThisLayoutGUID));
            // counting our subpanel we have 2
            Assert.AreEqual (3, MasterOfLayouts.Count (true));
            // NOT counting our subpanel we have 1
            Assert.AreEqual (1, MasterOfLayouts.Count (false));

            // export
            string file = Path.Combine (Environment.CurrentDirectory, "exportest.txt");
            if (File.Exists (file)) {
                File.Delete (file);
            }
            string subfile = file+"__child0.txt";
            if (File.Exists (subfile)) {
                File.Delete (subfile);
            }
            string subfile2 = file+"__child1.txt";
            if (File.Exists (subfile2)) {
                File.Delete (subfile2);
            }

            Assert.False (File.Exists (file), file + " does not exist");

            MasterOfLayouts.ExportLayout(ThisLayoutGUID, file);
            // test exportfile existence 	// count 2 files exported
            Assert.True (File.Exists(file),"main file exists");
            Assert.True (File.Exists(subfile),"subfile exists");
            Assert.True (File.Exists(subfile2),"subfile2 exists");

            // delete original note
            MasterOfLayouts.DeleteLayout(ThisLayoutGUID);

            // test existence
            Assert.False (MasterOfLayouts.ExistsByGUID (ThisLayoutGUID));
            // counting our subpanel we have ZERO
            Assert.AreEqual (0, MasterOfLayouts.Count (true) ,"Nothing should be left");
            // Import as New (but won't be duplicate because old is gone)

            int errorcode = MasterOfLayouts.ImportLayout(file);
            Console.WriteLine(errorcode);
            Assert.True (MasterOfLayouts.ExistsByGUID (ThisLayoutGUID));
            // test existence

            // confirm all notes laoded into layout
            panel = null;
            panel = new FAKE_LayoutPanel(ThisLayoutGUID, false);
            form.Controls.Add (panel);
            panel.LoadLayout (ThisLayoutGUID,false, null);
            //	panel.SaveLayout();

            Assert.AreEqual (7, panel.CountNotes (), "Count2");
            Assert.AreEqual (1, MasterOfLayouts.Count (false));
            Assert.AreEqual (3, MasterOfLayouts.Count (true));

            // Import as Overwrite
            if (File.Exists (file)) {
                File.Delete (file);
            }
            subfile = file+"__child0.txt";
            if (File.Exists (subfile)) {
                File.Delete (subfile);
            }
            Assert.True (MasterOfLayouts.ExistsByGUID (ThisLayoutGUID));
            MasterOfLayouts.ExportLayout(ThisLayoutGUID, file);

            panel = null;
            errorcode = MasterOfLayouts.ImportLayout(file);
            Assert.AreEqual (0, errorcode);
            // test existences
            panel = new FAKE_LayoutPanel(ThisLayoutGUID, false);
            form.Controls.Add (panel);
            panel.LoadLayout (ThisLayoutGUID,false, null);

            Assert.AreEqual (7, panel.CountNotes ());
            Assert.AreEqual (1, MasterOfLayouts.Count (false));
            Assert.AreEqual (3, MasterOfLayouts.Count (true));

            lg.Instance.OutputToConstoleToo = false;
        }
 public void TestInvalidAddToStart()
 {
     _TestSingleTon.Instance._SetupForLayoutPanelTests();
     FakeLayoutDatabase layout = new FakeLayoutDatabase ("DeleteMe");
     //LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
     //layoutPanel.NewLayout("testguid", true, null);
     layout.SaveTo ();
     NoteDataXML test = new NoteDataXML();
     test.GuidForNote = "boo";
     layout.AddToStart(test);
 }
        public void AddAndThenEditLinks()
        {
            // add a couple links, take count
            // then edit one of the early links a few times
            // get the link into a subpanel and make the counts are as expected
            _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();

            // in this test we don't use the subpanel but just have it here for fun
            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel ();
            panelA.Caption = "PanelA";
            panel.AddNote(panelA);
            panelA.CreateParent(panel);

            panel.SaveLayout();
            System.Collections.Generic.List<string> linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel");
            Assert.AreEqual(0, linkstome.Count);

            NoteDataXML_LinkNote link = new NoteDataXML_LinkNote();

            panel.AddNote (link);
            link.CreateParent(panel);
            link.SetLink("mynewpanel.thisguid1");
            panel.SaveLayout();

            linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel");
            Assert.AreEqual(1, linkstome.Count);

            // now edit the existing link
            link.SetLink("mynewpanel.thisguid2");
            panel.SaveLayout();
            Assert.AreEqual(1, linkstome.Count);
            // the counts should remain the same
        }
 public void TryToAddANullNote()
 {
     // no failure should happen. Simply should not be allowed to to do this.
     FakeLayoutDatabase layout = new FakeLayoutDatabase("testguid");
     NoteDataXML note = new NoteDataXML();
     note.Caption = "boo";
     layout.Add(note);
     // we should have one note in the list. Now add null
     layout.Add (null);
     Assert.AreEqual(1, layout.GetNotes().Count);
 }
        public void CallingSetFieldsOnAParent()
        {
            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);
            panel.SetParentFields("","","","");
        }