示例#1
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();
        }
示例#2
0
        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);
        }
示例#3
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;
        }
示例#4
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);
        }
示例#5
0
        public void IdentifySubpanels()
        {
            // get the link into a subpanel and make the counts are as expected
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            //	_SetupForLayoutPanelTests ();

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

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

            NoteDataXML basicNote = new NoteDataXML();

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

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


            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel();

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

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


            NoteDataXML_LinkNote link = new NoteDataXML_LinkNote();

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


            linkstome = MasterOfLayouts.ReciprocalLinks("mynewpanel");

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

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

            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel();

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

            panel.SaveLayout();

            children = MasterOfLayouts.GetListOfChildren("mynewpanel");
            Assert.AreEqual(2, children.Count);
            Assert.AreEqual("panela", children[0]);
            Assert.AreEqual("panelB", children[1]);
        }
        public void 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);
        }