c# - Ploeh AutoFixture was unable to create an instance from System.Runtime.Serialization.ExtensionDataObject -


we have mvc project references wcf services. references added (extensiondataobject)extensiondata property every dto , response object , autofixture fails create anonymous instances of these types.

example:

public partial class searchresultsdto : object,      system.runtime.serialization.iextensibledataobject,      system.componentmodel.inotifypropertychanged {      [system.nonserializedattribute()]     private system.runtime.serialization.extensiondataobject extensiondatafield;      [global::system.componentmodel.browsableattribute(false)]     public system.runtime.serialization.extensiondataobject extensiondata {         {                 return this.extensiondatafield;             }         set {                 this.extensiondatafield = value;             }         }     } 

code:

_fixture = new fixture().customize(new automoqcustomization()); var dto = _fixture.createanonymous<searchresultsdto>(); 

exception:

ploeh.autofixture.objectcreationexception: ploeh.autofixture.objectcreationexception: autofixture unable create instance system.runtime.serialization.extensiondataobject, because has no public constructor, abstract or non-public type..

question: there way of registering object within autofixture, instantiates null or else, let me createanonymous on objects extensiondata property.

the easiest way is:

fixture.register<extensiondataobject>(() => null); 

that registers autofixture specific way initialize extensiondataobject, func given. in case func returns null go.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -