c# - Is it possible to throw a MessageQueueException? -
i using mock object in rhinomocks represent class makes calls messagequeue.getpublicqueues. want simulate exception thrown when message queueing operating in workgroup mode, messagequeueexception, ensure catching exception correctly
the messagequeueexception has no public constructor, standard protected constructor exception. there appropriate way throw exception mock object / expect.call statement?
reflection can break accessibility rulez. will void warranty, .net update can break code. try this:
using system.reflection; using system.messaging; ... type t = typeof(messagequeueexception); constructorinfo ci = t.getconstructor(bindingflags.nonpublic | bindingflags.instance, null, new type[] { typeof(int) }, null); messagequeueexception ex = (messagequeueexception)ci.invoke(new object[] { 911 }); throw ex;
Comments
Post a Comment