One of the projects I work on uses the validation module of the eXpressApp Framework (XAF). Since the business logic is complex, there are many validation rules defined using the
One of the recurring problems occurs when the signature of the associated property is incorrect. Consider the following:
1 2 3 4 5 6 7 8 9 10 11
Notice that the rule is declared
public. This causes the getter to be executed when it is not required (see the note in the documentation). However another problem is that the default behaviour for public properties of XPObjects is to persist them to the datastore which means the application will attempt to create a new column called
Instead, either property should be declared
protected or the property should also have the
[MemberDesignTimeVisibility(false)] attributes as well.
Consequently, I wrote the following unit test which will detect any properties which have the
[RuleFromBoolProperty] attribute. This is not really a unit test, rather a sort of meta-test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Now the build will fail whenever a validation property signature is incorrect.