public Node(string IPv4_Router_Identifier, string NodeUsername, string NodePassword, int NodeKeepAliveInterval, string MessageBrokerURI, string MessageBrokerUsername, string MessageBrokerPassword, string ExchangeName, string RPCRequestQueueSuffix, string RPCRoutingKeyPrefix) { this.IPv4_Router_Identifier = IPv4_Router_Identifier; this.NodeUsername = NodeUsername; this.NodePassword = NodePassword; this.NodeKeepAliveInterval = NodeKeepAliveInterval; this.IsBusy = false; this.NetConfClient = new NetConfClient(this.IPv4_Router_Identifier, this.NodeUsername, this.NodePassword); this.NetConfClient.KeepAliveInterval = new TimeSpan(0, 0, 30); this.NetConfClient.AutomaticMessageIdHandling = false; this.ConnectionCheckTimer = new System.Timers.Timer(this.NodeKeepAliveInterval); this.ConnectionCheckTimer.Elapsed += ConnectionCheckTimer_Elapsed; this.MessageBrokerHost = MessageBrokerURI; this.MessageBrokerUsername = MessageBrokerUsername; this.MessageBrokerPassword = MessageBrokerPassword; this.ExchangeName = ExchangeName; this.RPCRequestQueueSuffix = RPCRequestQueueSuffix; this.RPCRoutingKeyPrefix = RPCRoutingKeyPrefix; this.Retries = 0; }
[Ignore] // placeholder for actual test public void NetConfClientConstructorTest4() { ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(connectionInfo); Assert.Inconclusive("TODO: Implement code to verify target"); }
protected void Arrange() { _serviceFactoryMock = new Mock <IServiceFactory>(MockBehavior.Loose); _sessionMock = new Mock <ISession>(MockBehavior.Loose); _netConfSessionMock = new Mock <INetConfSession>(MockBehavior.Loose); _connectionInfo = new ConnectionInfo("host", "user", new NoneAuthenticationMethod("userauth")); _netConfClient = new NetConfClient(_connectionInfo, false, _serviceFactoryMock.Object); var sequence = new MockSequence(); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateSession(_connectionInfo)) .Returns(_sessionMock.Object); _sessionMock.InSequence(sequence).Setup(p => p.Connect()); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateNetConfSession(_sessionMock.Object, _netConfClient.OperationTimeout)) .Returns(_netConfSessionMock.Object); _netConfSessionMock.InSequence(sequence).Setup(p => p.Connect()); _netConfClient.Connect(); _netConfClient = null; // we need to dereference all other mocks as they might otherwise hold the target alive _sessionMock = null; _connectionInfo = null; _serviceFactoryMock = null; }
protected void Arrange() { _serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Loose); _sessionMock = new Mock<ISession>(MockBehavior.Loose); _netConfSessionMock = new Mock<INetConfSession>(MockBehavior.Loose); _connectionInfo = new ConnectionInfo("host", "user", new NoneAuthenticationMethod("userauth")); _netConfClient = new NetConfClient(_connectionInfo, false, _serviceFactoryMock.Object); var sequence = new MockSequence(); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateSession(_connectionInfo)) .Returns(_sessionMock.Object); _sessionMock.InSequence(sequence).Setup(p => p.Connect()); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateNetConfSession(_sessionMock.Object, _netConfClient.OperationTimeout)) .Returns(_netConfSessionMock.Object); _netConfSessionMock.InSequence(sequence).Setup(p => p.Connect()); _netConfClient.Connect(); _netConfClient = null; // we need to dereference all other mocks as they might otherwise hold the target alive _sessionMock = null; _connectionInfo = null; _serviceFactoryMock = null; }
protected void Arrange() { _serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict); _sessionMock = new Mock<ISession>(MockBehavior.Strict); _netConfSessionMock = new Mock<INetConfSession>(MockBehavior.Strict); _connectionInfo = new ConnectionInfo("host", "user", new NoneAuthenticationMethod("userauth")); _netConfClient = new NetConfClient(_connectionInfo, false, _serviceFactoryMock.Object); var sequence = new MockSequence(); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateSession(_connectionInfo)) .Returns(_sessionMock.Object); _sessionMock.InSequence(sequence).Setup(p => p.Connect()); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateNetConfSession(_sessionMock.Object, _netConfClient.OperationTimeout)) .Returns(_netConfSessionMock.Object); _netConfSessionMock.InSequence(sequence).Setup(p => p.Connect()); _sessionMock.InSequence(sequence).Setup(p => p.OnDisconnecting()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Disconnect()); _sessionMock.InSequence(sequence).Setup(p => p.Dispose()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Dispose()); _netConfClient.Connect(); _netConfClient.Dispose(); }
protected override void SetupData() { _connectionInfo = new ConnectionInfo("host", "user", new NoneAuthenticationMethod("userauth")); _operationTimeout = new Random().Next(1000, 10000); _netConfClient = new NetConfClient(_connectionInfo, false, _serviceFactoryMock.Object); _netConfClient.OperationTimeout = TimeSpan.FromMilliseconds(_operationTimeout); }
protected void Arrange() { _serviceFactoryMock = new Mock <IServiceFactory>(MockBehavior.Strict); _sessionMock = new Mock <ISession>(MockBehavior.Strict); _netConfSessionMock = new Mock <INetConfSession>(MockBehavior.Strict); _connectionInfo = new ConnectionInfo("host", "user", new NoneAuthenticationMethod("userauth")); _operationTimeout = new Random().Next(1000, 10000); _netConfClient = new NetConfClient(_connectionInfo, false, _serviceFactoryMock.Object); _netConfClient.OperationTimeout = TimeSpan.FromMilliseconds(_operationTimeout); var sequence = new MockSequence(); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateSession(_connectionInfo)) .Returns(_sessionMock.Object); _sessionMock.InSequence(sequence).Setup(p => p.Connect()); _serviceFactoryMock.InSequence(sequence) .Setup(p => p.CreateNetConfSession(_sessionMock.Object, _operationTimeout)) .Returns(_netConfSessionMock.Object); _netConfSessionMock.InSequence(sequence).Setup(p => p.Connect()); _sessionMock.InSequence(sequence).Setup(p => p.OnDisconnecting()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Disconnect()); _sessionMock.InSequence(sequence).Setup(p => p.Dispose()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Disconnect()); _netConfSessionMock.InSequence(sequence).Setup(p => p.Dispose()); _netConfClient.Connect(); _netConfClient.Disconnect(); }
private void Arrange() { SetupData(); CreateMocks(); SetupMocks(); _netConfClient = new NetConfClient(_connectionInfo, false, _serviceFactoryMock.Object); }
public void ClientCapabilitiesTest() { ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value XmlDocument actual; actual = target.ClientCapabilities; Assert.Inconclusive("Verify the correctness of this test method."); }
[Ignore] // placeholder for actual test public void NetConfClientConstructorTest() { string host = string.Empty; // TODO: Initialize to an appropriate value string username = string.Empty; // TODO: Initialize to an appropriate value PrivateKeyFile[] keyFiles = null; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(host, username, keyFiles); Assert.Inconclusive("TODO: Implement code to verify target"); }
[Ignore] // placeholder for actual test public void NetConfClientConstructorTest2() { string host = string.Empty; // TODO: Initialize to an appropriate value string username = string.Empty; // TODO: Initialize to an appropriate value string password = string.Empty; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(host, username, password); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void OperationTimeout_Default() { var connectionInfo = new PasswordConnectionInfo("host", 22, "admin", "pwd"); var target = new NetConfClient(connectionInfo); var actual = target.OperationTimeout; Assert.AreEqual(TimeSpan.FromMilliseconds(-1), actual); }
[Ignore] // placeholder for actual test public void ClientCapabilitiesTest() { ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value XmlDocument actual; actual = target.ClientCapabilities; Assert.Inconclusive("Verify the correctness of this test method."); }
public void AutomaticMessageIdHandlingTest() { ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; target.AutomaticMessageIdHandling = expected; actual = target.AutomaticMessageIdHandling; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
[Ignore] // placeholder for actual test public void SendCloseRpcTest() { ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value XmlDocument expected = null; // TODO: Initialize to an appropriate value XmlDocument actual; actual = target.SendCloseRpc(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
protected override void Arrange() { base.Arrange(); _netConfClient.Connect(); _netConfClient = null; // We need to dereference all mocks as they might otherwise hold the target alive //(through recorded invocations?) CreateMocks(); }
public void OperationTimeoutTest() { ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value TimeSpan expected = new TimeSpan(); // TODO: Initialize to an appropriate value TimeSpan actual; target.OperationTimeout = expected; actual = target.OperationTimeout; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
[Ignore] // placeholder for actual test public void AutomaticMessageIdHandlingTest() { ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; target.AutomaticMessageIdHandling = expected; actual = target.AutomaticMessageIdHandling; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void OperationTimeout_UpperLimit() { var operationTimeout = TimeSpan.FromMilliseconds(int.MaxValue); var connectionInfo = new PasswordConnectionInfo("host", 22, "admin", "pwd"); var target = new NetConfClient(connectionInfo) { OperationTimeout = operationTimeout }; var actual = target.OperationTimeout; Assert.AreEqual(operationTimeout, actual); }
public void Load(string host, int port, string user, string password) { using (var client = new NetConfClient(host, port, user, password)) { client.AutomaticMessageIdHandling = false; client.OperationTimeout = new TimeSpan(0, 0, 60); client.Connect(); var nsManager = Ns.CreateManager(); var rpc = new XmlDocument(); // // Security Zones rpc.LoadXml("<rpc><get-config><source><running /></source><filter>" + FilterSecurityZones + "</filter></get-config></rpc>"); XmlDocument result = client.SendReceiveRpc(rpc); XDocument xmlZones = XDocument.Parse(result.OuterXml); this.Zones = xmlZones.Root.XPathSelectElements("./nc:data/xnm:configuration/xnm:security/xnm:zones/xnm:security-zone", nsManager).Select(SecurityZone.Parse).ToList(); // // Security Policy Groups rpc.LoadXml("<rpc><get-config><source><running /></source><filter>" + FilterGroups + "</filter></get-config></rpc>"); result = client.SendReceiveRpc(rpc); XDocument xmlGroups = XDocument.Parse(result.OuterXml); this.Groups = xmlGroups.Root.Descendants(Ns.Xnm + "groups") .Where(x => x.Descendants(Ns.Xnm + "security").SelectMany(y => y.Descendants(Ns.Xnm + "policies")).Any()) .Select(SecurityPoliciesGroup.Parse) .ToList(); // // Security Policies rpc.LoadXml("<rpc><get-config><source><running /></source><filter>" + FilterSecurityPolicies + "</filter></get-config></rpc>"); result = client.SendReceiveRpc(rpc); XDocument xmlPolicies = XDocument.Parse(result.OuterXml); this.Policies = xmlPolicies.Root.XPathSelectElements("./nc:data/xnm:configuration/xnm:security/xnm:policies/xnm:policy", nsManager) .Select(xml => SecurityPolicyContainer.Parse(xml, s => this.Groups.FirstOrDefault(g => g.Name == s) ?? new SecurityPoliciesGroup { Name = s })).ToList(); // Close client.SendCloseRpc(); } }
public void OperationTimeout_GreaterThanLowerLimit() { var operationTimeout = TimeSpan.FromMilliseconds(int.MaxValue).Add(TimeSpan.FromMilliseconds(1)); var connectionInfo = new PasswordConnectionInfo("host", 22, "admin", "pwd"); var target = new NetConfClient(connectionInfo); try { target.OperationTimeout = operationTimeout; } catch (ArgumentOutOfRangeException ex) { Assert.IsNull(ex.InnerException); Assert.AreEqual("The timeout must represent a value between -1 and Int32.MaxValue, inclusive." + Environment.NewLine + "Parameter name: " + ex.ParamName, ex.Message); Assert.AreEqual("value", ex.ParamName); } }
[Ignore] // placeholder for actual test public void SendReceiveRpcTest() { ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value string xml = string.Empty; // TODO: Initialize to an appropriate value XmlDocument expected = null; // TODO: Initialize to an appropriate value XmlDocument actual; actual = target.SendReceiveRpc(xml); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
[Ignore] // placeholder for actual test public void OperationTimeoutTest() { ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value NetConfClient target = new NetConfClient(connectionInfo); // TODO: Initialize to an appropriate value TimeSpan expected = new TimeSpan(); // TODO: Initialize to an appropriate value TimeSpan actual; target.OperationTimeout = expected; actual = target.OperationTimeout; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
protected override void SetupData() { _connectionInfo = new ConnectionInfo("host", "user", new NoneAuthenticationMethod("userauth")); _netConfSessionConnectionException = new ApplicationException(); _netConfClient = new NetConfClient(_connectionInfo, false, _serviceFactoryMock.Object); }