From: <gc...@us...> - 2002-10-29 03:40:16
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Data In directory usw-pr-cvs1:/tmp/cvs-serv24069/DotNetMock/Data Added Files: MockCommand.cs MockDbConnection.cs mockTransaction.cs Log Message: --- NEW FILE: MockCommand.cs --- using System; using System.Data; namespace DotNetMock.Data { /// <summary> /// Summary description for MockCommand. /// </summary> public class MockCommand : MockObject, IDbCommand { private ExpectationString _commandText = new ExpectationString("MockCommand.CommandText"); private ExpectationValue _commandTimeout = new ExpectationValue("MockCommand.CommandTimeout"); private ExpectationValue _commandType = new ExpectationValue("MockCommand.CommandType"); private ExpectationCounter _executeCalls = new ExpectationCounter("MockCommand.ExecuteCalls"); private MockDbConnection _connection = null; private MockTransaction _transaction = null; private MockDataParameterCollection _parameters = null; private UpdateRowSource _updateRowSource = UpdateRowSource.None; public MockCommand() { _parameters = new MockDataParameterCollection(); } public void SetExpectedExecuteCalls(int calls) { _executeCalls.Expected = calls; } public void SetExpectedCommandText(string commandText) { _commandText.Expected = commandText; } public void SetExpectedCommandTimeout(int commandTimeout) { _commandTimeout.Expected = commandTimeout; } public void SetExpectedCommandType(System.Data.CommandType commandType) { _commandType.Expected = commandType; } public void SetExpectedParameter(IDataParameter parameter) { _parameters.AddExpected(parameter); } #region Implementation of IDbCommand #region IDbCommand Methods public void Cancel() { throw new NotImplementedException("Canceling a command is currently not implemented."); } public void Prepare() { throw new NotImplementedException("Canceling a command is currently not implemented."); } public System.Data.IDataReader ExecuteReader(System.Data.CommandBehavior behavior) { _executeCalls.Inc(); return null; } public System.Data.IDataReader ExecuteReader() { _executeCalls.Inc(); return null; } public object ExecuteScalar() { _executeCalls.Inc(); return null; } public int ExecuteNonQuery() { _executeCalls.Inc(); return 0; } public System.Data.IDbDataParameter CreateParameter() { return (IDbDataParameter) new MockDataParameter(); } #endregion #region IDbCommand Properties // TODO: Implement other CommandTypes: StoredProcedure & TableDirect public System.Data.CommandType CommandType { get { return (CommandType)_commandType.Actual; } set { if (!value.Equals(CommandType.Text)) { throw new NotImplementedException("Only CommandType.Text is currently supported."); } _commandType.Actual = value; } } // TODO: Implement actual CommandTimeout usage public int CommandTimeout { get { return (int)_commandTimeout.Actual; } set { if (value != 0) { throw new NotImplementedException("Custom CommandTimeout is not currently supported."); } _commandTimeout.Actual = value; } } public System.Data.IDbConnection Connection { get { return _connection; } set { if (_connection != value) { this.Transaction = null; } _connection = (MockDbConnection)value; } } public System.Data.UpdateRowSource UpdatedRowSource { get { return _updateRowSource; } set { _updateRowSource = value; } } public string CommandText { get { return _commandText.Actual; } set { _commandText.Actual = value; } } public MockDataParameterCollection Parameters { get { return _parameters; } } System.Data.IDataParameterCollection IDbCommand.Parameters { get { return _parameters; } } // TODO: Takes steps to ensure that transaction is compatible with the current connection public System.Data.IDbTransaction Transaction { get { return _transaction; } set { _transaction = (MockTransaction)value; } } #endregion #endregion #region Implementation of IDisposable public void Dispose() { } #endregion } } --- NEW FILE: MockDbConnection.cs --- using System; using System.Data; namespace DotNetMock.Data { /// <summary> /// Summary description for MockDbConnection. /// </summary> public class MockDbConnection : IDbConnection { public MockDbConnection() { // // TODO: Add constructor logic here // } #region Implementation of IDbConnection public void ChangeDatabase(string databaseName) { } public System.Data.IDbTransaction BeginTransaction(System.Data.IsolationLevel il) { return null; } public System.Data.IDbTransaction BeginTransaction() { return null; } public System.Data.IDbCommand CreateCommand() { return null; } public void Open() { } public void Close() { } public System.Data.ConnectionState State { get { return new System.Data.ConnectionState(); } } public string ConnectionString { get { return null; } set { } } public string Database { get { return null; } } public int ConnectionTimeout { get { return 0; } } #endregion #region Implementation of IDisposable public void Dispose() { } #endregion } } --- NEW FILE: mockTransaction.cs --- using System; using System.Data; namespace DotNetMock.Data { /// <summary> /// Summary description for MockTransaction. /// </summary> public class MockTransaction : IDbTransaction { public MockTransaction() { // // TODO: Add constructor logic here // } #region Implementation of IDbTransaction public void Rollback() { } public void Commit() { } public System.Data.IDbConnection Connection { get { return null; } } public System.Data.IsolationLevel IsolationLevel { get { return new System.Data.IsolationLevel(); } } #endregion #region Implementation of IDisposable public void Dispose() { } #endregion } } |