Unit Test a database update code?
-
Hi - I have a piece of C# code that write message log to Database. Now I would like to create unit test scripts using Visual Studio Unit Test framework. I need to create Unit Test code to verify if the data is written properly to the database or not. How do I write code or what mechanism I should use to verify this. Thanks, Shub
-
Hi - I have a piece of C# code that write message log to Database. Now I would like to create unit test scripts using Visual Studio Unit Test framework. I need to create Unit Test code to verify if the data is written properly to the database or not. How do I write code or what mechanism I should use to verify this. Thanks, Shub
-
Hi - I have a piece of C# code that write message log to Database. Now I would like to create unit test scripts using Visual Studio Unit Test framework. I need to create Unit Test code to verify if the data is written properly to the database or not. How do I write code or what mechanism I should use to verify this. Thanks, Shub
-
Hi - I have a piece of C# code that write message log to Database. Now I would like to create unit test scripts using Visual Studio Unit Test framework. I need to create Unit Test code to verify if the data is written properly to the database or not. How do I write code or what mechanism I should use to verify this. Thanks, Shub
Well in my opinion doing a unit test does not involve actually seeing if the data got written properly to the database. That is an integration test in my opinion. Unit tests should just test that module and nothing else. I would make a mock database adaptor and have the test make sure all the proper commands where made to the adaptor from your code. To me this is a truer unit test.
Leon Lambert
-
Hi - I have a piece of C# code that write message log to Database. Now I would like to create unit test scripts using Visual Studio Unit Test framework. I need to create Unit Test code to verify if the data is written properly to the database or not. How do I write code or what mechanism I should use to verify this. Thanks, Shub
You have two choices. First choice is actually write the data to the Database, ideally within a transation so that it can be rolled back. You need to be able to run your Unit Tests repeatedly without leaving a mess behind. Second Choice is to Mock the Database. If you haven't designed your app from the start with this in mind then it can be tricky to retrofit. If you need more info on Mocking just ask. -Rd
Hit any user to continue.