public void DeriveParameters() { using (HsqlConnection connection = NewConnection()) using (HsqlCommand testSubject = connection.CreateCommand()) { testSubject.CommandText = "call 1 + cast(? as integer)"; testSubject.CommandType = global::System.Data.CommandType.StoredProcedure; testSubject.DeriveParameters(); HsqlParameterCollection parameters = testSubject.Parameters; Assert.AreEqual(1, parameters.Count); HsqlParameter parameter = parameters[0]; Assert.AreEqual(DbType.Int32, parameter.DbType); Assert.AreEqual(ParameterDirection.Input, parameter.Direction); Assert.AreEqual(false, parameter.IsNullable); Assert.AreEqual(0, parameter.Offset); Assert.AreEqual("@p1", parameter.ParameterName); Assert.AreEqual(10, parameter.Precision); Assert.AreEqual(HsqlProviderType.Integer, parameter.ProviderType); Assert.AreEqual(0, parameter.Scale); Assert.AreEqual(4, parameter.Size); Assert.AreEqual("", parameter.SourceColumn); Assert.AreEqual(false, parameter.SourceColumnNullMapping); Assert.AreEqual(DataRowVersion.Default, parameter.SourceVersion); Assert.AreEqual("NULL", parameter.ToSqlLiteral()); Assert.AreEqual(null, parameter.Value); } }
new public void ToString() { HsqlParameter testSubject = new HsqlParameter(); string actual = testSubject.ToString(); Assert.Fail("TODO"); }
public void Clone() { HsqlParameter testSubject = NewTestSubject(); HsqlParameter actual = testSubject.Clone(); Assert.Fail("TODO"); }
public void ResetDbType() { HsqlParameter testSubject = NewTestSubject(); testSubject.ResetDbType(); Assert.Fail("TODO"); }
public new void ToString() { HsqlParameter testSubject = new HsqlParameter(); string actual = testSubject.ToString(); Assert.Fail("TODO"); }
public void CreateParameter() { using (HsqlConnection connection = NewConnection()) using (HsqlCommand testSubject = connection.CreateCommand()) { HsqlParameter parameter = testSubject.CreateParameter(); IDbParmeter idbparameter = (testSubject as IDbCommand).CreateParameter(); DbParameter dbparameter = (testSubject as DbCommand).CreateParameter(); } }
public void IndexOf() { HsqlParameterCollection testSubject = NewTestSubject(); HsqlParameter value = new HsqlParameter("foo", "bar"); int expectedValueIndex = testSubject.Add((object)value); int actualValueIndex = testSubject.IndexOf(value); Assert.AreEqual(expectedValueIndex, actualValueIndex); Assert.AreEqual(testSubject.IndexOf(value.ParameterName), testSubject.IndexOf(value)); Assert.Fail("TODO"); }
public void Add() { HsqlParameterCollection testSubject = NewTestSubject(); object ovalue = new HsqlParameter(); int parameterIndex = testSubject.Add(ovalue); HsqlParameter pvalue = new HsqlParameter(); HsqlParameter rvalue = testSubject.Add(pvalue); Assert.Fail("TODO"); }
public void AddRange() { HsqlParameterCollection testSubject = NewTestSubject(); object[] avalues = new object[] { new HsqlParameter() }; testSubject.AddRange(avalues); HsqlParameter[] pvalues = new HsqlParameter[] { new HsqlParameter() }; testSubject.AddRange(pvalues); Assert.Fail("TODO"); }
public void Contains() { HsqlParameterCollection testSubject = NewTestSubject(); object value = new HsqlParameter("foo", "bar"); testSubject.Add(value); bool containsValue = testSubject.Contains(value); string parameterName = "foo"; bool containsNamedParameter = testSubject.Contains(parameterName); Assert.Fail("TODO"); }
public void CopyTo() { HsqlParameterCollection testSubject = NewTestSubject(); object[] array = new object[testSubject.Count]; testSubject.CopyTo(array, 0); HsqlParameter[] paramArray = new HsqlParameter[testSubject.Count]; ICollection <HsqlParameter> parameters = testSubject as ICollection <HsqlParameter>; parameters.CopyTo(paramArray, 0); }
public void Remove() { HsqlParameterCollection testSubject = NewTestSubject(); HsqlParameter parameter = new HsqlParameter("foo", "bar"); testSubject.Add(parameter); Assert.AreEqual(1, testSubject.Count); testSubject.Remove(parameter); Assert.AreEqual(0, testSubject.Count); Assert.Fail("TODO"); }
public void Clone() { using (HsqlConnection connection = NewConnection()) using (HsqlTransaction transaction = connection.BeginTransaction()) using (HsqlCommand originalCommand = connection.CreateCommand()) { originalCommand.CommandType = global::System.Data.CommandType.StoredProcedure; originalCommand.CommandText = "call 1 + cast(? as integer)"; originalCommand.DeriveParameters(); HsqlCommand clonedCommand = originalCommand.Clone(); Assert.AreEqual(originalCommand.CommandText, clonedCommand.CommandText); Assert.AreEqual(originalCommand.CommandTimeout, clonedCommand.CommandTimeout); Assert.AreEqual(originalCommand.CommandType, clonedCommand.CommandType); Assert.AreSame(connection, clonedCommand.Connection); Assert.AreEqual(originalCommand.DesignTimeVisible, clonedCommand.DesignTimeVisible); Assert.AreEqual(originalCommand.Parameters.Count, clonedCommand.Parameters.Count); for (int i = 0; i < originalCommand.Parameters.Count; i++) { HsqlParameter orignalCommandParameter = originalCommand.Parameters[i]; HsqlParameter clonedCommandParameter = clonedCommand.Parameters[i]; Assert.AreEqual(orignalCommandParameter.DbType, clonedCommandParameter.DbType); Assert.AreEqual(orignalCommandParameter.Direction, clonedCommandParameter.Direction); Assert.AreEqual(orignalCommandParameter.IsNullable, clonedCommandParameter.IsNullable); Assert.AreEqual(orignalCommandParameter.Offset, clonedCommandParameter.Offset); Assert.AreEqual(orignalCommandParameter.ParameterName, clonedCommandParameter.ParameterName); Assert.AreEqual(orignalCommandParameter.Precision, clonedCommandParameter.Precision); Assert.AreEqual(orignalCommandParameter.ProviderType, clonedCommandParameter.ProviderType); Assert.AreEqual(orignalCommandParameter.Scale, clonedCommandParameter.Scale); Assert.AreEqual(orignalCommandParameter.Size, clonedCommandParameter.Size); Assert.AreEqual(orignalCommandParameter.SourceColumn, clonedCommandParameter.SourceColumn); Assert.AreEqual(orignalCommandParameter.SourceColumnNullMapping, clonedCommandParameter.SourceColumnNullMapping); Assert.AreEqual(orignalCommandParameter.SourceVersion, clonedCommandParameter.SourceVersion); Assert.AreEqual(orignalCommandParameter.ToSqlLiteral(), clonedCommandParameter.ToSqlLiteral()); Assert.AreEqual(orignalCommandParameter.Value, clonedCommandParameter.Value); } Assert.AreSame(originalCommand.Transaction, clonedCommand.Transaction); Assert.AreEqual(originalCommand.UpdatedRowSource, clonedCommand.UpdatedRowSource); } }
internal void Append(HsqlCommand command) { HsqlParameterCollection parameters; if (command == null) { throw new ArgumentNullException( "command"); } string commandText = command.CommandText; if (string.IsNullOrEmpty(commandText)) { throw new ArgumentException("Command Text Required", "command.CommandText"); } CommandType commandType = command.CommandType; switch (commandType) { case CommandType.Text: case CommandType.StoredProcedure: { parameters = null; HsqlParameterCollection commandParameters = command.Parameters; int parameterCount = commandParameters.Count; if (parameterCount > 0) { parameters = new HsqlParameterCollection(); for (int i = 0; i < parameterCount; i++) { HsqlParameter destination = commandParameters[i].Clone(); parameters.Add(destination); if (!IdentifierParser.IsMatch(destination .ParameterName)) { throw new HsqlDataSourceException( "Bad Parameter Name", org.hsqldb.Trace.GENERAL_ERROR, "S1000"); } } } break; } case CommandType.TableDirect: { throw new ArgumentOutOfRangeException( "command.CommandType", commandType, "Enumeration Value Not Supported."); } default: { throw new ArgumentOutOfRangeException( "command.CommandType", commandType, "Invalid Enumeration Value"); } } int returnParameterIndex = -1; for (int j = 0; j < parameters.Count; j++) { if (ParameterDirection.ReturnValue == parameters[j].Direction) { returnParameterIndex = j; break; } } LocalCommand item = new LocalCommand( commandText, parameters, returnParameterIndex, commandType); m_commandList.Add(item); }
public void CopyTo() { HsqlParameterCollection testSubject = NewTestSubject(); object[] array = new object[testSubject.Count]; testSubject.CopyTo(array, 0); HsqlParameter[] paramArray = new HsqlParameter[testSubject.Count]; ICollection<HsqlParameter> parameters = testSubject as ICollection<HsqlParameter>; parameters.CopyTo(paramArray,0); }
/// <summary> /// Appends the statically-bound representation of this /// list to the given <c>StringBuilder</c>. /// </summary> /// <param name="sb"> /// The <c>StringBuilder</c> to which to append. /// </param> /// <param name="parameters">The parameters to bind.</param> /// <param name="strict"> /// When <c>true</c>, an exception is raised if there exist /// any unbound named parameter or parameter marker tokens. /// </param> /// <returns> /// The <c>StringBuilder</c> to which has been appended /// the statically-bound representation of this list. /// </returns> /// <remarks> /// The statically-bound representation of this list is the charater /// sequence representation in which each <c>NamedParameter</c> <c>Token</c> /// is replaced by an SQL literal character sequence representating the /// <c>Value</c> property of the matching <c>HsqlParameter</c> /// object from the given <c>parameters</c> collection. /// </remarks> public StringBuilder AppendStaticallyBoundForm(StringBuilder sb, HsqlParameterCollection parameters, bool strict) { if (ParameterCount == 0) { return(AppendNormalizedForm(sb)); } else if (strict && ParameterMarkerCount > 0) { throw new HsqlDataSourceException( "Cannot statically bind parameter markers" + " ('?' tokens) by name."); //NOI18N } if (sb == null) { // Not perfectly accurate preallocation, but better than nothing. sb = new StringBuilder(m_normalizedCapacity); } else { sb.EnsureCapacity(sb.Length + m_normalizedCapacity); } int count = m_list.Count; for (int i = 0; i < count; i++) { Token token = m_list[i]; string value = token.Value; SqlTokenType type = token.Type; if (i > 0 && (Token.ValueFor.COMMA != value)) { sb.Append(' '); } if (type == SqlTokenType.NamedParameter) { int index = parameters.IndexOf(value); if (index >= 0) { HsqlParameter parameter = (HsqlParameter)parameters[index]; sb.Append(parameter.ToSqlLiteral()); } else if (strict) { throw new HsqlDataSourceException( "No binding for named parameter: " + value); // NOI18N } else // (index < 0 && strict == false) { // Effectively a named parameter pass through... // may be that we want to do multi-pass binding. sb.Append(value); } } // Currently, this never happens, due to the // (strict && ParameterMarkerCount > 0) check above. // stubbed in as a reminder that we might have to deal // with this case differently, for instance using // a bind-by-parameter-ordinal policy. else if (strict && (Token.ValueFor.QUESTION == value)) { throw new HsqlDataSourceException( "No binding for parameter marker: " + value); //NOI18N } else { sb.Append(value); } } return(sb); }