0

I am trying to do exactly what the subject says for a test case, meaning when doing the check if(socket.Connected) you would get false, but the socket object remains and not get disposed. I know Polling test would be more precise but I'm not really interested in that for my current purpose of testing.

I looked around on this forum but I don't see a way to do this in C#, is this possible? I'm trying to create this scenario:

  1. Check Socket Connected, it fails.
  2. Reconnect socket so Socket.Connected return true.
  3. Sleep or wait for a period of time.
  4. Set the Socket.Connected to false again.
Fylix
  • 2,551
  • 6
  • 45
  • 72

1 Answers1

0

Mock or create a Test double for Socket and override Connected so that it can be set to True or False. If all you are testing is that the code reacts to that boolean and that the proper steps were taken, then its a pretty simple mock.

Ryan Bennett
  • 3,404
  • 19
  • 32