Ejemplo n.º 1
0
        public static void ValidateReturnsErrorWhenProcessorAttributeIsNotSpecified()
        {
            var           directive = new CustomDirective(new DirectiveBlockStart(0), new DirectiveName(4, "custom"), new Attribute[0], new BlockEnd(24));
            TemplateError error     = directive.Validate().Single();

            Assert.Contains("Processor", error.Message, StringComparison.OrdinalIgnoreCase);
        }
Ejemplo n.º 2
0
        public static void AcceptCallsVisitCustomDirectiveMethodOfSyntaxNodeVisitor()
        {
            var visitor   = Substitute.For <SyntaxNodeVisitor>();
            var directive = new CustomDirective(new DirectiveBlockStart(0), new DirectiveName(4, "custom"), new Attribute[0], new BlockEnd(24));

            directive.Accept(visitor);
            visitor.Received().VisitCustomDirective(directive);
        }
Ejemplo n.º 3
0
        public static void VisitDirectiveCallsVisitNonterminalNodeToAllowProcessingAllNonterminalNodesPolymorphically()
        {
            var visitor   = Substitute.ForPartsOf <SyntaxNodeVisitor>();
            var directive = new CustomDirective(new DirectiveBlockStart(0), new DirectiveName(0, "custom"), Enumerable.Empty <Attribute>(), new BlockEnd(0));

            visitor.VisitDirective(directive);
            visitor.Received().VisitNonterminalNode(directive);
            Assert.Equal(typeof(NonterminalNode), typeof(Directive).BaseType);
        }
Ejemplo n.º 4
0
        public static void GetDescriptionReturnsDescriptionOfDirective()
        {
            var    directive = new CustomDirective(new DirectiveBlockStart(0), new DirectiveName(4, "custom"), new Attribute[0], new BlockEnd(24));
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(4, out description, out applicableTo));
            Assert.Contains("directive", description, StringComparison.OrdinalIgnoreCase);
        }
Ejemplo n.º 5
0
        public static void ProcessorReturnsValueOfProcessorAttribute()
        {
            var directive = new CustomDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "custom"),
                new[] { new Attribute(new AttributeName(13, "processor"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "CustomProcessor"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal("CustomProcessor", directive.Processor);
        }
Ejemplo n.º 6
0
        public static void ValidateReturnsNoErrorsWhenDirectiveContainsUnrecognizedAttributes()
        {
            var a1        = new Attribute(new AttributeName(13, "processor"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "CustomProcessor"), new DoubleQuote(22));
            var a2        = new Attribute(new AttributeName(24, "custom"), new Equals(30), new DoubleQuote(31), new AttributeValue(32, "CustomValue"), new DoubleQuote(43));
            var directive = new CustomDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "custom"),
                new[] { a1, a2 },
                new BlockEnd(45));

            Assert.False(directive.Validate().Any());
        }
Ejemplo n.º 7
0
        public static void GetDescriptionReturnsDescriptionOfProcessorAttribute()
        {
            var directive = new CustomDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "custom"),
                new[] { new Attribute(new AttributeName(13, "processor"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "CustomProcessor"), new DoubleQuote(22)) },
                new BlockEnd(24));
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(13, out description, out applicableTo));
            Assert.Contains("processor", description, StringComparison.OrdinalIgnoreCase);
        }
Ejemplo n.º 8
0
 protected internal virtual void VisitCustomDirective(CustomDirective node)
 {
     this.VisitDirective(node);
 }
Ejemplo n.º 9
0
        public static void ProcessorReturnsEmptyStringWhenProcessorAttributeIsNotSpecified()
        {
            var directive = new CustomDirective(new DirectiveBlockStart(0), new DirectiveName(4, "custom"), new Attribute[0], new BlockEnd(24));

            Assert.Equal(string.Empty, directive.Processor);
        }