So I’ve started writing tests for the VASSAL Engine. I figured I’d start with something simple–test that for all traits, trait = deserialize(serialize(trait))
I’ve done ActionButton and more or less have it working, but there’s something that doesn’t look right.
I’m serializing by calling button.getType() which will throw a NullPointerException unless inner is set. Following the example of the TriggerActionTest that someone else already wrote, I did this to setInner:
button.setInner(new BasicPiece())
The problem is that if button.description = “foo” then when I deserialize by calling new ActionButton(type, basicPiece), the description of the new ActionButton is “foo piece”.
Which breaks my expectation that trait = deserialize(serialize(trait)).
Have I got it backwards? Should I instead be instantiating something else and then setting ActionButton to be inner to it, and then testing serialize/deserialize on the outer thing? If so, what should that outer thing be?
Or am I misunderstanding something more fundamental?
Ken
P.S. Initially, I didn’t think this was a big deal until I wrote a similar test for CalculatedProperty with an expression of “x+1” and found that for the deserialized serialized piece the expression came out “x + 1 piece” which definitely doesn’t look right…