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);
 }
 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);
 }
 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);
 }
 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);
 }
 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);
 }
 protected internal virtual void VisitCustomDirective(CustomDirective node)
 {
     this.VisitDirective(node);
 }
 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());
 }
 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);
 }
 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);
 }