I'm new to unit testing and I need some help with the following. I have created a small project to help me learn how to make Unit Tests. The functionality for one of the forms in my application deletes a user from the User table (and other rows in mapping tables).Currently, the unit test I have created to test this sets up the required objects and then calls the business rules method (passing in the user id) which calls the data access method to execute the stored procedure that deletes the rows in the tables.Is this the correct method to test whether something is being deleted successfully? Should the unit test / setup method first insert some test data which the unit test then deletes?
How to make Unit Tests to make sure stored procedure is deleting row from the database?
c#;unit testing
IMHO if you are just starting to learn unit testing, it is better to leave databases out of the picture for now. Data in a DB is harder to test - in fact when you are testing code which makes direct calls to a DB, it isn't a unit test anymore but integration test.You can unit test code manipulating a DB, but it requires more effort and tools, including extra frameworks - like DBUnit in the Java world -, interfaces, mocks etc. which are more advanced topics.