I'm trying to mock a SqlDataReader
SqlDataReader reader = mocks.CreateMock<SqlDataReader>();
Expect.Call(reader.Read()).Return(true).Repeat.Times(1);
Expect.Call(reader.Read()).Return(false);
Expect.Call(reader.HasRows).Return(true);
Expect.Call(reader.Dispose);
Expect.Call(reader["City"]).Return("Boise");
Expect.Call(reader["State"]).Return("State");
Expect.Call(reader["LAT"]).Return(100);
Expect.Call(reader["LON"]).Return(-100);
mocks.ReplayAll();
but I keep getting a Rhino.Mocks.Exceptions.ExpectationViolationException: IDisposable.Dispose(); Expected #0, Actual #1 error in my method
using (reader)
{
if (reader.HasRows)
{
while (reader.Read())
{
CityState myCity = new CityState
{
City = reader["City"].ToString(),
State = reader["State"].ToString(),
Lat = Convert.ToInt32(reader["LAT"]),
Lon = Convert.ToInt32(reader["LON"])
};
myCities.Add(myCity);
}
}
}
am I missing something?