chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I have a socketmanager class that manages my socket communication.

I am trying figure out a game plan on how to test it. Any ideas or patterns out there for unit testing socket communication?

I have 4 events, connected, disconnected, data arrived, and error. A constructor that takes the connection parameters and a connect method that connects to the server.

Do I make a unit test class that instantiates the class and wires up the events then connect to the actual server I am testing. I was hoping I could avoid that as it goes against the whole separation of concerns.

_ClientSocket.BeginReceive(thisSockectPacket.dataBuffer,
0, thisSockectPacket.dataBuffer.Length,
                  SocketFlags.None,
                  CallBack,
                  thisSockectPacket);

How would I mock this?

Thanks in advance.

Bryan
asked by BringerOD (600 points)

1 Answer

0 votes
Hi,

You can use The Isolator ability to fire mock events in order to simulate incoming connections from the outside.

check it here:
https://www.typemock.com/Docs/UserGuide/EventsNatural.html

If you can supply more info on the exact mechansim We might be able to help you more with this.
If you want let me know and we can take it offline.
answered by lior (13.2k points)
...