triplea posted on Wednesday, August 01, 2007
Having releases my first app using CSLA in production recently (hurray!) I decided that my unit tests were very basic (mainly because of time constraints - I know that's not an excuse but...). In any case I started planning how to write unit tests for my objects to test things that matter most to me. These I decided to be:
- Validation rules (simple e.g. string lengths, and custom rules)
- Authorization (on CanAdd(), CanEdit() etc as well as on AddAuthorizationRules())
- 1 CRUD test
Now my question is twofold:
- The above work fine for BusinessBase objects (or EditableRoot if you like). But how do you go about writing a CRUD test for EditableChild objects? The main issue is FK constraints, the fact that an existing connection (and transaction) need to exist etc... By the way I don't want to use mocks and am happy to hit the database for these operations (even if running time is longer).
- Writing basic unit tests is boring :-). Has anonye got any templates (CodeSmith or other) for at least the basic of tests (such as for simple validation rules).