private void TestValue(string table, string idcol, string idval, string column, string value) { var dialect = DatabaseFactory.CreateDialect(); using (var conn = OpenConnection()) { using (var cmd = conn.CreateCommand()) { cmd.CommandText = String.Format("SELECT {0} FROM {1} WHERE {2} = '{3}'", dialect.QuoteIdentifier(column), dialect.QuoteIdentifier(table), dialect.QuoteIdentifier(idcol), idval); string realVal = cmd.ExecuteScalar().SafeToString(); Assert.Equal(value, realVal); } } }
public void IncrementalAnalyse(string engine) { Initialize(engine); var dialect = DatabaseFactory.CreateDialect(); DatabaseInfo dbInfo; DatabaseChangeSet changeSet; dbInfo = FullAnalyse(); changeSet = GetModifications(dbInfo); Assert.Equal(0, changeSet.Items.Count); Thread.Sleep(TimeSpan.FromSeconds(1.5)); RunScript($"alter table {dialect.QuoteIdentifier("Genre")} add testflag int null;"); changeSet = GetModifications(dbInfo); Assert.Equal(1, changeSet.Items.Count); dbInfo = IncrementalAnalysis(dbInfo, changeSet); var genre = dbInfo.FindTableLike("genre"); Assert.Equal(3, genre.ColumnCount); Assert.Equal("testflag", genre.Columns[2].Name); Thread.Sleep(TimeSpan.FromSeconds(1.5)); RunScript($"drop table {dialect.QuoteIdentifier("Genre")};"); dbInfo = GetModificationsAndIncrementalAnalysis(dbInfo); Assert.Equal(4, dbInfo.Tables.Count); var genre2 = dbInfo.FindTableLike("genre"); Assert.Null(genre2); Thread.Sleep(TimeSpan.FromSeconds(1.5)); RunScript($"create table {dialect.QuoteIdentifier("NewTable1")} (testcol int null);"); dbInfo = GetModificationsAndIncrementalAnalysis(dbInfo); Assert.Equal(5, dbInfo.Tables.Count); var newTable1 = dbInfo.FindTableLike("NewTable1"); Assert.NotNull(newTable1); Assert.Equal(1, newTable1.ColumnCount); }
public void CopyDatabaseTest(string engine) { Initialize(engine); var dialect = DatabaseFactory.CreateDialect(); RunScript($"DELETE FROM {dialect.QuoteIdentifier("Album")}"); RunScript($"DELETE FROM {dialect.QuoteIdentifier("Genre")}"); var copyAll = new CopyAllTables { SourceConnection = "sqlite://Data Source=CopyTable/SqliteTestData.locdb", TargetConnection = ProviderConnectionString, DisableConstraints = true, }; copyAll.Run(); AssertIsValue("31", $"select count(*) from {dialect.QuoteIdentifier("Genre")}"); AssertIsValue("10", $"select count(*) from {dialect.QuoteIdentifier("Album")}"); }