var fakeRoles = MockRepository.GenerateStub < IDictionary<PermissionLevel, string>>();
fakeRoles[PermissionLevel.Developer] = "Developer";
fakeRoles[PermissionLevel.DeveloperManager] = "Developer Manager";
This is specific to what that 开发者_如何转开发method happens to be calling, and is irrelevant for the sake of my unit test. I'd rather do this:
fakeRoles.Stub(r => r[PermissionLevel.None]).IgnoreArguments().Return("Developer");
But I get an exception telling me to set the properties directly. Is there a way to tell rhino to just return the same value for any key given to this stub IDictionary
?
What you are trying to do is not a stub (in RhinoMock's understanding), you have to create a mock:
var fakeRoles = MockRepository.GenerateMock < IDictionary<PermissionLevel, string>>();
fakeRoles.Expect(r => r[PermissionLevel.None]).IgnoreArguments().Return("Developer");
精彩评论