Пример #1
0
        public void _SetupForLayoutPanelTests(bool BreakAppearanceOnPurpose, string OverrideDatabaseName)
        {
            LayoutDetails.Instance.UpdateAfterLoadList.Clear();
            SetupForAnyTest();
            LayoutDetails.Instance.YOM_DATABASE = TESTDATABASE;
            if ("" != OverrideDatabaseName)
            {
                LayoutDetails.Instance.YOM_DATABASE = OverrideDatabaseName;
            }
            LayoutDetails.Instance.OverridePath = Environment.CurrentDirectory;
            _w.output(LayoutDetails.Instance.YOM_DATABASE);
            if (false == BreakAppearanceOnPurpose)
            {
                LayoutDetails.Instance.GetAppearanceFromStorage = GetAppearanceFromStorage;
            }
            else
            {
                LayoutDetails.Instance.GetAppearanceFromStorage = null;
            }


            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Text), "testingtext");

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

            LayoutDetails.Instance.TransactionsList = new Transactions.TransactionsTable(MasterOfLayouts.GetDatabaseType(LayoutDetails.Instance.YOM_DATABASE));
            foreach (string s in ListOfTablesToDrop)
            {
                db.DropTableIfExists(s);
                //	db.DropTableIfExists("system");
                _w.output("dropping table " + s);
            }
        }
        public void TestAddToStart()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            FakeLayoutDatabase layout = new FakeLayoutDatabase("DeleteMe");

            //	LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layout.SaveTo();
            NoteDataXML test = new NoteDataXML();

            test.GuidForNote = CoreUtilities.Links.LinkTable.STICKY_TABLE;
            layout.AddToStart(test);
        }
        public void TryToAddANullNote()
        {
            // no failure should happen. Simply should not be allowed to to do this.
            FakeLayoutDatabase layout = new FakeLayoutDatabase("testguid");
            NoteDataXML        note   = new NoteDataXML();

            note.Caption = "boo";
            layout.Add(note);
            // we should have one note in the list. Now add null
            layout.Add(null);
            Assert.AreEqual(1, layout.GetNotes().Count);
        }
        public void TestInvalidAddToStart()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            FakeLayoutDatabase layout = new FakeLayoutDatabase("DeleteMe");

            //LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            //layoutPanel.NewLayout("testguid", true, null);
            layout.SaveTo();
            NoteDataXML test = new NoteDataXML();

            test.GuidForNote = "boo";
            layout.AddToStart(test);
        }
Пример #5
0
        protected void _SetupForLayoutPanelTests()
        {
            // just to make sure we are calling any other essential setters we call the Singleton, even though we are doign some custom stuff here to
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            LayoutDetails.Instance.YOM_DATABASE = "yom_test_database.s3db";
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel),"testingpanel");
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Text),"testingtext");

            FakeLayoutDatabase layout = new FakeLayoutDatabase("testguid");
            FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase(layout.GetDatabaseName ());
            db.DropTableIfExists(Layout.data.dbConstants.table_name);
            _w.output ("dropping table " + Layout.data.dbConstants.table_name);
        }
        public void LoadSomethingNotThere()
        {
            _setupforlayoutests();

            // this one needs to create the database

            FakeLayoutDatabase layout = new FakeLayoutDatabase("testguid");
            //	LayoutPanel layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            //layoutPanel.NewLayout("testguid", false, null);
            //	layoutPanel.LoadLayout("testguid", false, null);
            bool result = layout.LoadFrom(null);

            _w.output("made it");
            Assert.AreEqual(false, result);
        }
        protected void _SetupForLayoutPanelTests()
        {
            // just to make sure we are calling any other essential setters we call the Singleton, even though we are doign some custom stuff here to
            _TestSingleTon.Instance._SetupForLayoutPanelTests();


            LayoutDetails.Instance.YOM_DATABASE = "yom_test_database.s3db";
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Text), "testingtext");

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

            db.DropTableIfExists(Layout.data.dbConstants.table_name);
            _w.output("dropping table " + Layout.data.dbConstants.table_name);
        }
        public void LoadSomethingNotThere()
        {
            _setupforlayoutests();

            // this one needs to create the database

            FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            //	LayoutPanel layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            //layoutPanel.NewLayout("testguid", false, null);
            //	layoutPanel.LoadLayout("testguid", false, null);
            bool result = layout.LoadFrom(null);
            _w.output("made it");
            Assert.AreEqual(false, result);
        }
        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);
        }
Пример #10
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();
        }
 public void TestInvalidAddToStart()
 {
     _TestSingleTon.Instance._SetupForLayoutPanelTests();
     FakeLayoutDatabase layout = new FakeLayoutDatabase ("DeleteMe");
     //LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
     //layoutPanel.NewLayout("testguid", true, null);
     layout.SaveTo ();
     NoteDataXML test = new NoteDataXML();
     test.GuidForNote = "boo";
     layout.AddToStart(test);
 }
Пример #12
0
        public void IterateBigDatabase()
        {
            _TestSingleTon.Instance.SetupForAnyTest();
            LayoutDetails.Instance.YOM_DATABASE = @"C:\Users\BrentK\Documents\Projects\Utilities\yom2013B\zUnitTestsForSolution\bin\Debug\yomBIGGY.s3db";
            LayoutDetails.Instance.OverridePath = Environment.CurrentDirectory;

            LayoutDetails.Instance.GetAppearanceFromStorage = _TestSingleTon.Instance.GetAppearanceFromStorage;



            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Text), "testingtext");

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

            LayoutDetails.Instance.SuppressWarnings = true;             /// want image missing popups not to bug us

            LayoutDetails.Instance.AddToList(typeof(NoteDataXML_Picture.NoteDataXML_Pictures), "picture");
            LayoutDetails.Instance.AddToList(typeof(MefAddIns.NoteDataXML_SendIndex), "index");
            LayoutDetails.Instance.AddToList(typeof(MefAddIns.NoteDataXML_Submissions), "index");

            LayoutDetails.Instance.TransactionsList = new Transactions.TransactionsTable(MasterOfLayouts.GetDatabaseType(LayoutDetails.Instance.YOM_DATABASE));


            Form form = new Form();

            // system panel
//			LayoutPanel panel = new LayoutPanel("", false);
//			panel.LoadLayout("system", false, null);


            FAKE_LayoutPanel system = new FAKE_LayoutPanel("", false);

            form.Controls.Add(system);
            system.LoadLayout("system", false, null);

            LayoutDetails.Instance.SystemLayout = system;

            FAKE_LayoutPanel tablelay = new FAKE_LayoutPanel("", false);

            form.Controls.Add(tablelay);
            tablelay.LoadLayout("tables", false, null);

            LayoutDetails.Instance.TableLayout = tablelay;
            //	YOM2013.DefaultLayouts.CreateASystemLayout(form,null);
            //	string ThisLayoutGUID = "mynewpanelXA";
            // create a layout
            //	_TestSingleTon.Instance._SetupForLayoutPanelTests (false, @"C:\Users\BrentK\Documents\Projects\Utilities\yom2013B\zUnitTestsForSolution\bin\Debug\yomBIGGY.s3db");
            //	_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);



            // tmp: goto all notes
            System.Collections.Generic.List <MasterOfLayouts.NameAndGuid> ss = MasterOfLayouts.GetListOfLayouts("");
            Assert.AreEqual(3651, ss.Count);
            //Console.WriteLine(ss.Count);
            //	NewMessage.Show (ss.Count.ToString ());
            int count = 0;

            foreach (MasterOfLayouts.NameAndGuid name in ss)
            {
                panel.Dispose();
                panel = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false);
                form.Controls.Add(panel);
                count++;
                panel.LoadLayout(name.Guid, false, null);
                //	MDIHOST.DoCloseNote(false);
            }
            Assert.AreEqual(3651, count);
            form.Dispose();
        }
Пример #13
0
        public void _SetupForLayoutPanelTests(bool BreakAppearanceOnPurpose, string OverrideDatabaseName)
        {
            LayoutDetails.Instance.UpdateAfterLoadList.Clear ();
            SetupForAnyTest ();
            LayoutDetails.Instance.YOM_DATABASE = TESTDATABASE;
            if ("" != OverrideDatabaseName) {
                LayoutDetails.Instance.YOM_DATABASE = OverrideDatabaseName;
            }
            LayoutDetails.Instance.OverridePath = Environment.CurrentDirectory;
            _w.output (LayoutDetails.Instance.YOM_DATABASE);
            if (false == BreakAppearanceOnPurpose)
                LayoutDetails.Instance.GetAppearanceFromStorage = GetAppearanceFromStorage;
            else
                LayoutDetails.Instance.GetAppearanceFromStorage = null;

            LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Panel), "testingpanel");
            LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Text), "testingtext");

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

            LayoutDetails.Instance.TransactionsList = new Transactions.TransactionsTable (MasterOfLayouts.GetDatabaseType (LayoutDetails.Instance.YOM_DATABASE));
            foreach (string s in ListOfTablesToDrop) {
                db.DropTableIfExists (s);
                //	db.DropTableIfExists("system");
                _w.output ("dropping table " + s);
            }
        }
        public void  SaveTo_BlankGUID()
        {
            FakeLayoutDatabase layout = new FakeLayoutDatabase("");

            layout.SaveTo();
        }
        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);
        }
 public void SaveTo_BlankGUID()
 {
     FakeLayoutDatabase layout = new FakeLayoutDatabase("");
     layout.SaveTo ();
 }
 public void TestAddToStart()
 {
     _TestSingleTon.Instance._SetupForLayoutPanelTests();
     FakeLayoutDatabase layout = new FakeLayoutDatabase ("DeleteMe");
     //	LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
     layout.SaveTo ();
     NoteDataXML test = new NoteDataXML();
     test.GuidForNote = CoreUtilities.Links.LinkTable.STICKY_TABLE;
     layout.AddToStart(test);
 }
        public void IterateBigDatabase()
        {
            _TestSingleTon.Instance.SetupForAnyTest ();
            LayoutDetails.Instance.YOM_DATABASE =@"C:\Users\BrentK\Documents\Projects\Utilities\yom2013B\zUnitTestsForSolution\bin\Debug\yomBIGGY.s3db";
            LayoutDetails.Instance.OverridePath = Environment.CurrentDirectory;

            LayoutDetails.Instance.GetAppearanceFromStorage = _TestSingleTon.Instance.GetAppearanceFromStorage;

            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel),"testingpanel");
            LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Text),"testingtext");

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

            LayoutDetails.Instance.SuppressWarnings = true; /// want image missing popups not to bug us

            LayoutDetails.Instance.AddToList(typeof(NoteDataXML_Picture.NoteDataXML_Pictures), "picture");
            LayoutDetails.Instance.AddToList(typeof(MefAddIns.NoteDataXML_SendIndex), "index");
            LayoutDetails.Instance.AddToList(typeof(MefAddIns.NoteDataXML_Submissions), "index");

            LayoutDetails.Instance.TransactionsList =new Transactions.TransactionsTable(MasterOfLayouts.GetDatabaseType(LayoutDetails.Instance.YOM_DATABASE));

            Form form = new Form();

            // system panel
            //			LayoutPanel panel = new LayoutPanel("", false);
            //			panel.LoadLayout("system", false, null);

            FAKE_LayoutPanel system = new FAKE_LayoutPanel("", false);
            form.Controls.Add(system);
            system.LoadLayout("system", false, null);

            LayoutDetails.Instance.SystemLayout = system;

            FAKE_LayoutPanel tablelay = new FAKE_LayoutPanel("", false);
            form.Controls.Add(tablelay);
            tablelay.LoadLayout ("tables", false, null);

            LayoutDetails.Instance.TableLayout = tablelay;
            //	YOM2013.DefaultLayouts.CreateASystemLayout(form,null);
            //	string ThisLayoutGUID = "mynewpanelXA";
            // create a layout
            //	_TestSingleTon.Instance._SetupForLayoutPanelTests (false, @"C:\Users\BrentK\Documents\Projects\Utilities\yom2013B\zUnitTestsForSolution\bin\Debug\yomBIGGY.s3db");
            //	_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);

            // tmp: goto all notes
            System.Collections.Generic.List<MasterOfLayouts.NameAndGuid> ss = MasterOfLayouts.GetListOfLayouts ("");
            Assert.AreEqual (3651, ss.Count);
            //Console.WriteLine(ss.Count);
            //	NewMessage.Show (ss.Count.ToString ());
            int count = 0;
            foreach (MasterOfLayouts.NameAndGuid name in ss) {
                panel.Dispose ();
                panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
                form.Controls.Add (panel);
                count++;
                panel.LoadLayout(name.Guid,false, null);
            //	MDIHOST.DoCloseNote(false);
            }
            Assert.AreEqual (3651, count);
            form.Dispose ();
        }
 public void TryToAddANullNote()
 {
     // no failure should happen. Simply should not be allowed to to do this.
     FakeLayoutDatabase layout = new FakeLayoutDatabase("testguid");
     NoteDataXML note = new NoteDataXML();
     note.Caption = "boo";
     layout.Add(note);
     // we should have one note in the list. Now add null
     layout.Add (null);
     Assert.AreEqual(1, layout.GetNotes().Count);
 }
Пример #20
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();
        }