Exemplo n.º 1
0
        public void WithTag_Should_Set_Tag_On_Edge() {
            var node1 = MockRepository.GenerateMock<IGraphNode>();
            var node2 = MockRepository.GenerateMock<IGraphNode>();
            var edge = new UndirectedEdge(new NodeTarget(node1), new NodeTarget(node2));

            var expression = new EdgeExpression(edge);
            expression.WithTag(5);
            
            Assert.AreEqual(edge.Tag, 5);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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");
        }