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?
- Write class with 1 property.
- Serialize this class by my settings manager.
Before run new test:
- Manualy edit class and add new property, so we have two properties. New one with setted default value in [OnDeserialized] method.
- Run completely new test after rebuild new class.
- Class is deserialized from binary file.
- New property has default value.
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?
You can make two classes one for serialization and one for de-serialization and use SerializationBinder while de-serializing to the other class.