Ejemplo n.º 1
0
        /// <summary>
        /// Applies the known conventions to the specified node.
        /// </summary>
        /// <param name="node">The node to apply the conventions to.</param>
        public void ApplyConventions(IGraphNode node)
        {
            for (int i = 0; i< nodeConventions.Count; i++)
            {
                var convention = nodeConventions[i];
                var nodeInfo = new NodeInfo(node.Name, node.Tag);

                if (convention.ShouldApply(nodeInfo))
                {
                    convention.Apply(nodeInfo, new NodeExpression(node));
                }
            }
        }
Ejemplo n.º 2
0
        public void ApplyConventions_Node_Should_Not_Apply_Conventions_When_Should_Apply_Is_False()
        {
            var conventionTracker = new ConventionTracker();
            var convention = MockRepository.GenerateMock<INodeConvention>();
            var graphNode = new GraphNode("a");
            var nodeInfo = new NodeInfo(graphNode.Name, graphNode.Tag);

            convention.Expect(x => x.ShouldApply(nodeInfo))
                .IgnoreArguments()
                .Return(false)
                .Repeat.Once();

            convention.Expect(x => x.Apply(null, null))
                .IgnoreArguments()
                .Repeat.Never();
                
            conventionTracker.AddConvention(convention);
            conventionTracker.ApplyConventions(graphNode);

            convention.VerifyAllExpectations();
        }
Ejemplo n.º 3
0
        public void ApplyConventions_Node_Should_Apply_Conventions()
        {
            var conventionTracker = new ConventionTracker();
            var convention = MockRepository.GenerateMock<INodeConvention>();
            var graphNode = new GraphNode("a");
            var nodeInfo = new NodeInfo(graphNode.Name, graphNode.Tag);

            convention.Expect(x => x.ShouldApply(nodeInfo))
                .IgnoreArguments()
                .Constraints(Is.Matching<INodeInfo>(x => x.Name == "a"))
                .Return(true)
                .Repeat.Once();

            convention.Expect(x => x.Apply(null, null)).IgnoreArguments()
                .Constraints(Is.Matching<INodeInfo>(x => x.Name == graphNode.Name && x.Tag == graphNode.Tag), Is.Matching<INodeExpression>(x => x != null))
                .Repeat.Once();
            
            conventionTracker.AddConvention(convention);
            conventionTracker.ApplyConventions(graphNode);

            convention.VerifyAllExpectations();
        }