14

如何使用 Rhino Mocks 模拟索引属性?

4

1 回答 1

22

我假设您的意思是使用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();
于 2009-01-09T22:18:18.437 回答