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);
            }
        }
        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);
        }
示例#3
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();
        }
示例#4
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 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 ();
        }
示例#6
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();
        }
        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 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();
        }