public void TestDeleteNote()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            // add a note with specific label
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            layoutPanel.NewLayout("testguid", true, null);
            NoteDataXML_RichText note    = new NoteDataXML_RichText();
            string            guid2find  = "";
            NoteDataInterface mynotetogo = null;

            for (int i = 0; i < 1; i++)
            {
                note.CreateParent(layoutPanel);
                note.Caption = "boo" + i.ToString();
                note.UpdateLocation();
                guid2find = note.GuidForNote;
                layoutPanel.AddNote(note);
                mynotetogo = note;
            }
            //	layout.SaveTo();
            layoutPanel.SaveLayout();
            _w.output(guid2find);
            Assert.True(layoutPanel.GetLayoutDatabase().IsNoteExistsInLayout(guid2find));
            _w.output("here");
            // then delete it

            layoutPanel.GetLayoutDatabase().RemoveNote(mynotetogo);
            Assert.False(layoutPanel.GetLayoutDatabase().IsNoteExistsInLayout(guid2find));
        }
Пример #2
0
        public void ImportListTest_UnequalColumns()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            Form             form  = new Form();
            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);

            // needed else DataGrid does not initialize

            form.Show();
            form.Visible = false;

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout("mynewpanel", true, null);
            NoteDataXML_Table test = new NoteDataXML_Table(425, 380);

            test.GuidForNote = "thisguid1";
            test.Caption     = "note1";
            panel.SaveLayout();

            string[] newData = new string[3] {
                "1,col2,col3", "2,col2,col3", "3,col2,col3"
            };

            TableWrapper.ImportList(newData, (DataTable)test.dataSource);
            panel.SaveLayout();
            List <string> values = test.GetValuesForColumn(1, "*");

            Assert.AreEqual(3, values.Count);
            Assert.AreEqual("1,col2,col3", values[0]);
            form.Dispose();
        }
Пример #3
0
        public void TestReplaceWorks()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();


            System.Windows.Forms.Form form = new System.Windows.Forms.Form();



            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);

            // needed else DataGrid does not initialize

            form.Show();
            //form.Visible = false;

            //NOTE: For now remember that htis ADDS 1 Extra notes
            string panelname = System.Guid.NewGuid().ToString();

            panel.NewLayout(panelname, true, null);
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel");


            FAKE_NoteDataXML_Text fakeTextNote = new FAKE_NoteDataXML_Text();

            fakeTextNote.Caption = "Fake Text Note";
            panel.AddNote(fakeTextNote);
            fakeTextNote.CreateParent(panel);


            // Won't actually add things properly because I need to override the findbar
            FAKE_FindBar findBar = new FAKE_FindBar();

            form.Controls.Add(findBar);
            //RichTextExtended fakeText = new RichTextExtended();
            //form.Controls.Add (fakeText);


            LayoutDetails.Instance.CurrentLayout = panel;
            LayoutDetails.Instance.CurrentLayout.CurrentTextNote = fakeTextNote;
            panel.SetFindBar(findBar);
            findBar.SupressMode = true;
            //!= null && LayoutDetails.Instance.CurrentLayout.CurrentTextNote != null
            fakeTextNote.GetRichTextBox().Text = "We have a dog. His name is Jake." + Environment.NewLine + "We love him a lot. And that cat. He is a nice dog. We all love dogs. Dogs are neat.";
            findBar.SetLastRichText(fakeTextNote.GetRichTextBox());

            findBar.DoFind("dog", false, fakeTextNote.GetRichTextBox(), 0);

            //need to rewrite 'find/repalce' to make accessible better to test? It crashes.

            Assert.AreEqual(4, findBar.PositionsFOUND(), "Found 4 dogs");
            findBar.Replace_Text("dog", "cat");
            findBar.DoFind("dog", false, fakeTextNote.GetRichTextBox(), 0);
            Assert.AreEqual(0, findBar.PositionsFOUND(), "Found 0 dogs");
            findBar.DoFind("cat", false, fakeTextNote.GetRichTextBox(), 0);
            Assert.AreEqual(5, findBar.PositionsFOUND(), "Found 5 cats. 4 replacements + 1 original");
        }
        public void TestSavingRTFTextWorks()
        {
            Type TypeToTest = typeof(NoteDataXML_RichText);

            // 1. write data to notes
            _setupforlayoutests();
            int count = 15;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            layoutPanel.NewLayout("testguid", true, null);
            NoteDataInterface note = null;

            for (int i = 0; i < count; i++)
            {
                note = (NoteDataInterface)Activator.CreateInstance(TypeToTest);                //new NoteDataXML ();

                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote(note);
                note.CreateParent(layoutPanel);
            }


            note         = (NoteDataInterface)Activator.CreateInstance(TypeToTest);
            note.Caption = "snake";
            string guid       = note.GuidForNote;
            string teststring = "\nthe test is this ";


            note.Data1 = (@"{\rtf1\ansi\ansicpg1252\deff0\deflang4105{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}" +
                          @"\viewkind4\uc1\pard\f0\fs17\par the test is this }");


            //	note.Data1=String.Format (@"{\rtf1\ansi\ansicpg1252\deff0\deflang4105{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs17\par {0} \par}", teststring);

            //"This is the story of the bird.";
            note.CreateParent(layoutPanel);
            _w.output("new guid" + guid);

            layoutPanel.AddNote(note);
            //layout.SaveTo ();
            layoutPanel.SaveLayout();
            //layout = new FakeLayoutDatabase ("testguid");
            layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            layoutPanel.LoadLayout("testguid", false, null);
            //layout.LoadFrom(layoutPanel);

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

            NoteDataInterface result = layoutPanel.GetLayoutDatabase().GetNoteByGUID(guid);
            string            astest = ((NoteDataXML_RichText)result).GetAsText();

            _w.output(result.Data1);
            _w.output(astest);
            Assert.AreEqual(teststring, astest);
        }
Пример #5
0
        public void FindFileSimple()
        {
            //TestingSingleton.GetImageFile
            // Tests to see if it can find the file
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataPicture), "pictures");



            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(

            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

            panelA.Caption = "PanelA";

            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel();

            panelB.Caption = "PanelB";


            panel.AddNote(panelA);
            panelA.CreateParent(panel);

            // b is inside A
            panelA.AddNote(panelB);
            panelB.CreateParent(panelA.GetPanelsLayout());


            FAKE_NoteDataPicture picture = new FAKE_NoteDataPicture();

            panelB.AddNote(picture);
            picture.CreateParent(panelB.GetPanelsLayout());
            Assert.IsNull(picture.GetPictureBox().Image);

            Assert.True(System.IO.File.Exists(_TestSingleTon.ValidImageFile));
            picture._SetImage(_TestSingleTon.ValidImageFile);
            Assert.IsNotNull(picture.GetPictureBox().Image);
        }
Пример #6
0
        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());
        }
Пример #7
0
        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 BasicInvokeTest()
        {
            SetupForSubmissionTest();



            System.Windows.Forms.Form form  = new System.Windows.Forms.Form();
            FAKE_LayoutPanel          panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);
            // needed else DataGrid does not initialize
            form.Show();
            //form.Visible = false;
            _w.output("boom");



            // March 2013 -- notelist relies on having this
            YOM2013.DefaultLayouts.CreateASystemLayout(form, null);
            LayoutDetails.Instance.SystemLayout = new Layout.LayoutPanel(CoreUtilities.Constants.BLANK, true);
            LayoutDetails.Instance.SystemLayout.LoadLayout(LayoutPanel.SYSTEM_LAYOUT, false, null);
            form.Controls.Add(LayoutDetails.Instance.SystemLayout);

            // we need to force a registeration event (may 2013) after I restructued how the
            // default tables are created
            MefAddIns.Addin_Submissions FAKESUBAddIn = new MefAddIns.Addin_Submissions();
            FAKESUBAddIn.RegisterType();


            //NOTE: For now remember that htis ADDS 1 Extra notes
            string panelname = System.Guid.NewGuid().ToString();

            panel.NewLayout(panelname, true, null);
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanelZZ");
            _w.output("herefirst");


            NoteDataXML_Submissions Submissions = new NoteDataXML_Submissions(250, 250);

            Submissions.GuidForNote = "submissions";
            Submissions.Caption     = "Submissions";

            panel.AddNote(Submissions);
            Submissions.CreateParent(panel);
            Submissions.UpdateAfterLoad();

            panel.SaveLayout();
            form.Dispose();
        }
Пример #9
0
        public void CopyToClipboard()
        {
//			Table
//				Roll	Result	NextTable	Modifier	ff	seer	eee
//					z. This is a test. How to do al inefeed,,,length,,,
//					beer.This is the story that never was,e,,,bb,,


            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            Form             form  = new Form();
            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);

            // needed else DataGrid does not initialize

            form.Show();
            form.Visible = false;

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout("mynewpanel", true, null);
            FAKE_NoteDataXML_Table test = new FAKE_NoteDataXML_Table(33, 0009);

            test.GuidForNote = "thisguid1";
            test.Caption     = "note1";
            test.CreateParent(panel);

            test.AddRow(new object[3] {
                "1", "value1", "testA"
            });
            test.AddRow(new object[3] {
                "2", "value2", "testB"
            });
            test.AddRow(new object[3] {
                "3", "value3", "testC"
            });

            panel.SaveLayout();
            test.Copy();



            string result = Clipboard.GetText();

            Assert.AreEqual(91, result.Length);


            form.Dispose();
        }
Пример #10
0
        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 GetListOfStringsInColumn()
        {        // nest several panels
            _SetupForLayoutPanelTests();
            Form             form  = new Form();
            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);

            // needed else DataGrid does not initialize
            form.Visible = false;
            form.Show();

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout("mynewpanel", true, null);
            NoteDataXML_Table test = new NoteDataXML_Table(425, 380);

            test.GuidForNote = "thisguid1";
            test.Caption     = "note1";
            panel.SaveLayout();
            //	test.Columns = new appframe.ColumnDetails[3] {new appframe.ColumnDetails("snakes", 109), new appframe.ColumnDetails("fish", 90), new appframe.ColumnDetails("goobers", 11111)};

            panel.AddNote(test);
            test.CreateParent(panel);
            _w.output("COLUMN " + test.Columns.Length.ToString());
            Assert.AreEqual(4, test.Columns.Length, "before save");

            // saving is deleting the columns?!
            panel.SaveLayout();
            Assert.AreEqual(4, test.Columns.Length, "after save");
            for (int i = 0; i < 4; i++)
            {
                switch (i)
                {
                case 0: Assert.AreEqual("Roll", test.Columns[i].ColumnName); break;

                case 1:  Assert.AreEqual("Result", test.Columns[i].ColumnName); break;

                case 2: Assert.AreEqual("Next Table", test.Columns[i].ColumnName); break;

                case 3:  Assert.AreEqual("Modifier", test.Columns[i].ColumnName); break;
                }
            }


// not sure what we are testin here [The default Columns?]
            // testing notedataxml_table
        }
Пример #12
0
        public void AlLFindBarsAreTheSame()
        {
            // children panels have the same findbar as a parent
            _TestSingleTon.Instance._SetupForLayoutPanelTests();


            System.Windows.Forms.Form form = new System.Windows.Forms.Form();



            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);

            // needed else DataGrid does not initialize

            form.Show();
            //form.Visible = false;

            //NOTE: For now remember that htis ADDS 1 Extra notes
            string panelname = System.Guid.NewGuid().ToString();

            panel.NewLayout(panelname, true, null);
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel");

            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

            panelA.GuidForNote = "panelA";
            panel.AddNote(panelA);



            //panel.AddNote(panelA); Intentionally do not add this because it should bea  failre

            // Won't actually add things properly because I need to override the findbar
            FAKE_FindBar findBar = new FAKE_FindBar();

            form.Controls.Add(findBar);
            RichTextExtended fakeText = new RichTextExtended();

            form.Controls.Add(fakeText);
            fakeText.Text = "We have a dog. His name is Jake." + Environment.NewLine + "We love him a lot. He is a nice dog. We all love dogs.";
            findBar.DoFind("dog", false, fakeText, 0);

            Assert.AreEqual(panelA.GetPanelsLayout().GetFindbar(), panel.GetFindbar());
            //	Assert.AreEqual(panelB.GetPanelsLayout().GetFindbar(), panel.GetFindbar());
        }
Пример #13
0
        public void Quicker_UpdateAfterLoadTest()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();


            System.Windows.Forms.Form form = new System.Windows.Forms.Form();



            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);

            // needed else DataGrid does not initialize

            form.Show();
            //form.Visible = false;
            _w.output("boom");
            // March 2013 -- notelist relies on having this
            YOM2013.DefaultLayouts.CreateASystemLayout(form, null);


            //NOTE: For now remember that htis ADDS 1 Extra notes
            string panelname = System.Guid.NewGuid().ToString();

            panel.NewLayout(panelname, true, null);
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            _w.output("herefirst");

            // ADD 1 of each type
            foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML())
            {
                for (int i = 0; i < 5; i++)
                {
                    NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance(t);
                    panel.AddNote(note);
                    note.CreateParent(panel);

                    note.UpdateAfterLoad();
                }
            }

            panel.SaveLayout();
            form.Dispose();
        }
        //[Ignore]
        public void DeleteTest()
        {
            _setupforlayoutests();
            Assert.False(MasterOfLayouts.ExistsByGUID("DeleteMe"));

            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("DeleteMe");
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            layoutPanel.NewLayout("DeleteMe", true, null);
            //LayoutDatabase layout = layoutPanel.GetLayoutDatabase();
            //layout.SaveTo ();
            layoutPanel.SaveLayout();


            Assert.True(MasterOfLayouts.ExistsByGUID("DeleteMe"));
            MasterOfLayouts.DeleteLayout("DeleteMe");
            Assert.False(MasterOfLayouts.ExistsByGUID("DeleteMe"));
            layoutPanel.Dispose();
        }
Пример #15
0
        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("", "", "", "");
        }
Пример #16
0
        public void AddLinkToSubpanel()
        {
            // 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";
            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(1, linkstome.Count);
        }
Пример #17
0
        public void TestExistsByGUID()
        {
            _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();
            Assert.False(MasterOfLayouts.ExistsByGUID("mynewpanel2"));
            Assert.True(MasterOfLayouts.ExistsByGUID("mynewpanel"));
        }
Пример #18
0
        public void TestPositionNotChangingWhenItShouldNot()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();


            System.Windows.Forms.Form form = new System.Windows.Forms.Form();



            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);

            // needed else DataGrid does not initialize

            form.Show();
            //form.Visible = false;

            //NOTE: For now remember that htis ADDS 1 Extra notes
            string panelname = System.Guid.NewGuid().ToString();

            panel.NewLayout(panelname, true, null);
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel");


            // Won't actually add things properly because I need to override the findbar
            FAKE_FindBar findBar = new FAKE_FindBar();

            form.Controls.Add(findBar);
            RichTextExtended fakeText = new RichTextExtended();

            form.Controls.Add(fakeText);
            fakeText.Text = "We have a dog. His name is Jake." + Environment.NewLine + "We love him a lot. He is a nice dog. We all love dogs.";
            findBar.DoFind("dog", false, fakeText, 0);
            Assert.AreEqual(3, findBar.PositionsFOUND(), "Found 3 dogs");
            findBar.GoToNext();
            findBar.GoToNext();
            Assert.AreEqual(2, findBar.zPosition());
            findBar.DoFindBuildLIstTesty(fakeText.Text);
            Assert.AreEqual(2, findBar.zPosition());
        }
Пример #19
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);
      }
Пример #20
0
        public void InsertRowTest()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            Form             form  = new Form();
            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);

            // needed else DataGrid does not initialize

            form.Show();
            form.Visible = false;

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout("mynewpanel", true, null);
            FAKE_NoteDataXML_Table test = new FAKE_NoteDataXML_Table(33, 0009);

            test.GuidForNote = "thisguid1";
            test.Caption     = "note1";
            test.CreateParent(panel);

            test.AddRow(new object[3] {
                "1", "value1", "testA"
            });
            test.AddRow(new object[3] {
                "2", "value2", "testB"
            });
            test.AddRow(new object[3] {
                "3", "value3", "testC"
            });
            panel.SaveLayout();
            Assert.AreEqual(3, test.RowCount());
            test.GetTablePanel().InsertRow();
            Assert.AreEqual(4, test.RowCount());
            test.GetTablePanel().InsertRow();
            test.GetTablePanel().InsertRow();
            Assert.AreEqual(6, test.RowCount());
            form.Dispose();
        }
Пример #21
0
        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));
        }
Пример #22
0
        public void TestNavigationNote()
        {
            NoteDataXML_RichText texter = new NoteDataXML_RichText(100, 100);

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

            panel.AddNote(texter);

            texter.GetRichTextBox().Text = "";

            NoteNavigation bookMarkView = new NoteNavigation(texter);

            // Test 1: Tests that no crash happens when we don't have a proper markup assigned
            bookMarkView.UpdateListOfBookmarks();


            LayoutDetails.Instance.SetCurrentMarkup(new iMarkupYourOtherMind());
            // Test 2: Same test. No crash still.
            bookMarkView.UpdateListOfBookmarks();
            string TestText = @"7 minutes
Bus crash over cliff in Ecuador
Lost style flash leading to salvation
ddd[[f]]
=Dog=

=Dog 2=
The |whatis|this|
===error===
The |firstssafdfsf|day of the ghoose|
The |linkfdfgdfgdfg|dfdgdfgedfgdnded|";

            texter.GetRichTextBox().Text = TestText;
            // test 3: some text
            bookMarkView.UpdateListOfBookmarks();

            // Main Level Node +1
            // Dog +1
            // Dog 2 + 1
            // <Make Up Node to insert between Dog 2 and Error> +1
            // Error + 1
            // Current Position (Automated Node) + 1
            // = 6
            Assert.AreEqual(6, bookMarkView.NumberOfNodes());

            texter.GetRichTextBox().Text = "[[~scene]]";
            bookMarkView.UpdateListOfBookmarks();
            Assert.AreEqual(3, bookMarkView.NumberOfNodes());
            texter.GetRichTextBox().Text = @"Hello.
=h1=
=h2=
=h3=
=h4=
=h1=
";
            bookMarkView.UpdateListOfBookmarks();
            Assert.AreEqual(7, bookMarkView.NumberOfNodes());
        }
Пример #23
0
        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");
        }
Пример #24
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());
        }
Пример #25
0
        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);
        }
Пример #26
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);
        }
Пример #27
0
        public void TestMovingNotes()
        {
            _w.output("START");
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

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

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout("mynewpanel", true, null);
            NoteDataXML basicNote = new NoteDataXML();

            basicNote.Caption = "note1";

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



            //panel.MoveNote(
            // create four panels A and B at root level. C inside A. D inside C
            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

            panelA.Caption     = "PanelA";
            panelA.GuidForNote = "panela";
            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel();

            panelB.Caption     = "PanelB";
            panelB.GuidForNote = "panelb";
            FAKE_NoteDataXML_Panel panelC = new FAKE_NoteDataXML_Panel();

            panelC.Caption     = "PanelC";
            panelC.GuidForNote = "panelc";


            _w.output("panels made");


            panel.AddNote(panelA);               // 1
            panel.AddNote(panelB);               // 2
            //panelA.CreateParent(panel); should not need to call this when doing LayoutPanel.AddNote because it calls CreateParent insid eof it

            basicNote         = new NoteDataXML();
            basicNote.Caption = "note2";



            panelA.AddNote(basicNote);                                         // Panel A has 1 note
            basicNote.CreateParent(panelA.myLayoutPanel());                    // DO need to call it when adding notes like this (to a subpanel, I think)
            panel.SaveLayout();
            Assert.AreEqual(1, panelA.CountNotes(), "Panel A holds one note"); // So this counts as  + 2

            // so we have (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6
            _w.output("STARTCOUNT");
            Assert.AreEqual(6, panel.CountNotes(), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");

            _w.output("ENDCOUNT");

            //COUNT SHOULD BE: panelA has 1 note
            //COUNT Total should be: Default Note + Note + PanelA + Panel B  + (Note Inside Panel A) = 5

            panelA.AddNote(panelC);          // panelC is now part of Panel 2
            panelC.CreateParent(panelA.myLayoutPanel());
            panel.SaveLayout();              // NEED TO SAVE before conts will be accurated



            //COUNT SHOULD BE: panelA has 2 notes (Panel C + the Note I add)

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

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

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

            FAKE_NoteDataXML_Panel panelD = new FAKE_NoteDataXML_Panel();

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



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

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


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

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

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

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

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

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

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

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

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


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


            lg.Instance.Loudness = Loud.ACRITICAL;

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

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


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

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

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

            // now do a test to load it
            panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
            //form.Controls.Add (panel);
            //form.Show ();

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.LoadLayout("mynewpanel", false, null);
            _w.output("getting notes for " + panel.Caption);
            System.Collections.ArrayList TheNotes = panel.GetAllNotes();

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

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

            //.NoteDataInterface[] found = (NoteDataInterface)list.Find (NoteDataInterface=>NoteDataInterface.GuidForNote == CoreUtilities.Links.LinkTable.STICKY_TABLE );
            //	Assert.True (false);
        }
Пример #28
0
        public void SpeedTest()
        {
            // this will be a benchmarking test that will create a complicated Layout
            // Then it will time and record the results of LOADING and SAVING that layout into a
            // table saved in my backup paths
            // will also output a DAAbackup file (text readable) format too
            _TestSingleTon.Instance._SetupForLayoutPanelTests();


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



            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);

            // needed else DataGrid does not initialize

            form.Show();
            //form.Visible = false;
            _w.output("boom");
            // March 2013 -- notelist relies on having this
            YOM2013.DefaultLayouts.CreateASystemLayout(form, null);


            //NOTE: For now remember that htis ADDS 1 Extra notes
            string panelname = System.Guid.NewGuid().ToString();

            panel.NewLayout(panelname, true, null);
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            _w.output("herefirst");

            // ADD 1 of each type
            foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML())
            {
                for (int i = 0; i < 10; i++)
                {
                    NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance(t);
                    panel.AddNote(note);
                    note.CreateParent(panel);
                }
            }
            _w.output("here");
            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

            panelA.Caption = "PanelA";
            panel.AddNote(panelA);
            string stringoftypes = "";

            foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML())
            {
                NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance(t);
                panelA.AddNote(note);
                stringoftypes = stringoftypes + " " + t.ToString();
            }
            panel.SaveLayout();
            string base_path = _TestSingleTon.PATH_TO_SpeedTestFiles;            //@"C:\Users\BrentK\Documents\Keeper\Files\yomspeedtests2013\";

            _w.output("here");
            NoteDataXML_RichText richy;

            for (int i = 0; i < 20; i++)
            {
                richy         = new NoteDataXML_RichText();
                richy.Caption = "richtext";
                panel.AddNote(richy);
                Assert.True(richy.GetIsRichTextBlank());
                richy.DoOverwriteWithRTFFile(System.IO.Path.Combine(base_path, "speedtest.rtf"));
                Assert.False(richy.GetIsRichTextBlank());
            }
            _w.output("First save");
            panel.SaveLayout();
            string table = "layoutpanelsaveload";
            // Now try and write this data out.
            SqlLiteDatabase timetracking = new SqlLiteDatabase(System.IO.Path.Combine(base_path, "speedtests.s3db"));

            timetracking.CreateTableIfDoesNotExist(table, new string [5] {
                "id", "datetime", "timetook", "types", "saveorload"
            },
                                                   new string[5] {
                "INTEGER", "TEXT", "FLOAT", "TEXT", "TEXT"
            }, "id");


            // * Now start the Load Test
            TimeSpan time;

            CoreUtilities.TimerCore.TimerOn = true;
            time = CoreUtilities.TimerCore.Time(() => {
                panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
                form.Controls.Add(panel);
                panel.LoadLayout(panelname, false, null);
            });
            _w.output("TIME " + time);



            timetracking.InsertData(table, new string[4] {
                "datetime", "timetook", "types", "saveorload"
            }, new object[4] {
                DateTime.Now.ToString(),
                time.TotalSeconds, stringoftypes, "load"
            });

            time = CoreUtilities.TimerCore.Time(() => {
                // We keep the PANEL from above! Don't recreate it.
                //panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK);
                panel.SaveLayout();
            });


            Console.WriteLine("TIME " + time);

            timetracking.InsertData(table, new string[4] {
                "datetime", "timetook", "types", "saveorload"
            }, new object[4] {
                DateTime.Now.ToString(),
                time.TotalSeconds, stringoftypes, "save"
            });

            string backup = timetracking.BackupDatabase();

            System.IO.TextWriter write = new System.IO.StreamWriter(System.IO.Path.Combine(base_path, "timeresults.txt"));
            write.WriteLine(backup);

            write.Close();

            FakeLayoutDatabase   layout = new FakeLayoutDatabase("testguid");
            FAKE_SqlLiteDatabase db     = new FAKE_SqlLiteDatabase(layout.GetDatabaseName());

            _w.output("Backup of stored database: " + db.BackupDatabase());

            timetracking.Dispose();
            db.Dispose();
        }
Пример #29
0
        public void TestLinkTables()
        {
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataPicture), "pictures");



            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(

            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

            panelA.Caption = "PanelA";

            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel();

            panelB.Caption = "PanelB";


            panel.AddNote(panelA);
            panelA.CreateParent(panel);

            // b is inside A
            panelA.AddNote(panelB);
            panelB.CreateParent(panelA.GetPanelsLayout());


            FAKE_NoteDataPicture picture = new FAKE_NoteDataPicture();

            panelB.AddNote(picture);
            picture.CreateParent(panelB.GetPanelsLayout());
            // add a few more pictures
            picture = new FAKE_NoteDataPicture();
            panelB.AddNote(picture);
            picture.CreateParent(panelB.GetPanelsLayout());


            picture = new FAKE_NoteDataPicture();
            panelB.AddNote(picture);
            picture.CreateParent(panelB.GetPanelsLayout());



            panel.SaveLayout();
            // basic note + LINKTABLE + Default Note + Panel A + Panel B + Picture1 + Picture2 + Picture3= 8
            Assert.AreEqual(8, panel.CountNotes());
            // create several pictures, including in a subpanel, and then count linktables=1
            CoreUtilities.Links.LinkTable panelLinkTable = panelB.GetPanelsLayout().GetLinkTable();
            CoreUtilities.Links.LinkTable MainLinkTable  = panel.GetLinkTable();

            Assert.AreEqual(panelLinkTable, MainLinkTable);

            CoreUtilities.Links.LinkTable dodgeball = new CoreUtilities.Links.LinkTable();
            Assert.AreNotEqual(MainLinkTable, dodgeball);
            //Assert.AreNotEqual(MainLinkTable, panelLinkTable);


            // moves one of the pictures out of the Folder B and into FolderA
            Assert.AreEqual(4, panelA.CountNotes());
            panelB.myLayoutPanel().MoveNote(picture.GuidForNote, "up");
            Assert.AreEqual(4, panelA.CountNotes());              // count should stay the same
            panelA.myLayoutPanel().MoveNote(picture.GuidForNote, "up");
            Assert.AreEqual(3, panelA.CountNotes());              // now that the note is out the count should go down
            Assert.AreEqual(8, panel.CountNotes());
        }
        public void GetValuesForTable()
        {
            _SetupForLayoutPanelTests();
            Form             form  = new Form();
            FAKE_LayoutPanel panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            form.Controls.Add(panel);

            // needed else DataGrid does not initialize
            form.Visible = false;
            form.Show();
            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout("mynewpanel", true, null);
            NoteDataXML_Table test = new NoteDataXML_Table(425, 380);

            test.GuidForNote = "thisguid1";
            test.Caption     = "note1";

            test.Columns = new ColumnDetails[3] {
                new ColumnDetails("snakes", 109),
                new ColumnDetails("fish", 90),
                new ColumnDetails("goobers", 11111)
            };
            test.AddRow(new object[3] {
                "1", "value1", "testA"
            });
            test.AddRow(new object[3] {
                "2", "value2", "testB"
            });
            test.AddRow(new object[3] {
                "3", "value3", "testC"
            });

            panel.AddNote(test);
            test.CreateParent(panel);
            panel.SaveLayout();
            List <string> cols = test.GetValuesForColumn(1, "*");

            for (int i = 0; i < 3; i++)
            {
                switch (i)
                {
                case 0: Assert.AreEqual(cols[i], "value1"); break;

                case 1: Assert.AreEqual(cols[i], "value2"); break;

                case 2: Assert.AreEqual(cols[i], "value3"); break;
                }
            }
            cols = test.GetValuesForColumn(2, "*");
            for (int i = 0; i < 3; i++)
            {
                switch (i)
                {
                case 0: Assert.AreEqual(cols[i], "testA"); break;

                case 1: Assert.AreEqual(cols[i], "testB"); break;

                case 2: Assert.AreEqual(cols[i], "testC"); break;
                }
            }
        }