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


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


source


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


source







All Articles