I am doing a unit testing and I need to find a way to simulate a disconnection during DB transactions without actually or physically removing the network cable..The process must be automated since this is just part of a bigger scale of unit testing. I need to check if roll backs are handled accordingly
You could stop the DB server process. If you let us know which DB platform, I am sure one of us will have a shell command for you that you could execute within your unit test.
Kindness,
Dan
If you are using C# or .Net, you can use Typemock to fake the connection and return the disconnection effect.
You could mock the Connection and throw an exception when you need connection to disconnect.
write a proxy which will connect you to the DB
for example in python: http://code.activestate.com/recipes/483730/
then just kill the proxy to end to connection
I just need this network to be disabled. What I did was call through C# a DOS command NETSH assigning a non-existing gateway to my test pc thus disabling or cutting the network connection, execute the test case, and then setting it back to the original to enable again the connection. Thanks for the responses.. :D