mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Creates a test that aims to assert that the Equals and Clone functions for our three entity structs actually work. The bulk of the code is spent creating gopter generators for the entities. See information of generative or property based testing for explainations on that topic, but basically it's an object that is capable of creating a stream of unique instances of the given struct. With the generator we then make three assertions: 1) Entities are always equal to themselves. 2) A .Clone() of an entity is Equal to the original entity. 3) A .Clone() of an entity that has a field modified is not equal to the orignal. The third property is the worse for implementation, as it does not generate the field to modify, it simply loops all fields for each generated entity, and checks Equals always breaks. Break testing shows that this would have caught earlier bugs in Equals due to field addition. It will add to the work to add further fields, generators have to be manually specified for each field, but that seems a worthy cost.