I am wondering if anything like this exists:
When debugging in visual studio it would be really good if it had the ability to copy an object(all its properties and values) into memory. I am thinking of something that you could put a break point in code -> right click the object -> Click "create moq into clipboard"
Then you could go to your unit test, paste the text which would paste the code to create that object with all of those properties.
I imagine this would save loads of time, and would be really useful for fixing bugs.
One of the difficult things I find with unit test is the manual process in creating the mock objects.
In Visual Studio debug mode it's possible to hover over variables to show their value and then right-click to "Copy", "Copy Expression" or "Copy Value". In case the variable is an object and not just a basic type, there's a + sign to expand and explore the object.
In short, pressing F11 will take you to every line including your function body, but F10 allows to move from one line to the the immediate next line.
I'm a bit late to the party but I created a Visual Studio extension that does something very similar to what you're looking for. It will generate C# code to initialize an object from your visual studio debugging windows.
Here's the extension: Visual Studio Marketplace > Object Explorer
And here's an accompanying blog post: Exporting Objects from the Visual Studio Debugger
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