我如何用Rhino Mocks模拟索引属性?
我假设你的意思是使用的财产 this[]
var mockClass = MockRepository.GenerateMock(); 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();