c# - Unit testing - how to snapshot an object? -
i'm writting first unit tests in vs2012 using moq.
i need create object takes in multiple input parameters (not passed through interfaces).
i've minimized code sake of example. here's i'm trying do:
var mockloopcontrol = new mock<loopcontrol>(); var loopengine = new loopengine(mockloopcontrol.object); the loopcontrol object complex, has lot of members used in loopengine constructor.
for example loopengine constructor performs operations loopcontrol.contextdata again object lot of members.
from understanding need assign data members used using mock.setup(). possible take example snapshot of loopcontrol.contextdata object @ application runtime , use afterwards in unit tests?
i can figure out how it's possible write unit tests such complex architectures.
i hope made myself clear :) helping out.
dan
you mock don't need create complex structure. if loopengine needs use loopcontrol maybe doing much? maybe should delegate of work loopcontrol or other object? should extract other objects , else.
so seems me trying solve wrong problem here little bit.
and if want test more functionality, doing integration testing. may need have more complex object structure - right. don't need use mocks then, rather checking results in real sittuations.
Comments
Post a Comment