Network connection

I am doing unit testing and I need to find a way to simulate a disconnect during database transactions without actually or physically removing the network cable. The process should be automated, as this is just part of a larger unit testing, I need to check if the back rollers are processed accordingly.

+3
source share
5 answers

I just need this network disconnected. What I did was call through C # the DOS NETSH command, which assigns a nonexistent gateway to my test PC, thus disconnecting or reducing the network connection, running the test case, and then returning it to the original one to enable the connection again. Thanks for the answers ..: D

0
source

You can mock Connection and throw an exception when you need a connection to disconnect.

+5
source

. , , , - , unit test.

,

Dan

+1

If you are using C # or .Net, you can use Typemock to fake the connection and return the disconnect effect.

0
source

Source: https://habr.com/ru/post/1717804/


All Articles