WCF Message.IsFault
I am trying to write a test and you need to create an object Message
with a property IsFault
set to true. However, only a getter has this property. Does anyone know a better way to create a message that will set this property to true?
thank
+2
Jon Archway
source
to share
2 answers
Use an Message.CreateMessage()
overload that takes MessageFault
. Something like the following should work.
Message CreateMessage()
{
return Message.CreateMessage(
MessageVersion.Default,
MessageFault.CreateFault(new FaultCode("fault-string"), "reason"),
"action-string");
}
+2
Steve guidi
source
to share
Perhaps consider creating a setter on an object with a protected interior or a protected interior. i.e.
public String MyProperty {get; internal set;}
Andrew
Reflection is another route, but I think the first solution should work.
Andrew
0
REA_ANDREW
source
to share