Vector241-Eric / ZBuildLights

ZWaveControl for build status lights
MIT License
1 stars 3 forks source link

Fix JSON serialization test #21

Open Vector241-Eric opened 9 years ago

Vector241-Eric commented 9 years ago

Make some modifications to this test so that we ensure all properties on the MasterModel are populated to depth. I recently ran into a problem where I added a member to a data model, then forgot to set a value for that member in the test. So, I didn't realize that I wasn't serializing/deserializing that value. I thought my bug was elsewhere because this test gave me a false sense of confidence.

Vector241-Eric commented 9 years ago

I looked into using nBuilder or TestDataGenerator for this. Neither of these projects is good at populating a model with defaults values going to depth.

Maybe this is because ignorantly traversing object types leads to problems. But, I'm willing to try creating a new builder for this... later. What I'm thinking is, specifically handle each type encountered. Or, automatically handle everything that is in the same assembly as the root type.

Vector241-Eric commented 9 years ago

I see the problem now... The MasterModel has multiple read-only properties that are collections. These collections are modified by other methods. This situation is likely the case for other domain model types.

The best solution I can think for this at this point is... check that all properties are populated during the course of the test. This should catch empty properties -- the real problem highlighted by this bug. If the empty property check is added, then we can continue to generate the data manually.