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);
        }
Ejemplo n.º 3
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 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 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.º 7
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);
        }
Ejemplo n.º 8
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 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);
        }
        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 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) {
     }
 }
        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();
        }
        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);
        }