visual studio 2010 - Parameterless constructor in c# -
i writing unit test existing class "person" in visual studio 2012 , class has constructor 2 parameters , business logic.
testmethod() public void verifypersontest() { //using privateobject class privateobject privatehelperobject = new privateobject(typeof(person)); //some business logic }
when try run above test got exception "system.missingmethodexception {"no parameterless constructor defined object."}".so have added parameterless constructor person class , able run test without issue.
i have following questions
1)as have added parameterless constructor person class ,will break existing functionality of person class?
2) privateobject privatehelperobject = new privateobject(typeof(person));
the above statement invokes parameterless constructor of person class.suppose if want invoke constructor 2 parameters,how can write above statement?
you instantiate person
object yourself:
var myperson = ...; var privatehelperobject = new privateobject(myperson);
Comments
Post a Comment