mercredi 23 décembre 2015

C#: Create a test DataContract object with some internal properties?

I have a data contract Foo with the following structure.

 [DataContract]
 public sealed class Foo
 {
     [DataMember]
     public String Type
     {
         get;
         internal set;
     }
  }

For testing purpose I want to create a instance of Foo with a particular type, but I can't set the Type property after creating its instance because it is an internal property. How can I achieve this?

One idea is to create a serialized version of the object and then use the deserializer to create the instance of the object, is this possible and if yes how can I do it?

Aucun commentaire:

Enregistrer un commentaire