public DbDataReader GetData(int i) { StubDataReader reader = new StubDataReader(this._stubResultSets); reader._currentResultsetIndex = i; return(reader); }
/// <summary> /// Creates a DataMapper that can be used to test queries. /// </summary> /// <param name="rs">The stubbed record set.</param> /// <returns>Returns a StubDataMapper.</returns> public static IDataMapper CreateForQuery(StubResultSet rs) { StubDataReader reader = new StubDataReader(rs); var parameters = MockRepository.GenerateMock<DbParameterCollection>(); parameters.Expect(p => p.Add(null)).Return(1).IgnoreArguments(); var command = MockRepository.GenerateMock<DbCommand>(); command.Expect(c => c.ExecuteReader()).Return(reader); command.Expect(c => c.Parameters).Return(parameters); command.Expect(c => c.CreateParameter()).Return(new System.Data.SqlClient.SqlParameter()).Repeat.Any(); command.Stub(c => c.CommandText); var connection = MockRepository.GenerateMock<DbConnection>(); connection.Expect(c => c.CreateCommand()).Return(command); command.Expect(c => c.Connection).Return(connection); DbProviderFactory dbFactory = MockRepository.GenerateMock<DbProviderFactory>(); dbFactory.Expect(f => f.CreateConnection()).Return(connection); return new StubDataMapper(dbFactory, command, connection, parameters); }
public DbDataReader GetData(int i) { StubDataReader reader = new StubDataReader(this._stubResultSets); reader._currentResultsetIndex = i; return reader; }