public void BuildInsertTest() { var ed = new EntityDescription(typeof(POCOMultiTypeObject)); var provider = new SQLite.SQLiteProviderFactory(); var data = new POCOMultiTypeObject(); var commandBuilder = ed.CommandBuilder; using (var command = commandBuilder.BuildInsertCommand(provider, data, null, Core.SQL.OnConflictOption.Default)) { _output.WriteLine(command.CommandText); Assert.NotNull(command); AssertEx.NotNullOrWhitespace(command.CommandText); Assert.DoesNotContain("ID", command.CommandText); VerifyCommandSyntex(provider, command); } using (var command = commandBuilder.BuildInsertCommand(provider, data, 1, Core.SQL.OnConflictOption.Default)) { _output.WriteLine(command.CommandText); Assert.NotNull(command); AssertEx.NotNullOrWhitespace(command.CommandText); Assert.Contains("ID", command.CommandText); VerifyCommandSyntex(provider, command); } }
public void BuildSelectTest() { var ed = new EntityDescription(typeof(POCOMultiTypeObject)); var provider = new SQLite.SQLiteProviderFactory(); var commandBuilder = ed.CommandBuilder; using (var command = commandBuilder.BuildSelectCommand(provider, null)) { _output.WriteLine(command.CommandText); Assert.NotNull(command); AssertEx.NotNullOrWhitespace(command.CommandText); VerifyCommandSyntex(provider, command); } }
public void NestedSourcesTest() { var provider = new SQLite.SQLiteProviderFactory(); SQLSelectBuilder builder = new SQLSelectBuilder(); builder.Source = new TableOrSubQuery("something", "t1"); builder.ResultColumns.Add("col1"); VerifyCommandSyntex(provider, builder.ToSQL()); var builder2 = new SQLSelectBuilder(); builder2.Source = new TableOrSubQuery(builder, "t2"); builder2.ResultColumns.Add("col2"); VerifyCommandSyntex(provider, builder2.ToSQL()); }
public void FluentInterfaceTest() { base.StartTimer(); SQLSelectBuilder builder = new SQLSelectBuilder(); builder.Source = new TableOrSubQuery("something", "t1"); builder.ResultColumns.Add("col1"); builder.Join("something2", "Using (FKey)", null) .Join("something3", "Using (FKey2)", null) .Where("x > 1") .GroupBy("col1", "col2") .Limit(1, 0); var sql = builder.ToSQL(); Assert.Contains("Join", sql, StringComparison.InvariantCultureIgnoreCase); Assert.Contains("Where", sql, StringComparison.InvariantCultureIgnoreCase); Assert.Contains("Group By", sql, StringComparison.InvariantCultureIgnoreCase); Assert.Contains("Limit", sql, StringComparison.InvariantCultureIgnoreCase); base.EndTimer(); var provider = new SQLite.SQLiteProviderFactory(); VerifyCommandSyntex(provider, builder.ToSQL()); }