如何使用Rhino Mocks模拟索引属性?
答案 0 :(得分: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();