public void QuestionMarksAreReplacedWithOracleCompatiblePlaceholders() { var descriptor = (OdpDescriptor)ConnectionDescriptor.LoadFromConfig( new Config("..\\..\\Tests\\dao.config", "DaoConfig"), "NonSpatialDao"); const string initialSql = "SELECT * FROM TABLE WHERE COL = ? AND COL2 = ?"; const string expectedSql = "SELECT * FROM TABLE WHERE COL = :param0 AND COL2 = :param1"; var command = new TestCommand(initialSql); descriptor.SetParametersOnCommand(command, new [] {"foo", "bar"}); Assert.AreEqual(expectedSql, command.CommandText); Assert.AreEqual(2, command.Parameters.Count, "Expected 2 parameters to be created on the command."); AssertDbParameter(command.Parameters[0], "param0", "foo"); AssertDbParameter(command.Parameters[1], "param1", "bar"); }
public void FindParametersThrowsIfACommandIsTableDirect() { var cmd = new TestCommand { CommandText = "SomeTable", CommandType = CommandType.TableDirect }; AssertParameterPlaceholders(cmd); }
public void FindParametersThrowsIfACommandisStoredProcedure() { var cmd = new TestCommand { CommandText = "spSomeProc", CommandType = CommandType.StoredProcedure }; AssertParameterPlaceholders(cmd); }
public void FindParameterPlaceholdersInACommand() { var cmd = new TestCommand("SELECT NAME FROM TABLE WHERE \"COL?\" = ?"); AssertParameterPlaceholders(cmd, cmd.CommandText.Length - 1); }