예제 #1
0
        public void Constructor_Should_Save_Arguments() {
            var fromNode = MockRepository.GenerateMock<IGraphNode>();
            var toNode = MockRepository.GenerateMock<IGraphNode>();

            var edge = new DirectedEdge(new NodeTarget(fromNode), new NodeTarget(toNode));
            Assert.AreSame(fromNode, edge.From.Node);
            Assert.AreSame(toNode, edge.To.Node);
        }
예제 #2
0
        public void Add_Should_Add_Edge_To_Collection() {
            var tracker = new EdgeTracker();

            var node1 = MockRepository.GenerateMock<IGraphNode>();
            var node2 = MockRepository.GenerateMock<IGraphNode>();

            var edge = new DirectedEdge(new NodeTarget(node1), new NodeTarget(node2));
            tracker.AddEdge(edge);
            Assert.AreEqual(tracker.Edges.Count(), 1);
            Assert.AreSame(tracker.Edges.First(), edge);
        }
예제 #3
0
        public void AddEdge_Should_Add_Edge_To_Edge_Collection() {

            var node1 = MockRepository.GenerateMock<IGraphNode>();
            var node2 = MockRepository.GenerateMock<IGraphNode>();
            var edge = new DirectedEdge(new NodeTarget(node1), new NodeTarget(node2));

            var graph = new TestGraph();

            graph.AddEdge(edge);

            Assert.AreEqual(graph.Edges.Count(), 1);
            Assert.AreSame(graph.Edges.First(), edge);
        }
예제 #4
0
        private static void AssertAttributeAdded(Action<IEdgeExpression> action, Type attributeType, object attributeValue, Action<IEdge> customAsserts) {
            var node1 = MockRepository.GenerateMock<IGraphNode>();
            var node2 = MockRepository.GenerateMock<IGraphNode>();
            var edge = new DirectedEdge(new NodeTarget(node1), new NodeTarget(node2));

            var expression = new EdgeExpression(edge);
            action(expression);

            Assert.AreEqual(edge.Attributes.CurrentAttributes.Count, 1);

            var attribute = edge.Attributes.CurrentAttributes[0];
            Assert.IsInstanceOfType(attributeType, attribute);
            Assert.AreEqual(attribute.Value, attributeValue);

            if (customAsserts != null) {
                customAsserts(edge);
            }
        }
예제 #5
0
        public void WithEdgeURL_Should_Set_URL_And_Target()
        {
            var node1 = MockRepository.GenerateMock<IGraphNode>();
            var node2 = MockRepository.GenerateMock<IGraphNode>();
            var edge = new DirectedEdge(new NodeTarget(node1), new NodeTarget(node2));

            var expression = new EdgeExpression(edge);
            Assert.IsNotNull(expression.WithEdgeURL("http://www.google.com", "_new"));

            Assert.AreEqual(edge.Attributes.CurrentAttributes.Count, 2);

            var attribute = edge.Attributes.CurrentAttributes[0];
            Assert.IsInstanceOfType(typeof(EdgeURLAttribute), attribute);
            Assert.AreEqual(attribute.Value, "http://www.google.com");

            attribute = edge.Attributes.CurrentAttributes[1];
            Assert.IsInstanceOfType(typeof(EdgeTargetAttribute), attribute);
            Assert.AreEqual(attribute.Value, "_new");
        }