I have a scenario where I have a fairly complex object that I load from a database.
That object has several nested objects. While I am debugging I find an instance of this object that I would like to use in a unit test. Right now I have to create this object manually. Since it is fairly complex, it takes me a while.
My unit testing time would be better spent if there was a way to tell the watch window to output this variable to a text window (or the clipboard).
It seems all the info needed is in the watch window.
I would not expect it to create using statements or any such thing, just use the class info it has and create the new
statements (nested as many levels as my object goes).
Is there any such tool out there? (If not maybe I just found a way to make my fortune?)
There is no such tool that I know... it is very complicated to do this because:
One easy solution: make the object serializable (to xml, or json for example), serialize it, copy the serialized string to your unit test, and then deserialize it in the unit test.
Not so easy solution: implement a debugger visualizer, with a visualizer object source: Debugger Visualizer and "Type is not marked as serializable"
That way you can create a window, and show the serialized object... you will probably have to use reflection to read all object properties, and child objects, and so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With