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

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -