예제 #1
0
        protected IDataMapper CreateDB_ForQuery(StubResultSet rs)
        {
            StubDataReader reader = new StubDataReader(rs);

            _parameters = MockRepository.GenerateMock <DbParameterCollection>();
            _parameters.Expect(p => p.Add(null)).Return(1).IgnoreArguments();

            _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);

            _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 DataMapper(dbFactory, "connString..."));
        }
예제 #2
0
        public DbDataReader GetData(int i)
        {
            StubDataReader reader = new StubDataReader(this._stubResultSets);

            reader._currentResultsetIndex = i;
            return(reader);
        }
예제 #3
0
        protected IDataMapper CreateDB_ForQuery(StubResultSet rs)
        {
            StubDataReader reader = new StubDataReader(rs);

            _parameters = MockRepository.GenerateMock<DbParameterCollection>();
            _parameters.Expect(p => p.Add(null)).Return(1).IgnoreArguments();

            _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);

            _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 DataMapper(dbFactory, "connString...");
        }
예제 #4
0
 public DbDataReader GetData(int i)
 {
     StubDataReader reader = new StubDataReader(this._stubResultSets);
     reader._currentResultsetIndex = i;
     return reader;
 }