c# - Grab object values during runtime for creating Mock objects required for writing Unit Test -


consider below class needs tested,

class tobetested {   employee _e;   public tobetested(employee e)   {   _e = e;   }    void process()   {   // _e   } }      [testclass]     class tobetestedtest     {     [testmethod]     public void testprocessmethod()     {       employee e = // initialise test value..       tobetested tbt = new tobetested(e);       tbt.process();        //assert verify test results...       } 

the problem employee can complex type properties in can objects of more classes. becomes difficult initialise employee mock values , generate testable object.

while debugging can set breakpoint , see employee object in tobetested contains. there way can grab values object available during runtime , use in test method?

you can use object exporter. extension visual studio generate c# initialization code object in debugging windows. can use generated code in unit test initialization.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -