TDD - testing business rules/validation in ASP.NET MVC
Posted
by csetzkorn
on Stack Overflow
See other posts from Stack Overflow
or by csetzkorn
Published on 2010-03-29T10:31:09Z
Indexed on
2010/03/29
10:33 UTC
Read the original article
Hit count: 561
Hi,
I am using the sharp architecture so I can easily use mocks etc. in my unit tests and/or during TDD. I have quite complicated business rules and would like to test them at the controller level. I am just wondering how other people do this?
For me validation tests business rules at three levels:
(1) Property level (e.g. property is required) (2) Intra property level (e.g. start date < end date) (3) Persistence level (e.g. name is unique, parent cannot be child of child)
My validation framework also assigns errors to properties. I am just wondering what other people do? Do you write a test for each business rule and check whether the correct error message is assigned to the correct property (i.e. looking at the ASP.MVC ModelState)?
I hope my question makes sense. Thanks a lot!
Best wishes,
Christian
© Stack Overflow or respective owner