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 GetListOfLayoutTests()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            form.Show ();
            // March 2013 -- notelist relies on having this
            YOM2013.DefaultLayouts.CreateASystemLayout(form,null);

            string panelname2 = System.Guid.NewGuid().ToString();
            FAKE_LayoutPanel  PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout (panelname2,true, null);
            form.Controls.Add (PanelOtherGuy);
            PanelOtherGuy.SaveLayout();

            Assert.AreEqual( 2, PanelOtherGuy.CountNotes(), "count1");

            List<MasterOfLayouts.NameAndGuid> names =  MasterOfLayouts.GetListOfLayouts("WritingProjects");

            Assert.AreEqual (0, names.Count);

            // 1 prtoject

            PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout ("NextLayout",true, null);
            PanelOtherGuy.SetCaption("booler");
            PanelOtherGuy.SetNotebookSection("Writing","Projects");
            form.Controls.Add (PanelOtherGuy);
            PanelOtherGuy.SaveLayout();

            names =  MasterOfLayouts.GetListOfLayouts("WritingProjects");

            Assert.AreEqual (1, names.Count);

            // search LIKE NAME

            PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout ("NextLayout22",true, null);
            PanelOtherGuy.SetCaption("boolAt");

            LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Text), "textfake");

            FAKE_NoteDataXML_Text richy = new FAKE_NoteDataXML_Text();

            PanelOtherGuy.AddNote(richy);
            richy.CreateParent(PanelOtherGuy);
            richy.GetRichTextBox().Text="Hello there";

            PanelOtherGuy.SetNotebookSection("Writing","Projects");
            form.Controls.Add (PanelOtherGuy);
            PanelOtherGuy.SaveLayout();

            PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout ("NextLayout33",true, null);
            PanelOtherGuy.SetCaption("bolzzz");
            PanelOtherGuy.SetNotebookSection("Writing","Projects");
            form.Controls.Add (PanelOtherGuy);
            PanelOtherGuy.SaveLayout();

            names =  MasterOfLayouts.GetListOfLayouts("WritingProjects");

            Assert.AreEqual (3, names.Count);

            names =  MasterOfLayouts.GetListOfLayouts("WritingProjects","bool",false, null);

            Assert.AreEqual (2, names.Count);

            //
            // text searching
            //

            PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout ("NextLayout55",true, null);
            PanelOtherGuy.SetCaption("bolzzz222");
            PanelOtherGuy.SetNotebookSection("Writing","Projects");
            form.Controls.Add (PanelOtherGuy);
            PanelOtherGuy.SaveLayout();

            richy = new FAKE_NoteDataXML_Text();

            PanelOtherGuy.AddNote(richy);
            richy.CreateParent(PanelOtherGuy);
            richy.GetRichTextBox().Text="Hello there again!";
            PanelOtherGuy.SaveLayout();
            richy = new FAKE_NoteDataXML_Text();

            PanelOtherGuy.AddNote(richy);
            richy.CreateParent(PanelOtherGuy);
            richy.GetRichTextBox().Text="Hello the fish are good there";
            PanelOtherGuy.SaveLayout();

            names =  MasterOfLayouts.GetListOfLayouts("All", "fish", true, null);
            Assert.AreEqual (1, names.Count);
            // FINAL TEST now count all

            names =  MasterOfLayouts.GetListOfLayouts("All");
            Assert.AreEqual (6, names.Count);

            // now test to see if text in a subpanel is found correct
            FAKE_NoteDataXML_Panel subpanel = new FAKE_NoteDataXML_Panel();
            PanelOtherGuy.AddNote(subpanel);
            subpanel.CreateParent(PanelOtherGuy);

            names =  MasterOfLayouts.GetListOfLayouts("All", "sharks", true, null);
            Assert.AreEqual (0, names.Count);

            FAKE_NoteDataXML_Text Rich2 = new FAKE_NoteDataXML_Text();
            subpanel.AddNote(Rich2);
            Rich2.GetRichTextBox().Text = "Sharks";

            PanelOtherGuy.SaveLayout ();

            names =  MasterOfLayouts.GetListOfLayouts("All", "sharks", true, null);
            Assert.AreEqual (1, names.Count);
        }
        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 CopyNoteTest()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

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

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

            form.Controls.Add (panelToUse);

            // 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();
            panelToUse.NewLayout (panelname,true, null);
            LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            _w.output ("herefirst");

            Timer SaveTimer= new Timer();
            SaveTimer.Interval = 300;
            SaveTimer.Tick+= HandleSaveTimerTick;
            SaveTimer.Start ();

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

                    note.UpdateAfterLoad();
                    panelToUse.CopyNote(note);
                    panelToUse.PasteNote();
                }
            }
            panelToUse.SaveLayout();
            //int propercount= 4 * LayoutDetails.Instance.ListOfTypesToStoreInXML().Length;
            Assert.AreEqual (46, panelToUse.CountNotes());

            //
            // Now we test pasting one of our notes onto another Layout
            //

            string panelname2 = System.Guid.NewGuid().ToString();
            FAKE_LayoutPanel  PanelOtherGuy= new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            PanelOtherGuy.NewLayout (panelname2,true, null);
            PanelOtherGuy.SaveLayout();

            form.Controls.Add(PanelOtherGuy);

            Assert.AreEqual( 2, PanelOtherGuy.CountNotes(), "count1");

            // ADD 1 of each type
            //foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML())
            {
                for (int i = 0; i < 10; i++) {

                    NoteDataInterface note = new NoteDataXML_RichText();
                    PanelOtherGuy.AddNote (note);
                    note.CreateParent(PanelOtherGuy);

                    note.UpdateAfterLoad();

                }
            }
            Assert.AreEqual( 12, PanelOtherGuy.CountNotes(), "count2");
            PanelOtherGuy.PasteNote();
            Assert.AreEqual( 13, PanelOtherGuy.CountNotes(), "count2");
            PanelOtherGuy.SaveLayout();

            FAKE_NoteDataXML_Text Noter = new FAKE_NoteDataXML_Text();
            Noter.Caption ="Hello there";

            PanelOtherGuy.AddNote (Noter);

            Noter.GetRichTextBox().Text ="bear";
            PanelOtherGuy.SaveLayout ();

            PanelOtherGuy.CopyNote(Noter);
            NoteDataXML_RichText CopyOfTextNote = (NoteDataXML_RichText)PanelOtherGuy.PasteNote();
            Assert.AreEqual ("Hello there",CopyOfTextNote.Caption);
            Assert.AreEqual ("bear", CopyOfTextNote.GetRichTextBox().Text);

            //
            //
            // Table Copy Test
            //
            //

            NoteDataXML_Table randomTables = new NoteDataXML_Table(100, 100,new ColumnDetails[2]{new ColumnDetails("id",100), new ColumnDetails("tables",100)} );
            randomTables.Caption = LayoutDetails.SYSTEM_RANDOM_TABLES;
            //	randomTables.Columns = new appframe.ColumnDetails[2]{new appframe.ColumnDetails("id",100), new appframe.ColumnDetails("tables",100)};

            PanelOtherGuy.AddNote(randomTables);
            //randomTables.CreateParent(PanelOtherGuy);

            randomTables.AddRow(new object[2]{"1", "example|colors"});
            randomTables.AddRow(new object[2]{"2", "example|colorPROMPTS"});
            PanelOtherGuy.SaveLayout ();

            PanelOtherGuy.CopyNote(randomTables);
            NoteDataXML_Table CopyOfTable = (NoteDataXML_Table)PanelOtherGuy.PasteNote();
            Assert.AreEqual (2, CopyOfTable.RowCount());
        }
        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);
        }
Ejemplo n.º 6
0
        public void TestReplaceWorks_WithSimiliarWORDS()
        {
            //NOTE: This will not work until I implement the Replace system improvements

            _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 dog 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(5, findBar.PositionsFOUND(), "Found 5 dogs");
            findBar.Replace_Text("dog", "dog2");
            findBar.DoFind("dog", false,fakeTextNote.GetRichTextBox(),0);
            Assert.AreEqual(5, findBar.PositionsFOUND(), "Found 5 dogs because we are doing a partial search");

            findBar.DoFind("dog", true,fakeTextNote.GetRichTextBox(),0);
            Assert.AreEqual(0, findBar.PositionsFOUND(), "Found 0 dogs because we are doing an exact search NOTE: This will not work until I implement the Replace system improvements");

            findBar.DoFind("dog2", false,fakeTextNote.GetRichTextBox(),0);
            Assert.AreEqual(5, findBar.PositionsFOUND(), "Found 4 dog2. 4 replacements NOTE: This will not work until I implement the Replace system improvements ");
        }
Ejemplo n.º 7
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);
        }