After I tried to serialize some geometry to JSON and unit tested it some while ago, now I see that the opennurbs value changed. Could you please tell me what the number value for opennurbs means? It looks like this:
I think unit testing the actual contents of the string is not a correct test, because as you can see you are not certain about what the result should be (assertion step) Instead you can always test whether the serialized rhino object is not a null or empty string. In addition, you can then do the opposite test, then you have two unit tests which handle any of the given situations. This means that your production code will do so as well.
Anyways, for informational purposes your question to Steve is also very pertinent.
at first I need to mention, that I don’t test the serializing part. I test some objects by serializing them instead. You might ask me then why I do it like that, if I can test the properties instead for example.
Well the thing is, that sometimes I have cases like this:
I have an object and I call some method that is using it, and I want to make sure, that this method didn’t changed anything in the object used. Default way would be to for example check every single property and make sure that nothing changed. But then you will have a lot of asserts, to make sure that it is like that. So my way is to serialize this object before the method is being called, call the method, serialize object once again, and compare two result strings. It takes 3 lines of code, and I am sure that nothing have changed.
Testing if Rhino object is null or empty doesn’t make sense, as it only tests if you got any string. When I test Rhino geometry objects, then assertion of true with GeometryEquals does the job, but we’re not talking about the geometry comparisons or making sure if Json serialize function succeed, but about the opennurbs value mystery, that was found by accident during running the tests