Пример #1
0
        public void GetTcpChannelReturnsChannelWithCorrectURI()
        {
            var channel = TcpChannelUtils.GetTcpChannel("test", 1234);

            using (CleanUpOnDispose(channel))
            {
                Assert.That(channel, HasChannelUris().EqualTo(new[] { "tcp://127.0.0.1:1234" }));
            }
        }
Пример #2
0
        public void GetTcpChannelReturnsChannelWithCorrectNameForUnspecifiedPort()
        {
            var channel = TcpChannelUtils.GetTcpChannel("test", 0);

            using (CleanUpOnDispose(channel))
            {
                Assert.That(channel, HasChannelName().EqualTo("test"));
            }
        }
Пример #3
0
        public void GetTcpChannelReturnsSameChannelForSameNameUnspecifiedPorts()
        {
            var first = TcpChannelUtils.GetTcpChannel("test", 0);

            using (CleanUpOnDispose(first))
            {
                var second = TcpChannelUtils.GetTcpChannel("test", 0);
                Assert.That(second, Is.SameAs(first));
            }
        }
Пример #4
0
        public void GetTcpChannelReturnsSameChannelForSameNameDifferentPort()
        {
            var first = TcpChannelUtils.GetTcpChannel("test", 1234);

            using (CleanUpOnDispose(first))
            {
                var second = TcpChannelUtils.GetTcpChannel("test", 4321);
                Assert.That(second, Is.SameAs(first));
            }
        }
Пример #5
0
        public virtual void Start()
        {
            if (uri != null && uri != string.Empty)
            {
                lock (theLock)
                {
                    this.channel = TcpChannelUtils.GetTcpChannel(uri + "Channel", port, 100);

                    RemotingServices.Marshal(this, uri);
                    this.isMarshalled = true;
                }

                if (this.port == 0)
                {
                    ChannelDataStore store = this.channel.ChannelData as ChannelDataStore;
                    if (store != null)
                    {
                        string channelUri = store.ChannelUris[0];
                        this.port = int.Parse(channelUri.Substring(channelUri.LastIndexOf(':') + 1));
                    }
                }
            }
        }