Hi as I am new to using RM and have following, probably simple
question but haven't found appropriate answer yet.

I'd like to use mock object (mocked dbdatareader) multiple times
within single test class.

Within test class I am creating mock of data reader this way:
private DbDataReader GetReaderMock()
        {
DbDataReader readerMock = MockRepository.GenerateStub<DbDataReader>();
            RhinoMocksExtensions.Stub(readerMock,
delegate(DbDataReader x) { x.Read(); })
                .Return(true)
                .Repeat.Times(5);

            RhinoMocksExtensions.Stub(readerMock,
delegate(DbDataReader x) { x.Read(); }).Return(false);

            RhinoMocksExtensions.Stub(readerMock,
delegate(DbDataReader x)
                                                  {
                                                      object o =
x["column1"];
                                                  }).Return(57);
            RhinoMocksExtensions.Stub(readerMock,
delegate(DbDataReader x)
                                                  {
                                                      object o =
x["column2"];
                                                  }).Return(102);
            RhinoMocksExtensions.Stub(readerMock,
delegate(DbDataReader x)
                                                  {
                                                      object o =
x["column3"];
                                                  }).Return(7);
            return readerMock;
}

Now, as I don't have much experience with this I've achieved
reusability only by calling this method in setup method of every test
(thus, recreating mock reader before each test).

What would be correct approach for creating such reusable mock object?
I thought that calling Replay on readerMock is appropriate...but no
luck with that.

Any suggestion/advice/comment is welcome.

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to