public void Update_FROM_2015_01_05() { var filePath = Path.Combine(TestTempPath, "TestUpdate.cruise"); try { using (var setup = new SQLiteDatastore(filePath)) { setup.Execute(CruiseDAL.Tests.SQL.CRUISECREATE_2015_01_05); } using (var datastore = new CruiseDatastore(filePath)) { var updater = new Updater_V2(); updater.Invoking(x => x.Update(datastore)) .Should().NotThrow(); var semVerActual = new Version(datastore.DatabaseVersion); var semVerExpected = new Version("2.7.0"); semVerActual.Major.Should().Be(semVerExpected.Major); semVerActual.Minor.Should().Be(semVerExpected.Minor); ValidateUpdate(datastore); } } finally { if (File.Exists(filePath)) { File.Delete(filePath); } } }
public void Update_FROM_05_30_2013() { var filePath = Path.Combine(TestTempPath, "TestUpdate.cruise"); try { using (var setup = new SQLiteDatastore(filePath)) { setup.Execute(CruiseDAL.Tests.SQL.CRUISECREATE_05_30_2013); } using (var database = new CruiseDatastore(filePath)) { var dataStore = new CruiseDatastore(filePath); var updater = new Updater_V2(); updater.Invoking(x => x.Update(dataStore)).Should().Throw <IncompatibleSchemaException>(); database.CurrentTransaction.Should().BeNull(); } } finally { if (File.Exists(filePath)) { File.Delete(filePath); } } }
public void GetLastInsertRowID() { using (var ds = new SQLiteDatastore()) { using (var connection = ds.OpenConnection()) { connection.ExecuteNonQuery("CREATE TABLE tbl (id INTEGER PRIMARY KEY AUTOINCREMENT, col1 TEXT);", null, null); connection.ExecuteNonQuery("INSERT INTO tbl (col1) VALUES ('something');", null, null); connection.GetLastInsertRowID().Should().Be(1); } } }
public void ListFieldsIntersect() { using (var srcDB = new SQLiteDatastore()) using (var destDB = new SQLiteDatastore()) { using (var srcConn = srcDB.OpenConnection()) using (var destCon = destDB.OpenConnection()) { srcConn.ExecuteNonQuery("CREATE TABLE A ( f1 TEXT, f2 TEXT );"); destCon.ExecuteNonQuery("CREATE TABLE A ( f2 TEXT, f3 TEXT );"); var tables = Updater_V3.ListFieldsIntersect(destCon, srcConn, "A"); tables.Single().Should().Be("\"f2\""); } } }
public void Tables_Test() { using (var datastore = new SQLiteDatastore()) { var createTable = new CreateTable() { TableName = "MyTable", Columns = new[] { new ColumnInfo("col1", SqliteDataType.INTEGER) { AutoIncrement = true, IsPK = true }, new ColumnInfo("col2", SqliteDataType.REAL), new ColumnInfo("col3", SqliteDataType.TEXT), new ColumnInfo("col4", SqliteDataType.BOOLEAN), new ColumnInfo("IgnoreMe"), }, }; datastore.Execute(createTable.ToString()); datastore.Execute("CREATE VIEW MyView AS SELECT * FROM MyTable;"); // inserting will trigger the creation of Sqlite_squince table var insert = new SqlInsertCommand() { TableName = createTable.TableName }; datastore.Equals(insert.ToString()); var schemaInfoProvider = new SqliteDatastoreSchemaInfoProvider(datastore, new[] { "IgnoreMe" }); var tables = schemaInfoProvider.Tables.ToArray(); tables.Should().HaveCount(2); var myTableInfo = tables.First(); myTableInfo.TableName.Should().Be("MyTable"); myTableInfo.PrimaryKeyField.Should().NotBeNull(); myTableInfo.PrimaryKeyField.IsPK.Should().BeTrue(); myTableInfo.Fields.Should().HaveSameCount(createTable.Columns.Where(x => x.Name != "IgnoreMe")); var myViewInfo = tables[1]; myViewInfo.TableName.Should().Be("MyView"); } }
public void Query_Test(bool nulls) { using (var ds = new SQLiteDatastore()) { ds.CreateDatastore(new TestDBBuilder()); var poco = CreateRandomPoco(nulls); ds.Insert(poco); using (var connection = ds.OpenConnection()) { var query = connection.Query <POCOMultiTypeObject>("SELECT * FROM MultiPropTable;"); var results = query.ToArray(); results.Should().HaveCount(1); var result = query.SingleOrDefault(); result.Should().NotBeNull(); result.Should().BeEquivalentTo(poco); } } }