Exemplo n.º 1
0
        public void InitializeConnection_ReceiveMessage()
        {
            var callBackContainer = new CallBackContainer <Socket>();

            _connectInitializer.NewSocketEvent += (sender, socket) => callBackContainer.CallBackMethod(sender, socket);

            var tcpConnector = new TcpClient(Dns.GetHostName(), StartupInfo.PortNum);

            callBackContainer.WaitForCallBack(1000);

            Assert.True(callBackContainer.ReceivedCallBack);
            Assert.NotNull(callBackContainer.CallBackObject);
        }
Exemplo n.º 2
0
        public TcpMessagingTests()
        {
            StartupInfo.PortNum = 54231;
            _connectionInitializationListener = new ConnectionInitializationListener();
            _tcpClient = new TcpClient();
            var callBackContainer = new CallBackContainer <Socket>();

            _connectionInitializationListener.NewSocketEvent += callBackContainer.CallBackMethod;

            _tcpClient.Connect(Dns.GetHostName(), StartupInfo.PortNum);

            callBackContainer.WaitForCallBack(1000);

            _tcpConnectionHandler = new TcpConnectionHandler(callBackContainer.CallBackObject);
        }