Пример #1
0
        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);
        }