Esempio n. 1
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);
        }
Esempio n. 2
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());
        }
Esempio n. 3
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());
        }
Esempio n. 4
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);
        }
Esempio n. 5
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));
        }
Esempio n. 6
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");
        }
Esempio n. 7
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());
        }
Esempio n. 8
0
        public void FindFile_MissingAdvanced()
        {
            //TestingSingleton.GetImageFile
            // Tests to see if it can find the file, in CURRENT directory (not at location specifeid and not at root level -- Searches subdirectores)
            //TestingSingleton.GetImageFile
            // Tests to see if it can find the file, in CURRENT directory (not at location specifeid)

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



            string NewDirectory = Path.Combine(Environment.CurrentDirectory, @"temppicdirectory");

            //CoreUtilities.NewMessage.Show("trying to create: "+ NewDirectory);
            Directory.CreateDirectory(NewDirectory);
            //string NewLocation = Path.Combine (NewDirectory, _TestSingleTon.InvalidImageFile);



            string NewLocation = Path.Combine(NewDirectory, _TestSingleTon.InvalidImageFile);

            _w.output("here");

            File.Delete(NewLocation);

            //File.Copy (_TestSingleTon.ValidImageFile, NewLocation, true);

            File.Delete(_TestSingleTon.InvalidImageFile);              // in case leftover froma nother test



            Assert.False(File.Exists(_TestSingleTon.InvalidImageFile), "File ALready Exists!");
            // copy it into local directory
            _w.output("here2");

            File.Copy(_TestSingleTon.ValidImageFile, NewLocation, true);

            picture._SetImage(_TestSingleTon.InvalidImageFile);
            // THis should work, it works LIVE??
            Assert.IsNotNull(picture.GetPictureBox().Image);
            picture.Dispose();
        }
Esempio n. 9
0
        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;
        }
Esempio n. 10
0
        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);
        }
        public void ArchiveAllAndCount()
        {
            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));

            LayoutDetails.Instance.CurrentLayout = panel;
            MefAddIns.Addin_Archive Archiver = new MefAddIns.Addin_Archive();

            // delete existing files
            string path = Archiver.BuildArchiveDepotPath();

            string[] files = Directory.GetFiles(path);
            foreach (string s in files)
            {
                File.Delete(s);
            }
            files = Directory.GetFiles(path);

            Assert.AreEqual(0, files.Length);


            Archiver.ArchiveAll(panel, "automatedtesting");
            files = Directory.GetFiles(path);
            Assert.AreEqual(3, files.Length);
        }
Esempio n. 12
0
        public void TimelineAndTableAlwaysTogether()
        {
            _w.output("START");
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

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

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

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

            basicNote.Caption = "note1";

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



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

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

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

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


            _w.output("panels made");


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

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



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

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

            _w.output("ENDCOUNT");



            // add timeline into a PANEL
            // count 1 row
            NoteDataXML_Timeline MyTimeLine = new NoteDataXML_Timeline(100, 100);

            MyTimeLine.Caption = "My Timeline!";
            panelA.AddNote(MyTimeLine);
            MyTimeLine.CreateParent(panelA.GetPanelsLayout());

            panel.SaveLayout();             // I needed this save else it would not work?

            Assert.AreEqual(8, panel.CountNotes(), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");


            string guidOfTimeline      = MyTimeLine.GuidForNote;
            string guidOfTimelineTable = guidOfTimeline + "table";

            NoteDataXML_Table FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable);

            Assert.NotNull(FoundTable);

            Assert.AreEqual(1, FoundTable.RowCount());
            FoundTable = null;

            // move the TABLE associated with the timeline OUT to parent
            // count 1 row


            panelA.myLayoutPanel().MoveNote(guidOfTimelineTable, "up");

            // And for kicks add another timeline just to see if it messages anytnig up
            NoteDataXML_Timeline MyTimeLine2 = new NoteDataXML_Timeline(100, 1020);

            MyTimeLine2.Caption = "My Timeline! #2";
            panel.AddNote(MyTimeLine2);

            panel.SaveLayout();
            Assert.AreEqual(10, panel.CountNotes(), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");


            Assert.Null(FoundTable);
            FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable);
            Assert.NotNull(FoundTable);

            Assert.AreEqual(1, FoundTable.RowCount());

            // move the TABLE into ANOTHER panel
            // count 1 row
            _w.output("Moving into panelb now");
            panel.MoveNote(guidOfTimelineTable, "panelb");
            panel.SaveLayout();

            Assert.AreEqual(10, panel.CountNotes(), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");
            _w.output("done counting");

            FoundTable = null;
            Assert.Null(FoundTable);
            FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable);
            Assert.NotNull(FoundTable);

            Assert.AreEqual(1, FoundTable.RowCount());
            form.Dispose();
        }