views:

147

answers:

2

I am trying to write a test and need to create a Message object with the IsFault property set to true. However, this property only has a getter. Does anyone know the best way to create a message where this property would be set to true?

Thanks

A: 

Possibly think about making a setter on the object with a proteced, internal or protected internal scope on. i.e.

public String MyProperty {get; internal set;}

Andrew

Reflection is another route, but I would think the first solution should work.

Andrew

REA_ANDREW
+1  A: 

Use the Message.CreateMessage() overload that accepts a MessageFault object. Something like the following should work.

Message CreateMessage()
{
    return Message.CreateMessage(
        MessageVersion.Default,
        MessageFault.CreateFault(new FaultCode("fault-string"), "reason"),
        "action-string");
}
Steve Guidi