Beispiel #1
0
        public void GetPort_Rpc_DefaultPort()
        {
            PortTypeUtils.ResetPorts();
            var port = PortTypeUtils.GetPortNumber(EPortType.Rpc);

            Assert.AreEqual(24533, port);
        }
Beispiel #2
0
        public void GetPort_MultichainD_DefaultPort()
        {
            PortTypeUtils.ResetPorts();
            var port = PortTypeUtils.GetPortNumber(EPortType.MultichainD);

            Assert.AreEqual(7211, port);
        }
Beispiel #3
0
        public void GetPortTwice_MultichainD_NextPort()
        {
            PortTypeUtils.ResetPorts();
            PortTypeUtils.GetPortNumber(EPortType.MultichainD);

            var port = PortTypeUtils.GetPortNumber(EPortType.MultichainD);

            Assert.AreEqual(7212, port);
        }
Beispiel #4
0
        public void GetPortTwice_Rpc_NextPort()
        {
            PortTypeUtils.ResetPorts();
            PortTypeUtils.GetPortNumber(EPortType.Rpc);

            var port = PortTypeUtils.GetPortNumber(EPortType.Rpc);

            Assert.AreEqual(24534, port);
        }
Beispiel #5
0
        public void ResetPorts_GetPortTwice_DefaultPort()
        {
            PortTypeUtils.ResetPorts();
            var port1 = PortTypeUtils.GetPortNumber(EPortType.MultichainD);

            PortTypeUtils.ResetPorts();
            var port2 = PortTypeUtils.GetPortNumber(EPortType.MultichainD);

            Assert.AreEqual(port1, port2);
        }
Beispiel #6
0
        /// <summary>
        ///     Returns the next available port for specified use.
        ///     Starts from a predefined value for enum
        /// </summary>
        /// <returns>An available TPC Port</returns>
        public static int GetNewPort(EPortType type)
        {
            var ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
            var tcpConnInfoArray   = ipGlobalProperties.GetActiveTcpConnections();

            while (true)
            {
                // Get port from tool
                var port = PortTypeUtils.GetPortNumber(type);
                // Check if our desired port is in use
                if (tcpConnInfoArray.All(t => t.LocalEndPoint.Port != port))
                {
                    // This port is good
                    return(port);
                }
            }
        }