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));
        }
        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);
        }
Пример #3
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 CountSpecificSubType()
        {
            //-- do unit tests counting store 6 textboxes and know this (countbytype)

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


            int count = 25;
            //	FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            FAKE_LayoutPanel layoutPanel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);

            layoutPanel.NewLayout("testguid", true, null);

            // jan152013 - tweak to allow this to work with new system without rewriting all the tstings in LayoutDatabasetest
            LayoutDatabase layout = layoutPanel.GetLayoutDatabase();

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

            NoteDataXML note = new NoteDataXML();

            for (int i = 0; i < count; i++)
            {
                note.Caption = "boo" + i.ToString();
                layout.Add(note);
                note.CreateParent(layoutPanel);
            }
            _w.output(String.Format("{0} Notes in Layout before save", layout.GetNotes().Count.ToString()));

            for (int i = 0; i < 6; i++)
            {
                note = new NoteDataXML_RichText();

                note.Caption = "richText";
                layout.Add(note);
                note.CreateParent(layoutPanel);
            }

            layout.SaveTo();

            //	_w.output(String.Format ("{0} Objects Saved", layout.ObjectsSaved().ToString()));
            layout = new FakeLayoutDatabase("testguid");

            layout.LoadFrom(layoutPanel);

            // now count RichText notes
            int count2 = 0;

            foreach (NoteDataInterface _note in layout.GetNotes())
            {
                if (_note.GetType() == typeof(NoteDataXML_RichText))
                {
                    count2++;
                }
            }

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


            // added linktable
            Assert.AreEqual(7, count2);
        }