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 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"); } }