I'm having a problem mocking a ResultPropertyCollection object. This object has two fields PropertyNames and PropertyValues. I can successfully mock this object, but it does not help very much - reason being ResultPropertyCollection inherits from DictionaryBase and the underlying hashtable has to be populated. I have read the limits of mscorlib assemblies, etc... but in my case I have to mock this hashtable.
This works, but doesn't seem like the easiest way .... I used a little reflection to add to the underlying hashtable.
Mock<ResultPropertyCollection> pc = MockManager.MockObject<ResultPropertyCollection>(Constructor.Mocked);
ResultPropertyCollection rpc = pc.Object as ResultPropertyCollection;
rpc.GetType().BaseType.GetInterface("IDictionary").InvokeMember("Add",
System.Reflection.BindingFlags.InvokeMethod,
null, rpc, new string[] { "test-key", "test-value" });
Is there an easier way?
Jayme