I'm writing unittests for an application which makes use of a third party API, with some generated interfaces. I was getting some strange exceptions trying to create a mock object for a complex interface. After much digging, I found that one of these interfaces it extends has a declaration with a ref keyword in it:
public interface IReferenceMaker
RefResult NotifyRefChanged(ref UIntPtr partID, RefMessage message);
When trying to create a mock object for this interface, an exception is thrown when accessing the Object property: ArgumentException: Type System.UIntPtr could not be converted to a OpCode.
Mock<IReferenceMaker> mockRefMaker = new Mock<IReferenceMaker>();
IReferenceMaker refMaker = mockRefMaker.Object;
Unfortunately I can't change the interface in any way, so I'm looking for a way to work around the issue on the Moq side.
edit: I noticed in the stacktrace that the exception is thrown in Castle, so I submitted an issue report there too.
It appears this was fix when upgrading to Castle 3.3.3 #204.