コード例 #1
0
        public void ConnectionsTest()
        {
            //Arrange
            var connection = new NodeConnection();

            //Act
            _networkMapProvider.Connections.Add(connection);

            //Assert
            Assert.AreEqual(1, _networkMapProvider.Connections.Count);
            Assert.AreEqual(connection, _networkMapProvider.Connections[0]);
        }
コード例 #2
0
        public void RemoveConnection_ConnectionFound()
        {
            //Arrange
            var sourceNodeId = Guid.NewGuid();
            var targetNodeId = Guid.NewGuid();
            var connection = new NodeConnection {SourceNodeId = sourceNodeId, TargetNodeId = targetNodeId};
            var connections = new List<NodeConnection> { connection};
            _mockNetworkMapProvider.Setup(p => p.FindConnection(sourceNodeId, targetNodeId)).Returns(connection);
            _mockNetworkMapProvider.SetupGet(p => p.Connections).Returns(connections);

            //Act
            _presenter.RemoveConnection(sourceNodeId, targetNodeId);

            //Assert
            Assert.IsTrue(_presenter.IsDirty);
            Assert.IsEmpty(connections);
        }
コード例 #3
0
        public void GetNodeDestinationAddresses_RemoteNodeNotFound()
        {
            //Arrange
            var nodeId = Guid.NewGuid();
            var connection = new NodeConnection {SourceNodeId = nodeId, TargetNodeId = Guid.NewGuid()};
            _networkMapProvider.Connections.Add(connection);

            //Act
            var results = _networkMapProvider.GetNodeDestinationAddresses(nodeId);

            //Assert
            Assert.IsEmpty(results);
        }
コード例 #4
0
        public void GetNodeDestinationAddresses_TargetIsTarget()
        {
            //Arrange
            var nodeId = Guid.NewGuid();
            var targetNode = new NetworkNode
                {
                    Id = Guid.NewGuid(),
                    Address = new NetworkAddress { IpAddress = "172.0.0.1", SubnetMask = "255.255.255.0" }
                };
            var connection = new NodeConnection { SourceNodeId = nodeId, TargetNodeId = targetNode.Id };
            _networkMapProvider.Connections.Add(connection);
            _networkMapProvider.Nodes.Add(targetNode);

            //Act
            var results = _networkMapProvider.GetNodeDestinationAddresses(nodeId);

            //Assert
            Assert.AreEqual(1, results.Count());
            var resultAddress = results.First();
            Assert.AreEqual(targetNode.Address.IpAddress, resultAddress.IpAddress);
            Assert.AreEqual(targetNode.Address.SubnetMask, resultAddress.SubnetMask);
        }
コード例 #5
0
        public void FindConnection_WhenSourceIsTargetAndTargetIsSource()
        {
            //Arrange
            var sourceId = Guid.NewGuid();
            var targetId = Guid.NewGuid();
            var connection = new NodeConnection { SourceNodeId = targetId, TargetNodeId = sourceId };
            _networkMapProvider.Connections.Add(connection);

            //Act
            var result = _networkMapProvider.FindConnection(sourceId, targetId);

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(sourceId, result.TargetNodeId);
            Assert.AreEqual(targetId, result.SourceNodeId);
        }