Ejemplo n.º 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);
            }
        }
        private FAKE_SqlLiteDatabase CreateTestDatabase(string primarykey)
        {
            FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase(test_database_name);

            try {
                // There was a lock on deleting the database but I realized that the call to new would
                // clear the database if paired with a delete?

                // We have to clear memory when deleting because the database might be lingering
                //GC.Collect();
                //System.IO.File.Delete (test_database_name);
            } catch (Exception ex) {
                _w.output("Unable to delete file " + ex.ToString());
            }
            try {
                db.DropTableIfExists(dbConstants.table_name);
            } catch (Exception ex) {
                _w.output(String.Format("Unable to drop table {0}", ex.ToString()));
            }

            db.CreateTableIfDoesNotExist(dbConstants.table_name, new string[6]
            {
                dbConstants.ID, dbConstants.GUID, dbConstants.XML,
                dbConstants.STATUS, dbConstants.NAME, dbConstants.SUBPANEL
            },
                                         new string[6] {
                "INTEGER",
                "TEXT UNIQUE",
                "LONGTEXT",
                "TEXT", "TEXT", "BOOLEAN"
            }, primarykey
                                         );
            return(db);
        }
        public void GuidDoesExist()
        {
            _w.output("GUIDDOESEXIST");
            bool result = false;

            _w.output("here1");
            // Create a test database
            FAKE_SqlLiteDatabase db = CreateTestDatabase(String.Format("{0}", dbConstants.ID));

            _w.output("here");
            try {
                db.InsertData(dbConstants.table_name, new string[3] {
                    dbConstants.STATUS,
                    dbConstants.XML,
                    dbConstants.GUID
                }
                              , new object[3] {
                    "boo status", "boo xml", "GUID_A"
                });

                result = db.TestAddMissingColumn(dbConstants.table_name, new string[1] {
                    "boomer"
                },
                                                 new string[1] {
                    "TEXT"
                });
            } catch (Exception ex) {
                _w.output(ex.ToString());
            }
            _w.output("here");
            Assert.True(db.Exists(dbConstants.table_name, dbConstants.GUID, "GUID_A"));
            _w.output(result);
        }
Ejemplo n.º 4
0
        public void CreateExampleAndSystemLayouts()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            form.Show();
            //form.Visible=false; NOPE Form has to be visible now!!!

            DefaultLayouts.CreateExampleLayout(form, null);
            DefaultLayouts.CreateASystemLayout(form, null);
            FAKE_SqlLiteDatabase db    = new FAKE_SqlLiteDatabase(LayoutDetails.Instance.YOM_DATABASE);
            NoteDataXML_Table    table = (NoteDataXML_Table)LayoutDetails.Instance.TableLayout.FindNoteByGuid("systemqueries");

            Assert.NotNull(table);
            Assert.AreEqual("name", table.Columns[1].ColumnName);


            string result = db.BackupDatabase();

            Assert.Greater(result.Length, 29000);
            //Assert.AreEqual(29971, result.Length);
            db.Dispose();
            // creates the example and system layouts
            // to catch if any popups or other oddities introduced
            //Assert.True (false);
        }
        public void AddMissingColumn_Test_ColumnDidNotExistAndWeDetectedItCorrectly()
        {
            // Create a test database
            FAKE_SqlLiteDatabase db = CreateTestDatabase(String.Format("{0}", dbConstants.ID));

            db.InsertData(dbConstants.table_name, new string[3] {
                dbConstants.STATUS,
                dbConstants.XML,
                dbConstants.GUID
            }
                          , new object[3] {
                "boo status", "boo xml", "GUID_A"
            });
            _w.output(db.BackupDatabase());
            // add ColumnA to it
            bool result = db.TestAddMissingColumn(dbConstants.table_name, new string[1] {
                "boomer"
            },
                                                  new string[1] {
                "TEXT"
            });

            // check return value is true
            Assert.True(result);
            _w.output(db.BackupDatabase());
            // add ColumnA to it again. This time return value should be false (because we did not need to add the column)
            result = db.TestAddMissingColumn(dbConstants.table_name, new string[1] {
                "boomer"
            },
                                             new string[1] {
                "TEXT"
            });
            Console.WriteLine("Result #2 = " + result);
            Assert.False(result);
        }
        public void ColumnArrayToStringForInserting()
        {
            FAKE_SqlLiteDatabase test = new FAKE_SqlLiteDatabase("nUnitTest");
            string columns            = test.TestColumnArrayToStringForInserting(new string[3] {
                "dog", "cat", "fish"
            });

            //Console.WriteLine(columns);
            Assert.AreEqual(columns, "dog,cat,fish");
        }
Ejemplo n.º 7
0
        private TransactionsTable SetupForEventTests()
        {
            lg.Instance.OutputToConstoleToo = true;
            FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase(_TestSingleTon.TESTDATABASE);

            db.DropTableIfExists("events");
            db.Dispose();


            TransactionsTable eventTable = new TransactionsTable(MasterOfLayouts.GetDatabaseType(_TestSingleTon.TESTDATABASE));

            return(eventTable);
        }
        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 GuidDoesNotExist()
        {
            // Create a test database
            FAKE_SqlLiteDatabase db = CreateTestDatabase(String.Format("{0}", dbConstants.ID));

            db.InsertData(dbConstants.table_name, new string[3] {
                dbConstants.STATUS, dbConstants.XML, dbConstants.GUID
            }, new object[3] {
                "boo status", "boo xml", "GUID_A"
            });

            bool result = db.TestAddMissingColumn(dbConstants.table_name, new string[1] {
                "boomer"
            },
                                                  new string[1] {
                "TEXT"
            });

            Console.WriteLine("GuidDoesNotExist");
            Assert.False(db.Exists(dbConstants.table_name, dbConstants.GUID, "GUID_B"));
        }
        public void DropTableTest()
        {
            FAKE_SqlLiteDatabase db = CreateTestDatabase(String.Format("{0}", dbConstants.ID));

            _w.output("here");
            try {
                db.InsertData(dbConstants.table_name, new string[3] {
                    dbConstants.STATUS,
                    dbConstants.XML,
                    dbConstants.GUID
                }
                              , new object[3] {
                    "boo status", "boo xml", "GUID_A"
                });

                Assert.True(db.TableExists(dbConstants.table_name));
                db.DropTableIfExists(dbConstants.table_name);
                Assert.True(db.TableExists(dbConstants.table_name));
            } catch (Exception) {
            }
        }
        public void AddMissingColumn_ListOfColumnsNotEqualToListOfTypes()
        {
            // Create a test database
            FAKE_SqlLiteDatabase db = CreateTestDatabase(String.Format("{0}", dbConstants.ID));

            db.InsertData(dbConstants.table_name, new string[3] {
                dbConstants.STATUS,
                dbConstants.XML,
                dbConstants.GUID
            }
                          , new object[3] {
                "boo status", "boo xml", "GUID_A"
            });

            bool result = db.TestAddMissingColumn(dbConstants.table_name, new string[2] {
                "boomer", "poob"
            },
                                                  new string[1] {
                "TEXT"
            });
        }
        public void AddingToUniqueColumn()
        {
            // Create a test database
            FAKE_SqlLiteDatabase db = CreateTestDatabase(String.Format("{0}", dbConstants.GUID));

            Console.WriteLine("First insert should work");
            if (db.Exists("boo", dbConstants.XML, "z"))
            {
            }
            ;

            db.InsertData(dbConstants.table_name, new string[3] {
                dbConstants.STATUS,
                dbConstants.XML,
                dbConstants.GUID
            }
                          , new object[3] {
                "boo status", "boo xml", "GUID_A"
            });
            Console.WriteLine("inserting a unique GUID_B is okay");
            db.InsertData(dbConstants.table_name, new string[3] {
                dbConstants.STATUS,
                dbConstants.XML,
                dbConstants.GUID
            }
                          , new object[3] {
                "boo status", "boo xml", "GUID_B"
            });
            Console.WriteLine("Second insert should fail ");
            db.InsertData(dbConstants.table_name, new string[3] {
                dbConstants.STATUS,
                dbConstants.XML,
                dbConstants.GUID
            }
                          , new object[3] {
                "boo status", "boo xml", "GUID_A"
            });
        }
Ejemplo n.º 13
0
        public void CreateExampleAndSystemLayouts()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            form.Show();
            //form.Visible=false; NOPE Form has to be visible now!!!

            DefaultLayouts.CreateExampleLayout(form,null);
            DefaultLayouts.CreateASystemLayout(form,null);
            FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase(LayoutDetails.Instance.YOM_DATABASE);
            NoteDataXML_Table table =  (NoteDataXML_Table) LayoutDetails.Instance.TableLayout.FindNoteByGuid("systemqueries");
            Assert.NotNull(table);
            Assert.AreEqual ("name", table.Columns[1].ColumnName);

            string result = db.BackupDatabase();
            Assert.Greater(result.Length,29000);
            //Assert.AreEqual(29971, result.Length);
            db.Dispose();
            // creates the example and system layouts
            // to catch if any popups or other oddities introduced
            //Assert.True (false);
        }
        public void CreateTableIfDoesNotExist_CreateUnevenTable()
        {
            FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase(test_database_name);


            try {
                db.DropTableIfExists(dbConstants.table_name);
            } catch (Exception ex) {
                _w.output(String.Format("Unable to drop table {0}", ex.ToString()));
            }

            db.CreateTableIfDoesNotExist(dbConstants.table_name, new string[4]
            {
                dbConstants.ID, dbConstants.GUID, dbConstants.XML,
                dbConstants.STATUS
            },
                                         new string[3] {
                "INTEGER",
                "TEXT UNIQUE",
                "LONGTEXT"
            }, dbConstants.GUID
                                         );
            db.Dispose();
        }
Ejemplo n.º 15
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 ();
        }
Ejemplo n.º 17
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();
        }
Ejemplo n.º 18
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 Test_FailOnInvalidDatabaseName()
 {
     FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase ("");
     db.Dispose();
 }
        private FAKE_SqlLiteDatabase CreateTestDatabase(string primarykey)
        {
            FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase (test_database_name);

            try {

                // There was a lock on deleting the database but I realized that the call to new would
                // clear the database if paired with a delete?

                // We have to clear memory when deleting because the database might be lingering
                //GC.Collect();
                //System.IO.File.Delete (test_database_name);
            } catch (Exception ex) {
                _w.output ("Unable to delete file " + ex.ToString ());
            }
            try {

                db.DropTableIfExists(dbConstants.table_name);
            } catch (Exception ex) {
                _w.output (String.Format ("Unable to drop table {0}", ex.ToString()));
            }

            db.CreateTableIfDoesNotExist (dbConstants.table_name, new string[6]
                                          {dbConstants.ID, dbConstants.GUID, dbConstants.XML,
                dbConstants.STATUS, dbConstants.NAME, dbConstants.SUBPANEL},
            new string[6] {
                "INTEGER",
                "TEXT UNIQUE",
                "LONGTEXT",
                "TEXT","TEXT","BOOLEAN"
            }, primarykey
            );
            return db;
        }
        public void Test_FailOnInvalidDatabaseName()
        {
            FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase("");

            db.Dispose();
        }
        public void CreateFakeDatabaseAndBackup()
        {
            SqlLiteDatabase db = CreateTestDatabase(String.Format("{0}", dbConstants.GUID));

            db.InsertData(dbConstants.table_name, new string[3] {
                dbConstants.STATUS, dbConstants.XML, dbConstants.GUID
            }, new object[3] {
                "boo status", "boo xml", "GUID_A"
            });
            db.InsertData(dbConstants.table_name, new string[3] {
                dbConstants.STATUS, dbConstants.XML, dbConstants.GUID
            }, new object[3] {
                "boo status2", "boo xml2", "GUID_A2"
            });
            db.Dispose();


            db = new FAKE_SqlLiteDatabase(test_database_name);


            try {
                db.DropTableIfExists(dbConstants.table_name + "_b");
            } catch (Exception ex) {
                _w.output(String.Format("Unable to drop table {0}", ex.ToString()));
            }

            db.CreateTableIfDoesNotExist(dbConstants.table_name + "_b", new string[4]
            {
                dbConstants.ID, dbConstants.GUID, dbConstants.XML,
                dbConstants.STATUS
            },
                                         new string[4] {
                "INTEGER",
                "TEXT UNIQUE",
                "LONGTEXT",
                "TEXT"
            }, dbConstants.GUID
                                         );


            db.InsertData(dbConstants.table_name + "_b", new string[3] {
                dbConstants.STATUS, dbConstants.XML, dbConstants.GUID
            }, new object[3] {
                "boo status", "boo xml", "GUID_B"
            });



            db.Dispose();
            db = new FAKE_SqlLiteDatabase(test_database_name);


            try {
                db.DropTableIfExists(dbConstants.table_name + "_c");
            } catch (Exception ex) {
                _w.output(String.Format("Unable to drop table {0}", ex.ToString()));
            }

            db.CreateTableIfDoesNotExist(dbConstants.table_name + "_c", new string[4]
            {
                dbConstants.ID, dbConstants.GUID, dbConstants.XML,
                dbConstants.STATUS
            },
                                         new string[4] {
                "INTEGER",
                "TEXT UNIQUE",
                "LONGTEXT",
                "TEXT"
            }, dbConstants.GUID
                                         );

            db.InsertData(dbConstants.table_name + "_c", new string[3] {
                dbConstants.STATUS, dbConstants.XML, dbConstants.GUID
            }, new object[3] {
                "boo status", "boo xml", "GUID_C"
            });

            // get rid of full text database too
            db.DropTableIfExists("fulltextsearch");

            //not sure how to set this test up. Force File Write? Then test if file exists?
            // or shoudl this return a Stream?
            string result = db.BackupDatabase();

            _w.output(result.Length);
            _w.output(result);

            db.DropTableIfExists(dbConstants.table_name + "_b");
            db.DropTableIfExists(dbConstants.table_name + "_c");
            db.Dispose();
            Assert.AreEqual(526, result.Length);
            //Assert.False (true);
        }
 public void TableDoesExist()
 {
     FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase (test_database_name);
     db.DropTableIfExists(dbConstants.table_name);
     _w.output ("here1");
     Assert.False (db.TableExists (dbConstants.table_name));
     _w.output ("here");
     CreateTestDatabase (String.Format ("{0}", dbConstants.ID));
     _w.output ("here");
     try {
         db.InsertData (dbConstants.table_name, new string[3] {
             dbConstants.STATUS,
             dbConstants.XML,
             dbConstants.GUID
         }
         , new object[3] {"boo status", "boo xml", "GUID_A"});
         Assert.True (db.TableExists (dbConstants.table_name));
     } catch (Exception) {
     }
 }
Ejemplo n.º 24
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 CreateFakeDatabaseAndBackup()
        {
            SqlLiteDatabase db =CreateTestDatabase(String.Format ("{0}", dbConstants.GUID));
            db.InsertData (dbConstants.table_name, new string[3] {	dbConstants.STATUS,dbConstants.XML,dbConstants.GUID
            }, new object[3] {"boo status", "boo xml", "GUID_A"});
            db.InsertData (dbConstants.table_name, new string[3] {	dbConstants.STATUS,dbConstants.XML,dbConstants.GUID
            }, new object[3] {"boo status2", "boo xml2", "GUID_A2"});
            db.Dispose();

            db = new FAKE_SqlLiteDatabase (test_database_name);

            try {

                db.DropTableIfExists(dbConstants.table_name+"_b");
            } catch (Exception ex) {
                _w.output (String.Format ("Unable to drop table {0}", ex.ToString()));
            }

            db.CreateTableIfDoesNotExist (dbConstants.table_name+"_b", new string[4]
                                          {dbConstants.ID, dbConstants.GUID, dbConstants.XML,
                dbConstants.STATUS},
            new string[4] {
                "INTEGER",
                "TEXT UNIQUE",
                "LONGTEXT",
                "TEXT"
            }, dbConstants.GUID
            );

            db.InsertData (dbConstants.table_name+"_b", new string[3] {	dbConstants.STATUS,dbConstants.XML,dbConstants.GUID
            }, new object[3] {"boo status", "boo xml", "GUID_B"});

            db.Dispose();
            db = new FAKE_SqlLiteDatabase (test_database_name);

            try {

                db.DropTableIfExists(dbConstants.table_name+"_c");
            } catch (Exception ex) {
                _w.output (String.Format ("Unable to drop table {0}", ex.ToString()));
            }

            db.CreateTableIfDoesNotExist (dbConstants.table_name+"_c", new string[4]
                                          {dbConstants.ID, dbConstants.GUID, dbConstants.XML,
                dbConstants.STATUS},
            new string[4] {
                "INTEGER",
                "TEXT UNIQUE",
                "LONGTEXT",
                "TEXT"
            }, dbConstants.GUID
            );

            db.InsertData (dbConstants.table_name+"_c", new string[3] {	dbConstants.STATUS,dbConstants.XML,dbConstants.GUID
            }, new object[3] {"boo status", "boo xml", "GUID_C"});

            // get rid of full text database too
            db.DropTableIfExists("fulltextsearch");

            //not sure how to set this test up. Force File Write? Then test if file exists?
            // or shoudl this return a Stream?
            string result = db.BackupDatabase();
            _w.output(result.Length);
            _w.output(result);

            db.DropTableIfExists(dbConstants.table_name+"_b");
            db.DropTableIfExists(dbConstants.table_name+"_c");
            db.Dispose();
            Assert.AreEqual(526, result.Length);
            //Assert.False (true);
        }
        public void CreateTableIfDoesNotExist_CreateUnevenTable()
        {
            FAKE_SqlLiteDatabase db = new FAKE_SqlLiteDatabase (test_database_name);

            try {

                db.DropTableIfExists(dbConstants.table_name);
            } catch (Exception ex) {
                _w.output (String.Format ("Unable to drop table {0}", ex.ToString()));
            }

            db.CreateTableIfDoesNotExist (dbConstants.table_name, new string[4]
                                          {dbConstants.ID, dbConstants.GUID, dbConstants.XML,
                dbConstants.STATUS},
            new string[3] {
                "INTEGER",
                "TEXT UNIQUE",
                "LONGTEXT"

            }, dbConstants.GUID
            );
            db.Dispose();
        }
Ejemplo n.º 27
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 ColumnArrayToStringForInserting()
 {
     FAKE_SqlLiteDatabase test = new FAKE_SqlLiteDatabase("nUnitTest");
     string columns = test.TestColumnArrayToStringForInserting(new string[3] {"dog", "cat", "fish"});
     //Console.WriteLine(columns);
     Assert.AreEqual(columns, "dog,cat,fish");
 }