views:

301

answers:

1

How can I Mock Indexed Property with Rhino Mocks ?

+5  A: 

I'm assuming you mean a property using this[]

  var mockClass = MockRepository.GenerateMock<MockClass>();

  mockClass.Expect( m => m["key"] ).Return( "value" );  // return a value
  mockClass.Expect( m => m["key2"] = "value2" );  // set a value

  ... some test in here using something that depends on mockClass...


  mockClass.VerifyAllExpectations();
tvanfosson
Ok Thanks a lot ! :)
Yoann. B