To help with testing the Post data class, i.e. the one that is linked to the database, has extra rules over the DetailPostDto. This means that more tests are done when the database is updated, which are then caught by SaveChanges and sent back as errors.
Property | Validation rule | Where shown? | Where Checked* |
---|---|---|---|
Title | Must have between 2 and 128 characters in it | By property | Browser,MVC,EF |
Title | Must not contain HTML symbols, e.g. <, > | Exception | MVC |
Content | Cannot be empty | By property | Browser,MVC,EF |
Content | Must not contain HTML symbols, e.g. <, > | Exception | MVC |
Blog (Author) | Must have a blogger assigned to the post | By property | DTO,EF |
Tags | Must have at least one tag assigned to the Post | By property | DTO,EF |
Note that these strange rules have been added to allow testing of different error conditions
Property | Validation rule | Where shown? | Where Checked* |
---|---|---|---|
Title | Must not include an exclamation mark, i.e '!' | By property | EF |
Title | Must not end with a question mark, i.e '?' | By property | EF |
Content |
A sentence must not end with the following words: ' sheep.', ' lamb.', ' cow.' or ' calf.' |
At top | EF |
Note*: The 'Where Checked' terms are
if (!ModelState.IsValid)
in Controller actionsThe test for HTML symbols is done by MVC and throws an exception, which in the release version goes to the default error page.