vendredi 12 octobre 2018

Visual Studio / Reflection / Serialization: Can I export values from a debug session to use them for unit testing?

I had to write many dozens of lines of code (see here: https://dotnetfiddle.net/RiVx2E) to generate a few lines of sample data.

In this specific case I could manually export the output variable (see the whole code on Fiddler) in this way:

new List { 
 { IDMacroTab = 1, IDTab = 1, IDSIot = 2 }
 { IDMacroTab = 1, IDTab = 2, IDSIot 1}
 { IDMacroTab = 1, IDTab = 2, IDSIot = 2}
 { IDMacroTab = 1, IDTab = 2, IDSIot = 3}
 { IDMacroTab = 2, IDTab = 1, IDSIot = 1}
 { IDMacroTab = 2, IDTab = 1, IDSIot = 2 }
 { IDMacroTab = 2, IDTab = 2, IDSIot = 1}
 { IDMacroTab = 2, IDTab = 2, IDSIot = 2}
 { IDMacroTab = 2, IDTab = 2, IDSIot = 3}
 { IDMacroTab = 3, IDTab = 1, IDSIot = 1}
 { IDMacroTab = 3, IDTab = 1, IDSIot = 2}
 { IDMacroTab = 3, IDTab = 2, IDSIot = 1}
 { IDMacroTab = 3, IDTab = 2, IDSIot = 2}
 { IDMacroTab = 3, IDTab = 2, IDSIot = 3}};

Is there any workaround that allows to serialize an object to the c# lines of code required to populate it?





Aucun commentaire:

Enregistrer un commentaire