From: <gc...@us...> - 2003-01-06 03:51:30
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Data In directory sc8-pr-cvs1:/tmp/cvs-serv25791/DotNetMock/Data Modified Files: MockDataReader.cs Log Message: Index: MockDataReader.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Data/MockDataReader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockDataReader.cs 29 Dec 2002 02:47:39 -0000 1.2 --- MockDataReader.cs 6 Jan 2003 03:51:27 -0000 1.3 *************** *** 6,10 **** { /// <summary> ! /// Summary description for MockDataReader. /// </summary> public class MockDataReader : MockObject, IDataReader --- 6,10 ---- { /// <summary> ! /// This Mock Object implements the IDataReader interface. /// </summary> public class MockDataReader : MockObject, IDataReader *************** *** 24,51 **** --- 24,79 ---- #region Mock Methods + /// <summary> + /// Set records affected count to return from RecordsAffected property + /// </summary> + /// <param name="count">Count to expect</param> public void SetRecordsAffectedCount(int count) { _recordsAffectedCount = count; } + /// <summary> + /// Set number of Close() calls to expect + /// </summary> + /// <param name="calls">Count to expect</param> public void SetExpectedCloseCalls(int calls) { _closeCalls.Expected = calls; } + /// <summary> + /// Sets Schema Table to used + /// </summary> + /// <param name="schemaTable">DataTable to describe columns</param> public void SetSchemaTable(DataTable schemaTable) { _schemaTable = schemaTable; } + /// <summary> + /// Set number of Read() calls to expect + /// </summary> + /// <param name="readCalls">Count to expect</param> public void SetExpectedReadCalls(int readCalls) { _readCalls.Expected = readCalls; } + /// <summary> + /// Set value of IsClosed property + /// </summary> + /// <param name="isClosed">True/False</param> public void SetIsClosedValue(bool isClosed) { _isClosed = isClosed; } + /// <summary> + /// Set data to use for all get calls + /// </summary> + /// <param name="rows">Two-Dimensional array to read data from. Format: [Row,Column]</param> public void SetRows(object[,] rows) { _rows = rows; } + /// <summary> + /// Set exception to throw on any GetXXX() calls + /// </summary> + /// <param name="exception">Exception to throw</param> public void SetGetException(Exception exception) { *************** *** 54,57 **** --- 82,89 ---- #endregion #region Implementation of IDataReader + + /// <summary> + /// Increments the CloseCalls counter & sets IsClosed property to true + /// </summary> public void Close() { *************** *** 59,68 **** _isClosed = true; } ! public System.Data.DataTable GetSchemaTable() { return _schemaTable; } ! public bool NextResult() { --- 91,107 ---- _isClosed = true; } ! /// <summary> ! /// Gets SchemaTable ! /// </summary> ! /// <returns></returns> public System.Data.DataTable GetSchemaTable() { return _schemaTable; } ! /// <summary> ! /// Advances the data reader to the next result, when reading the result batch SQL statements ! /// Currently Not Implemented ! /// </summary> ! /// <returns>True</returns> public bool NextResult() { *************** *** 70,74 **** return true; } ! public bool Read() { --- 109,116 ---- return true; } ! /// <summary> ! /// Increments ReadCalls counter & increments current row of the Data Reader ! /// </summary> ! /// <returns>True if there are more results, False if there are no more records</returns> public bool Read() { *************** *** 81,85 **** return true; } ! public int Depth { --- 123,130 ---- return true; } ! /// <summary> ! /// Gets a value indicating the depth of nesting for the current row. ! /// Currently Not Implemented ! /// </summary> public int Depth { *************** *** 90,94 **** } } ! public bool IsClosed { --- 135,141 ---- } } ! /// <summary> ! /// Gets a value indicating whether the data reader is closed ! /// </summary> public bool IsClosed { *************** *** 98,102 **** } } ! public int RecordsAffected { --- 145,152 ---- } } ! /// <summary> ! /// Gets the number of rows changed, inserted, or deleted by executing the SQL statement ! /// Returns the value set by SetRecordsAffectedCount() ! /// </summary> public int RecordsAffected { *************** *** 113,121 **** #endregion #region Implementation of IDataRecord public int GetInt32(int i) { return Convert.ToInt32(GetValue(i)); } ! public object GetValue(int i) { --- 163,180 ---- #endregion #region Implementation of IDataRecord + /// <summary> + /// Gets the 32-bit signed integer value of the specified field + /// </summary> + /// <param name="i">Index of the field to find</param> + /// <returns>The 32-bit signed integer value of the specified field.</returns> public int GetInt32(int i) { return Convert.ToInt32(GetValue(i)); } ! /// <summary> ! /// Returns the value of the specified field ! /// </summary> ! /// <param name="i">Index of the field to find</param> ! /// <returns>The Object which will contain the field value upon return.</returns> public object GetValue(int i) { *************** *** 126,130 **** return _rows[_currentRow, i - 1]; } ! public bool IsDBNull(int i) { --- 185,193 ---- return _rows[_currentRow, i - 1]; } ! /// <summary> ! /// Return whether the specified field is set to null ! /// </summary> ! /// <param name="i">Index of the field to find</param> ! /// <returns>true if the specified field is set to null, otherwise false.</returns> public bool IsDBNull(int i) { *************** *** 136,140 **** return result; } ! public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { --- 199,211 ---- return result; } ! /// <summary> ! /// Reads a stream of bytes from the specified column offset into the buffer as an array, starting at the given buffer offset. Currently Not Implemented ! /// </summary> ! /// <param name="i">The zero-based column ordinal. </param> ! /// <param name="fieldOffset">The index within the field from which to begin the read operation. </param> ! /// <param name="buffer">The buffer into which to read the stream of bytes.</param> ! /// <param name="bufferoffset">The index for buffer to begin the read operation.</param> ! /// <param name="length">The number of bytes to read.</param> ! /// <returns>The actual number of bytes read.</returns> public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { *************** *** 142,151 **** return 0; } ! public byte GetByte(int i) { return Convert.ToByte(GetValue(i)); } ! public System.Type GetFieldType(int i) { --- 213,230 ---- return 0; } ! /// <summary> ! /// Gets the 8-bit unsigned integer value of the specified column. ! /// </summary> ! /// <param name="i">The zero-based column ordinal.</param> ! /// <returns>The 8-bit unsigned integer value of the specified column.</returns> public byte GetByte(int i) { return Convert.ToByte(GetValue(i)); } ! /// <summary> ! /// Gets the Type information corresponding to the type of Object that would be returned from GetValue. Currently Not Implemented ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The Type information corresponding to the type of Object that would be returned from GetValue.</returns> public System.Type GetFieldType(int i) { *************** *** 153,162 **** return null; } ! public decimal GetDecimal(int i) { return Convert.ToDecimal(GetValue(i)); } ! public int GetValues(object[] values) { --- 232,249 ---- return null; } ! /// <summary> ! /// Gets the fixed-position numeric value of the specified field. ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The fixed-position numeric value of the specified field.</returns> public decimal GetDecimal(int i) { return Convert.ToDecimal(GetValue(i)); } ! /// <summary> ! /// Gets all the attribute fields in the collection for the current record. ! /// </summary> ! /// <param name="values">An array of Object to copy the attribute fields into. </param> ! /// <returns>The number of instances of Object in the array.</returns> public int GetValues(object[] values) { *************** *** 164,168 **** return 0; } ! public string GetName(int i) { --- 251,259 ---- return 0; } ! /// <summary> ! /// Gets the name for the field to find. Currently Not Implemented ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The name of the field or the empty string (""), if there is no value to return.</returns> public string GetName(int i) { *************** *** 170,189 **** return null; } ! public long GetInt64(int i) { return Convert.ToInt64(GetValue(i)); } ! public double GetDouble(int i) { return Convert.ToDouble(GetValue(i)); } ! public bool GetBoolean(int i) { return Convert.ToBoolean(GetValue(i)); } ! public System.Guid GetGuid(int i) { --- 261,296 ---- return null; } ! /// <summary> ! /// Gets the 64-bit signed integer value of the specified field. ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The 64-bit signed integer value of the specified field.</returns> public long GetInt64(int i) { return Convert.ToInt64(GetValue(i)); } ! /// <summary> ! /// Gets the double-precision floating point number of the specified field. ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The double-precision floating point number of the specified field.</returns> public double GetDouble(int i) { return Convert.ToDouble(GetValue(i)); } ! /// <summary> ! /// Gets the value of the specified column as a Boolean. ! /// </summary> ! /// <param name="i">The zero-based column ordinal. </param> ! /// <returns>The value of the column.</returns> public bool GetBoolean(int i) { return Convert.ToBoolean(GetValue(i)); } ! /// <summary> ! /// Returns the guid value of the specified field. Currently Not Implemented ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The guid value of the specified field.</returns> public System.Guid GetGuid(int i) { *************** *** 191,200 **** return new System.Guid(); } ! public System.DateTime GetDateTime(int i) { return Convert.ToDateTime(GetValue(i)); } ! public int GetOrdinal(string name) { --- 298,315 ---- return new System.Guid(); } ! /// <summary> ! /// Gets the date and time data value of the spcified field. ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The date and time data value of the spcified field.</returns> public System.DateTime GetDateTime(int i) { return Convert.ToDateTime(GetValue(i)); } ! /// <summary> ! /// Return the index of the named field. Currently Not Implemented ! /// </summary> ! /// <param name="name">The name of the field to find. </param> ! /// <returns>The index of the named field.</returns> public int GetOrdinal(string name) { *************** *** 202,206 **** return 0; } ! public string GetDataTypeName(int i) { --- 317,325 ---- return 0; } ! /// <summary> ! /// Gets the data type information for the specified field. Currently Not Implemented ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The data type information for the specified field.</returns> public string GetDataTypeName(int i) { *************** *** 208,218 **** return null; } ! public float GetFloat(int i) ! { this.NotImplemented("MockDataReader.GetFloat"); return 0; } ! public System.Data.IDataReader GetData(int i) { --- 327,345 ---- return null; } ! /// <summary> ! /// Gets the single-precision floating point number of the specified field. Currently Not Implemented ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The single-precision floating point number of the specified field.</returns> public float GetFloat(int i) ! { this.NotImplemented("MockDataReader.GetFloat"); return 0; } ! /// <summary> ! /// Gets an IDataReader to be used when the field points to more remote structured data. Currently Not Implemented ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>An IDataReader to be used when the field points to more remote structured data.</returns> public System.Data.IDataReader GetData(int i) { *************** *** 220,224 **** return null; } ! public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) { --- 347,359 ---- return null; } ! /// <summary> ! /// Reads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset. ! /// </summary> ! /// <param name="i">The zero-based column ordinal. </param> ! /// <param name="fieldoffset">The index within the row from which to begin the read operation. </param> ! /// <param name="buffer">The buffer into which to read the stream of bytes. </param> ! /// <param name="bufferoffset">The index for buffer to begin the read operation. </param> ! /// <param name="length">The number of bytes to read. </param> ! /// <returns></returns> public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) { *************** *** 226,245 **** return 0; } ! public string GetString(int i) { return Convert.ToString(GetValue(i)); } ! public char GetChar(int i) { return Convert.ToChar(GetValue(i)); } ! public short GetInt16(int i) { return Convert.ToInt16(GetValue(i)); } ! public object this[string name] { --- 361,394 ---- return 0; } ! /// <summary> ! /// Gets the string value of the specified field. ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The string value of the specified field.</returns> public string GetString(int i) { return Convert.ToString(GetValue(i)); } ! /// <summary> ! /// Gets the character value of the specified column. ! /// </summary> ! /// <param name="i">The zero-based column ordinal. </param> ! /// <returns>The character value of the specified column.</returns> public char GetChar(int i) { return Convert.ToChar(GetValue(i)); } ! /// <summary> ! /// Gets the 16-bit signed integer value of the specified field. ! /// </summary> ! /// <param name="i">The index of the field to find. </param> ! /// <returns>The 16-bit signed integer value of the specified field.</returns> public short GetInt16(int i) { return Convert.ToInt16(GetValue(i)); } ! /// <summary> ! /// Gets the specified column by name. ! /// </summary> public object this[string name] { *************** *** 249,253 **** } } ! public object this[int i] { --- 398,404 ---- } } ! /// <summary> ! /// Gets the specified column by index ! /// </summary> public object this[int i] { *************** *** 257,261 **** } } ! public int FieldCount { --- 408,414 ---- } } ! /// <summary> ! /// Gets the number of columns in the current row. Currently Not Implemented ! /// </summary> public int FieldCount { *************** *** 268,271 **** --- 421,429 ---- #endregion #endregion + /// <summary> + /// Finds the index of the given name + /// </summary> + /// <param name="name">Name of the column to find</param> + /// <returns>Column index of the given name</returns> private int findColumnIndexForName(string name) { |