Ejemplo n.º 1
0
        public SocketClientTests()
        {
            this.socketClient = new SocketClient();

            var endpoint = new IPEndPoint(IPAddress.Loopback, 0);

            this.tcpListener = new TcpListener(endpoint);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestRequestSender"/> class.
 /// Used only for testing to inject communication endpoint.
 /// </summary>
 /// <param name="communicationEndPoint">Communication server implementation.</param>
 /// <param name="connectionInfo">ConnectionInfo to set up transport layer</param>
 /// <param name="serializer">Serializer implementation.</param>
 /// <param name="protocolConfig">Protocol configuration.</param>
 /// <param name="clientExitedWaitTime">Time to wait for client process exit.</param>
 internal TestRequestSender(
     ICommunicationEndPoint communicationEndPoint,
     TestHostConnectionInfo connectionInfo,
     IDataSerializer serializer,
     ProtocolConfig protocolConfig,
     int clientExitedWaitTime)
     : this(connectionInfo, serializer, protocolConfig, clientExitedWaitTime)
 {
     this.communicationEndpoint = communicationEndPoint;
 }
Ejemplo n.º 3
0
 protected TestRequestHandler(TestHostConnectionInfo connectionInfo, ICommunicationEndPoint communicationEndpoint, IDataSerializer dataSerializer, JobQueue <Action> jobQueue, Action <Message> onAckMessageRecieved)
 {
     this.communicationEndPoint       = communicationEndpoint;
     this.connectionInfo              = connectionInfo;
     this.dataSerializer              = dataSerializer;
     this.requestSenderConnected      = new ManualResetEventSlim(false);
     this.testHostManagerFactoryReady = new ManualResetEventSlim(false);
     this.sessionCompleted            = new ManualResetEventSlim(false);
     this.onAckMessageRecieved        = onAckMessageRecieved;
     this.jobQueue = jobQueue;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestRequestSender"/> class.
 /// Used only for testing to inject communication endpoint.
 /// </summary>
 /// <param name="communicationEndPoint">Communication server implementation.</param>
 /// <param name="connectionInfo">ConnectionInfo to set up transport layer</param>
 /// <param name="serializer">Serializer implementation.</param>
 /// <param name="protocolConfig">Protocol configuration.</param>
 /// <param name="clientExitedWaitTime">Time to wait for client process exit.</param>
 internal TestRequestSender(
     ICommunicationEndPoint communicationEndPoint,
     TestHostConnectionInfo connectionInfo,
     IDataSerializer serializer,
     ProtocolConfig protocolConfig,
     int clientExitedWaitTime)
     : this(
         runtimeProvider : null,
         communicationEndPoint,
         connectionInfo,
         serializer,
         protocolConfig,
         clientExitedWaitTime)
 {
 }
        /// <inheritdoc />
        public virtual void InitializeCommunication()
        {
            this.communicationEndPoint            = this.communicationEndpointFactory.Create(this.ConnectionInfo.Role);
            this.communicationEndPoint.Connected += (sender, connectedArgs) =>
            {
                if (!connectedArgs.Connected)
                {
                    requestSenderConnected.Set();
                    throw connectedArgs.Fault;
                }
                this.channel = connectedArgs.Channel;
                this.channel.MessageReceived += this.OnMessageReceived;
                requestSenderConnected.Set();
            };

            this.communicationEndPoint.Start(this.ConnectionInfo.Endpoint);
        }
Ejemplo n.º 6
0
 private void SetCommunicationEndPoint()
 {
     if (this.connectionInfo.Role == ConnectionRole.Host)
     {
         this.communicationEndPoint = new SocketServer();
         if (EqtTrace.IsVerboseEnabled)
         {
             EqtTrace.Verbose("TestRequestHanlder is acting as server");
         }
     }
     else
     {
         this.communicationEndPoint = new SocketClient();
         if (EqtTrace.IsVerboseEnabled)
         {
             EqtTrace.Verbose("TestRequestHanlder is acting as client");
         }
     }
 }
Ejemplo n.º 7
0
 private void SetCommunicationEndPoint()
 {
     // TODO: Use factory to get the communication endpoint. It will abstract out the type of communication endpoint like socket, shared memory or named pipe etc.,
     if (this.connectionInfo.Role == ConnectionRole.Client)
     {
         this.communicationEndpoint = new SocketClient();
         if (EqtTrace.IsVerboseEnabled)
         {
             EqtTrace.Verbose("TestRequestSender is acting as client");
         }
     }
     else
     {
         this.communicationEndpoint = new SocketServer();
         if (EqtTrace.IsVerboseEnabled)
         {
             EqtTrace.Verbose("TestRequestSender is acting as server");
         }
     }
 }
Ejemplo n.º 8
0
        internal TestRequestSender(
            ITestRuntimeProvider runtimeProvider,
            ICommunicationEndPoint communicationEndPoint,
            TestHostConnectionInfo connectionInfo,
            IDataSerializer serializer,
            ProtocolConfig protocolConfig,
            int clientExitedWaitTime)
        {
            this.dataSerializer       = serializer;
            this.connected            = new ManualResetEventSlim(false);
            this.clientExited         = new ManualResetEventSlim(false);
            this.clientExitedWaitTime = clientExitedWaitTime;
            this.operationCompleted   = 0;

            this.highestSupportedVersion = protocolConfig.Version;

            // The connectionInfo here is that of RuntimeProvider, so reverse the role of runner.
            this.runtimeProvider         = runtimeProvider;
            this.communicationEndpoint   = communicationEndPoint;
            this.connectionInfo.Endpoint = connectionInfo.Endpoint;
            this.connectionInfo.Role     = connectionInfo.Role == ConnectionRole.Host
                ? ConnectionRole.Client
                : ConnectionRole.Host;
        }
Ejemplo n.º 9
0
 public TestableTestRequestSender(ICommunicationEndPoint commEndpoint, TestHostConnectionInfo connectionInfo, IDataSerializer serializer, ProtocolConfig protocolConfig)
     : base(commEndpoint, connectionInfo, serializer, protocolConfig, 0)
 {
 }
Ejemplo n.º 10
0
 public TestableTestRequestHandler(TestHostConnectionInfo testHostConnectionInfo, ICommunicationEndPoint communicationClient, IDataSerializer dataSerializer, JobQueue <Action> jobQueue)
     : base(testHostConnectionInfo, communicationClient, dataSerializer, jobQueue, OnAckMessageReceived)
 {
 }
Ejemplo n.º 11
0
        public SocketServerTests()
        {
            this.socketServer = new SocketServer();

            this.tcpClient = new TcpClient();
        }