// -------- Constructor -------- /// <summary> /// Constructor /// </summary> /// <param name="databaseLocation">The database location.</param> public KarmaBotDatabase(string databaseLocation) { ISQLitePlatform platform; if (Environment.OSVersion.Platform.Equals(PlatformID.Win32NT)) { Console.WriteLine("KarmaBot> Using Win32 Sqlite Platform"); platform = new SQLite.Net.Platform.Win32.SQLitePlatformWin32(); } else { // Requires the SQLite.so (shared object) files to be installed. Console.WriteLine("KarmaBot> Using Generic Sqlite Platform"); platform = new SQLite.Net.Platform.Generic.SQLitePlatformGeneric(); } this.sqlite = new SQLiteConnection( platform, databaseLocation, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite ); this.sqlite.CreateTable <IrcUser>(); this.sqlite.Commit(); this.ircUserCache = new Dictionary <string, IrcUser>(); }
public void TestBoolean() { var sqlite3Platform = new SQLitePlatformTest(); string tmpFile = TestPath.GetTempFileName(); var db = new DbAcs(sqlite3Platform, tmpFile); db.buildTable(); for (int i = 0; i < 10; i++) { db.Insert(new VO { Flag = (i%3 == 0), Text = String.Format("VO{0}", i) }); } // count vo which flag is true Assert.AreEqual(4, db.CountWithFlag(true)); Assert.AreEqual(6, db.CountWithFlag(false)); Debug.WriteLine("VO with true flag:"); foreach (VO vo in db.Query<VO>("SELECT * FROM VO Where Flag = ?", true)) { Debug.WriteLine(vo.ToString()); } Debug.WriteLine("VO with false flag:"); foreach (VO vo in db.Query<VO>("SELECT * FROM VO Where Flag = ?", false)) { Debug.WriteLine(vo.ToString()); } }
public void TestBoolean() { var sqlite3Platform = new SQLitePlatformTest(); string tmpFile = TestPath.GetTempFileName(); var db = new DbAcs(sqlite3Platform, tmpFile); db.buildTable(); for (int i = 0; i < 10; i++) { db.Insert(new VO { Flag = (i % 3 == 0), Text = String.Format("VO{0}", i) }); } // count vo which flag is true Assert.AreEqual(4, db.CountWithFlag(true)); Assert.AreEqual(6, db.CountWithFlag(false)); Debug.WriteLine("VO with true flag:"); foreach (VO vo in db.Query <VO>("SELECT * FROM VO Where Flag = ?", true)) { Debug.WriteLine(vo.ToString()); } Debug.WriteLine("VO with false flag:"); foreach (VO vo in db.Query <VO>("SELECT * FROM VO Where Flag = ?", false)) { Debug.WriteLine(vo.ToString()); } }
protected SQLiteConnection GetConnection() { var platform = new SQLite.Net.Platform.Win32.SQLitePlatformWin32(); var connection = new SQLiteConnection(platform, "DataBase.db"); connection.BusyTimeout = new TimeSpan(0, 0, 3); return(connection); }
public static void Init(TestContext context) { var platform = new SQLite.Net.Platform.Win32.SQLitePlatformWin32(); _connection = new SQLiteConnection(platform, "ampstore.db"); AMPClient.Configure(bootstrapper => { bootstrapper.RegisterLocalStore(() => new AMPSQLiteStore(_connection)); bootstrapper.TrackingID = "UA-69403343-1"; bootstrapper.ClientID = Guid.NewGuid().ToString(); bootstrapper.GlobalUserID = "dkomar"; }); }
public void SetUp() { _sqlite3Platform = new SQLitePlatformTest(); }
static void Main(string[] args) { // go direct to the db ISQLitePlatform Platform = new SQLite.Net.Platform.Win32.SQLitePlatformWin32(); var connection = new SQLiteConnection(Platform, Constants.ActiveStoreageDBConnection); string[] sites = Destinations.Sites.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); List <Destination> toInsert = new List <Destination>(); bool errors = false; if (sites.Length > 0) { foreach (var s in sites) { Console.WriteLine(s); string[] siteInfo = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (siteInfo.Length == 2) { Destination d = new Destination() { DestinationDesc = siteInfo[0], RequiresDetail = bool.Parse(siteInfo[1]), Notes = string.Empty }; Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("Inserting destination: {0}", s); toInsert.Add(d); //connection.Insert(d); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Unable to parse site info from string: {0}", s); Console.ForegroundColor = ConsoleColor.White; errors = true; } } } if (errors) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Errors occured, please review and fix, update failed"); Console.ForegroundColor = ConsoleColor.White; } else { // make sure the table exists, then clear all the existing items connection.CreateTable <Destination>(CreateFlags.AutoIncPK); connection.DeleteAll <Destination>(); foreach (var site in toInsert) { connection.Insert(site); } } }
public void TestFixtureSetUp() { _sqlite3Platform = new SQLitePlatformTest(); _sqliteConnectionPool = new SQLiteConnectionPool(_sqlite3Platform); }