Reputation: 3285
I wrote my own settings manager, serialization is provided by BinaryFormatter. It is cool becouse, it can load and save class with missing/added property and I can define default value in missing property. But I have problem to test it with unit test.
I am doing this by myself. How to do this scenario automatically?
Before run new test:
It works like a charm, but I dont want to do this by myself. I need some automatic test.
Please, dont question my architecture, focus on my problem.
Posible way: Reclection? Other class? What about namespaces?
Upvotes: 2
Views: 1127
Reputation: 11833
If your classes are simple, you really can compile them on the fly, load the assembly, do your serialization, unload the assembly. Compile the "updated" class, reload the assembly and test deserialization.
Maybe this link gets you started!
Upvotes: 1
Reputation: 18296
You can make two classes one for serialization and one for de-serialization and use SerializationBinder while de-serializing to the other class.
Upvotes: 3