如何与Rhino Mocks模拟索引属性(property)?

最佳答案

我假设您的意思是使用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();

关于c# - 如何用犀牛 mock 索引属性(property)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/429933/

10-12 16:24