Beispiel #1
0
        /// <summary>
        /// Create a new connection with the specific end nodes and create relation among nodes and connection
        /// </summary>
        /// <param name="from">The node, where this connection starts</param>
        /// <param name="to">The noe where this connection ends</param>
        public Connection(Node from, Node to)
        {
            this.From = from;
            from.Connections.Add(this);

            this.To = to;
            to.Connections.Add(this);
        }
Beispiel #2
0
        public void NodeConstructorSetsPositionAndInitializeProperties()
        {
            PointGeo position = new PointGeo(12.8, 45.9);

            Node target = new Node(position);

            Assert.Equal(position, target.MapPoint);
            Assert.NotNull(target.Connections);
        }
        public void ConnectionConstructorSetFromAndToProperties()
        {
            Node from = new Node();
            Node to = new Node();

            Connection target = new Connection(from, to);

            Assert.Equal(from, target.From);
            Assert.Equal(to, target.To);
        }
        public void ConnectionToPropertyReturnsCorrectNode()
        {
            Node from = new Node();
            Node to = new Node();

            Connection target = new Connection(from, to);

            Node newTo = new Node();
            target.To = newTo;

            Assert.Equal(newTo, target.To);
        }
        public void ConnectionFromPropertyReturnsCorrectNode()
        {
            Node from = new Node();
            Node to = new Node();

            Connection target = new Connection(from, to);

            Node newFrom = new Node();
            target.From = newFrom;

            Assert.Equal(newFrom, target.From);
        }
Beispiel #6
0
 /// <summary>
 /// Gets Node with specific ID from the internal storage if available or creates a new one
 /// </summary>
 /// <param name="nodeId">The ID of the node</param>
 /// <returns>The node with specific ID</returns>
 private Node GetOrCreateNode(int nodeId, Dictionary<int, Node> usedNodes)
 {
     if (usedNodes.ContainsKey(nodeId) == false) {
         Node n = new Node();
         usedNodes.Add(nodeId, n);
         _nodes.Add(n);
         return n;
     }
     else {
         return usedNodes[nodeId];
     }
 }
Beispiel #7
0
        public void NodeConstructorParameterlessInitializesProperties()
        {
            Node target = new Node();

            Assert.NotNull(target.Connections);
        }