I am right now trying to do very, very simple stuff with unit-testing in VS2008, to get started and get a feel for this. I think I have testing of small non-database stuff down, but now I want to start testing my real solutions - that are almost always CRUD-heavy.
So let's assume I have a class in the data-access layer, that does standard CRUD-stuff for a Product. I want a test for each of the methods on the Product.
Below is what I could think up without any real knowledge on the subject. Is this the way to do it, or... How should I approach this? Cool (but simple, please) references are also very welcome.
Create
- Feed some relevant parameters (Product name etc)
- Check that an identity is returned.
- Delete the Product (to clean up).
Read
- Create a new product
- Invoke the select-method
- Make sure the product-name matches the one I gave it on creation
- Delete the produkt
Update
- Create a new Product
- Update some fields on it
- Select the product
- Verify some fields match
- Delete hte product
Delete
- Create a new Product, keep the ProductID
- Delete the product (Cleanup on aisle 4!)
- Check if the product with this Productid is still in the table?
EDIT:
...Or should I simply create a single test, that tests all of these things?