public bool Start() { log.Info("Agent starting"); // Open the TCP channel so we can activate an ITestAgency instance from _agencyUrl _channel = TcpChannelUtils.GetTcpChannel(_currentMessageCounter); log.Info("Connecting to TestAgency at {0}", _agencyUrl); try { // Direct cast, not safe cast. If the cast fails we need a clear InvalidCastException message, not a null _agency. _agency = (ITestAgency)Activator.GetObject(typeof(ITestAgency), _agencyUrl); } catch (Exception ex) { log.Error("Unable to connect: {0}", ExceptionHelper.BuildMessageAndStackTrace(ex)); } try { _agency.Register(_agentId, this); log.Debug("Registered with TestAgency"); } catch (Exception ex) { log.Error("RemoteTestAgent: Failed to register with TestAgency. {0}", ExceptionHelper.BuildMessageAndStackTrace(ex)); return(false); } return(true); }
public void GetTcpChannelReturnsChannelWithCorrectURI() { var channel = TcpChannelUtils.GetTcpChannel("test", 1234); using (CleanUpOnDispose(channel)) { Assert.That(channel, HasChannelUris().EqualTo(new[] { "tcp://127.0.0.1:1234" })); } }
public void GetTcpChannelReturnsChannelWithCorrectNameForUnspecifiedPort() { var channel = TcpChannelUtils.GetTcpChannel("test", 0); using (CleanUpOnDispose(channel)) { Assert.That(channel, HasChannelName().EqualTo("test")); } }
public void GetTcpChannelReturnsSameChannelForSameNameUnspecifiedPorts() { var first = TcpChannelUtils.GetTcpChannel("test", 0); using (CleanUpOnDispose(first)) { var second = TcpChannelUtils.GetTcpChannel("test", 0); Assert.That(second, Is.SameAs(first)); } }
public void GetTcpChannelReturnsSameChannelForSameNameDifferentPort() { var first = TcpChannelUtils.GetTcpChannel("test", 1234); using (CleanUpOnDispose(first)) { var second = TcpChannelUtils.GetTcpChannel("test", 4321); Assert.That(second, Is.SameAs(first)); } }
public bool Start() { lock (_theLock) { _channel = TcpChannelUtils.GetTcpChannel(_uri + "Channel", _port, 100); RemotingServices.Marshal(this, _uri); _isMarshalled = true; } if (_port == 0) { ChannelDataStore store = this._channel.ChannelData as ChannelDataStore; if (store != null) { string channelUri = store.ChannelUris[0]; _port = int.Parse(channelUri.Substring(channelUri.LastIndexOf(':') + 1)); } } return(true); }