Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Mock Indexed Property with Rhino Mocks?

How can I Mock Indexed Property with Rhino Mocks ?

like image 437
Yoann. B Avatar asked Jan 09 '09 22:01

Yoann. B


1 Answers

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();
like image 160
tvanfosson Avatar answered Oct 14 '22 16:10

tvanfosson