Пример #1
0
        private static void PopulateSQLite(SQLiteDba sqliteDba)
        {
            tblTestRow [] rows = new tblTestRow [] {
                new tblTestRow(1, "Number one."),
                new tblTestRow(2, "Number two."),
                new tblTestRow(3, "Number three.")
            };

            sqliteDba.ExecuteSqlCommand(_sqlCreateTable);

            foreach(tblTestRow row in rows) {
                DbParameter[] parameters = new DbParameter [] {
                    new SQLiteParameter("@id", row.Id),
                    new SQLiteParameter("@description", row.Description)
                };
                sqliteDba.ExecuteSqlCommand(_sqlInsertRow, parameters);
            }
            string [] columnData = sqliteDba.GetColumnAsStringArray("tblTest", "description");
            Assert.AreEqual(columnData.Length, 3, "Inserted 3 rows and retrieved {0}", new object[] {columnData.Length});
        }
Пример #2
0
        public void TestSQLite()
        {
            string fileName = Path.Combine(_tempDirectory, _tempFilePrefix + ".sqlite");
            try {
                CreateSQLite(fileName);

                SQLiteDba sqliteDba = new SQLiteDba();
                sqliteDba.Connect(fileName);

                PopulateSQLite(sqliteDba);

                sqliteDba.ExecuteSqlCommand(_sqlDropTable);

                sqliteDba.Disconnect();
            }
            finally
            {
                File.Delete(fileName);
                Assert.IsFalse(File.Exists(fileName), "Failed to delete " + fileName);
            }
        }