c# - How to unit test with a recursive object -
i have object takes in parameter of same type in constructor:
public class person { private person theparent; private string thename; public person(string aname, person aparent) { if(aparent == null) { thrown new argumentnullexception("aparent"); } theparent = aparent; thename = aname; } }
in unit test have create new person
object constructor requires person
object passed in. overcome problem in application getting person
object pass in database (using nhibernate , magic)*. don't want tie database access test not testing database functionality. should mock parent object (i'm using rhino mocks in of other tests) or there better way approach this?
*there guaranteed 1 record in databse can retrieve make parent object.
i assume @ point expected reach top node? correct value aparent
then?
my guess null
, , mean person
first in it's line (whatever means application, perhaps adam or something?).
Comments
Post a Comment