Unexpected behaviour from RhinoMocks:
var mocks = new MockRepository();
var connection = mocks.Stub<OracleConnection>();
var command = mocks.Stub<OracleCommand>();
using (mocks.Record()) {
connection.Expect(x => x.CreateCommand()).Return(command);
command.Expect(x => x.ExecuteNonQuery());
command.Expect(x => x.Dispose());
}
using (mocks.Playback()) {
using(var command = connection.CreateCommand()) {
...
command.ExecuteNonQuery();
}
}
Allthough I have expected the Dispose()-Call, it is not recognized and I am getting the following message:
Rhino.Mocks.Exceptions.ExpectationViolationException: IDisposable.Dispose(); Expected #0, Actual #1.
If I rewirte the code without the using-clause everything is fine:
OracleCommand cmd = null;
try {
command = connection.CreateCommand();
...
command.ExecuteNonQuery();
}
finally {
if (command != null)
command.Dispose();
}
Any ideas on this issue?
Regards, MacX