public void UpdateTableTest() { var factory = new MySQLCommandFactory(); var table = Utils.RandomName(); var builder = factory.CreateUpdateBuilder() .Table(factory.GetDbObjectFactory().CreateTable(table)); Assert.Throws(typeof(MySQLNoneSetException), builder.Build); }
public void UpdateTableSetOneColumnTest() { var factory = new MySQLCommandFactory(); var table = Utils.RandomName(); var column = Utils.RandomName(); var builder = factory.CreateUpdateBuilder() .Table(factory.GetDbObjectFactory().CreateTable(table)) .Set(factory.GetDbObjectFactory().CreateColumn(column), factory.GetDbObjectFactory().CreateParameter(column)); Assert.Equal($"UPDATE `{ table }` SET `{ column }` = @{ column }", builder.Build()); }
public void UpdateTableSetWhereTest() { var factory = new MySQLCommandFactory(); var table = Utils.RandomName(); var column_1 = Utils.RandomName(); var column_2 = Utils.RandomName(); var column_3 = Utils.RandomName(); var condition_3 = factory.GetConditionFactory().EqualTo(factory.GetDbObjectFactory().CreateColumn(column_3), factory.GetDbObjectFactory().CreateParameter(column_3)); var builder = factory.CreateUpdateBuilder() .Table(factory.GetDbObjectFactory().CreateTable(table)) .Set(factory.GetDbObjectFactory().CreateColumn(column_1), factory.GetDbObjectFactory().CreateParameter(column_1)) .Set(factory.GetDbObjectFactory().CreateColumn(column_2), factory.GetDbObjectFactory().CreateParameter(column_2)) .Where(condition_3); Assert.Equal($"UPDATE `{ table }` SET `{ column_1 }` = @{ column_1 }, `{ column_2 }` = @{ column_2 } WHERE `{ column_3 }` = @{ column_3 }", builder.Build()); }