public static void AcceptCallsVisitOutputDirectiveMethodOfSyntaxNodeVisitor()
 {
     var visitor = Substitute.For<SyntaxNodeVisitor>();
     var directive = new OutputDirective(new DirectiveBlockStart(0), new DirectiveName(4, "output"), new Attribute[0], new BlockEnd(24));
     directive.Accept(visitor);
     visitor.Received().VisitOutputDirective(directive);
 }
        public static void AcceptCallsVisitOutputDirectiveMethodOfSyntaxNodeVisitor()
        {
            var visitor   = Substitute.For <SyntaxNodeVisitor>();
            var directive = new OutputDirective(new DirectiveBlockStart(0), new DirectiveName(4, "output"), new Attribute[0], new BlockEnd(24));

            directive.Accept(visitor);
            visitor.Received().VisitOutputDirective(directive);
        }
 public static void ExtensionReturnsValueOfExtensionAttribute()
 {
     var directive = new OutputDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "output"),
         new[] { new Attribute(new AttributeName(14, "extension"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, ".txt"), new DoubleQuote(22)) },
         new BlockEnd(24));
     Assert.Equal(".txt", directive.Extension);
 }
Beispiel #4
0
        public static void VisitOutputDirectiveCallsVisitDirectiveToAllowProcessingAllDirectivesPolymorphically()
        {
            var visitor         = Substitute.ForPartsOf <SyntaxNodeVisitor>();
            var outputDirective = new OutputDirective(new DirectiveBlockStart(0), new DirectiveName(0, "output"), Enumerable.Empty <Attribute>(), new BlockEnd(0));

            visitor.VisitOutputDirective(outputDirective);
            visitor.Received().VisitDirective(outputDirective);
            Assert.Equal(typeof(Directive), typeof(OutputDirective).BaseType);
        }
 public static void GetDescriptionReturnsDescriptionOfOutputDirective()
 {
     var directive = new OutputDirective(new DirectiveBlockStart(0), new DirectiveName(4, "output"), new Attribute[0], new BlockEnd(24));
     string description;
     Span applicableTo;
     Assert.True(directive.TryGetDescription(4, out description, out applicableTo));
     Assert.Contains("extension", description, StringComparison.OrdinalIgnoreCase);
     Assert.Contains("encoding", description, StringComparison.OrdinalIgnoreCase);
 }
 public static void EncodingReturnsValueOfEncodingAttribute()
 {
     var directive = new OutputDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "output"),
         new[] { new Attribute(new AttributeName(14, "encoding"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "utf-8"), new DoubleQuote(22)) },
         new BlockEnd(24));
     Assert.Equal("utf-8", directive.Encoding);
 }
        public static void EncodingReturnsValueOfEncodingAttribute()
        {
            var directive = new OutputDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "output"),
                new[] { new Attribute(new AttributeName(14, "encoding"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "utf-8"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal("utf-8", directive.Encoding);
        }
        public static void ExtensionReturnsValueOfExtensionAttribute()
        {
            var directive = new OutputDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "output"),
                new[] { new Attribute(new AttributeName(14, "extension"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, ".txt"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal(".txt", directive.Extension);
        }
        public static void ValidateDoesNotReturnErrorWhenEncodingAttributeIsNotSpecified()
        {
            var directive = new OutputDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "output"),
                new[] { new Attribute(new AttributeName(14, "extension"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, ".ext"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.False(directive.Validate().Any());
        }
        public static void GetDescriptionReturnsDescriptionOfOutputDirective()
        {
            var    directive = new OutputDirective(new DirectiveBlockStart(0), new DirectiveName(4, "output"), new Attribute[0], new BlockEnd(24));
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(4, out description, out applicableTo));
            Assert.Contains("extension", description, StringComparison.OrdinalIgnoreCase);
            Assert.Contains("encoding", description, StringComparison.OrdinalIgnoreCase);
        }
        public static void ValidateReturnsErrorWhenExtensionAttributeIsNotSpecified()
        {
            var directive = new OutputDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "output"),
                new[] { new Attribute(new AttributeName(14, "encoding"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "utf-8"), new DoubleQuote(22)) },
                new BlockEnd(24));
            TemplateError error = directive.Validate().Single();

            Assert.Contains("Extension", error.Message, StringComparison.OrdinalIgnoreCase);
        }
        public static void GetDescriptionReturnsDescriptionOfExtensionAttribute()
        {
            var directive = new OutputDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "output"),
                new[] { new Attribute(new AttributeName(14, "extension"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, ".txt"), new DoubleQuote(22)) },
                new BlockEnd(24));
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(14, out description, out applicableTo));
            Assert.Contains("Extension of the output file", description, StringComparison.OrdinalIgnoreCase);
        }
 public static void CompletionsReturnsAttributeNamesWhenPositionIsWithinAttributeName()
 {
     // <#@ output e="" #>
     var directive = new OutputDirective(
         new DirectiveBlockStart(0), 
         new DirectiveName(4, "output"), 
         new[] { new Attribute(new AttributeName(11, "e"), new Equals(12), new DoubleQuote(13), new AttributeValue(14, string.Empty), new DoubleQuote(14)) }, 
         new BlockEnd(16));
     var builder = new TemplateCompletionBuilder(12);
     builder.Visit(directive);
     Assert.NotNull(builder.Completions);
     Assert.Contains(builder.Completions, c => string.Equals(c.DisplayText, "encoding", StringComparison.OrdinalIgnoreCase));
     Assert.Contains(builder.Completions, c => string.Equals(c.DisplayText, "extension", StringComparison.OrdinalIgnoreCase));
 }
 public static void CompletionsReturnsNullWhenAllAttributesAreAlreadyPresentInDirective()
 {
     // <#@ output extension="txt" encoding="UTF8" #>
     var attributes = new[] 
     { 
         new Attribute(new AttributeName(11, "extension"), new Equals(20), new DoubleQuote(21), new AttributeValue(22, "txt"), new DoubleQuote(25)),
         new Attribute(new AttributeName(27, "encoding"), new Equals(35), new DoubleQuote(36), new AttributeValue(37, "UTF8"), new DoubleQuote(41)) 
     };
     var directive = new OutputDirective(new DirectiveBlockStart(0), new DirectiveName(4, "output"), attributes, new BlockEnd(43));
     var builder = new TemplateCompletionBuilder(35);
     builder.Visit(directive);
     Assert.Null(builder.Completions);
 }
 public static void VisitOutputDirectiveCallsVisitDirectiveToAllowProcessingAllDirectivesPolymorphically()
 {
     var visitor = Substitute.ForPartsOf<SyntaxNodeVisitor>();
     var outputDirective = new OutputDirective(new DirectiveBlockStart(0), new DirectiveName(0, "output"), Enumerable.Empty<Attribute>(), new BlockEnd(0));
     visitor.VisitOutputDirective(outputDirective);
     visitor.Received().VisitDirective(outputDirective);            
     Assert.Equal(typeof(Directive), typeof(OutputDirective).BaseType);
 }
 public static void EncodingReturnsEmptyStringWhenEncodingAttributeIsNotSpecified()
 {
     var directive = new OutputDirective(new DirectiveBlockStart(0), new DirectiveName(4, "output"), new Attribute[0], new BlockEnd(24));
     Assert.Equal(string.Empty, directive.Encoding);
 }
        public static void EncodingReturnsEmptyStringWhenEncodingAttributeIsNotSpecified()
        {
            var directive = new OutputDirective(new DirectiveBlockStart(0), new DirectiveName(4, "output"), new Attribute[0], new BlockEnd(24));

            Assert.Equal(string.Empty, directive.Encoding);
        }
 public static void GetDescriptionReturnsDescriptionOfEncodingAttribute()
 {
     var directive = new OutputDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "output"),
         new[] { new Attribute(new AttributeName(14, "encoding"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "utf-8"), new DoubleQuote(22)) },
         new BlockEnd(24));
     string description;
     Span applicableTo;
     Assert.True(directive.TryGetDescription(14, out description, out applicableTo));
     Assert.Contains("Encoding of the output file", description, StringComparison.OrdinalIgnoreCase);
 }
Beispiel #19
0
 protected internal virtual void VisitOutputDirective(OutputDirective node)
 {
     this.VisitDirective(node);
 }
 public static void CompletionsExcludeAttributesAlreadyPresentInDirective()
 {
     // <#@ output extension="txt" e="" #>
     var attributes = new[] 
     { 
         new Attribute(new AttributeName(11, "extension"), new Equals(20), new DoubleQuote(21), new AttributeValue(22, "txt"), new DoubleQuote(25)),
         new Attribute(new AttributeName(27, "e"), new Equals(28), new DoubleQuote(29), new AttributeValue(30, string.Empty), new DoubleQuote(30)) 
     };
     var directive = new OutputDirective(new DirectiveBlockStart(0), new DirectiveName(4, "output"), attributes, new BlockEnd(32));
     var builder = new TemplateCompletionBuilder(28);
     builder.Visit(directive);
     Assert.True(string.Equals(builder.Completions.Single().DisplayText, "encoding", StringComparison.OrdinalIgnoreCase));
 }
 public static void ValidateReturnsErrorWhenExtensionAttributeIsNotSpecified()
 {
     var directive = new OutputDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "output"),
         new[] { new Attribute(new AttributeName(14, "encoding"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "utf-8"), new DoubleQuote(22)) },
         new BlockEnd(24));
     TemplateError error = directive.Validate().Single();
     Assert.Contains("Extension", error.Message, StringComparison.OrdinalIgnoreCase);
 }
 public static void NodeReturnsNullWhenPositionIsOutsideOfAttributeName()
 {
     var directive = new OutputDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "output"),
         new[] { new Attribute(new AttributeName(11, "e"), new Equals(12), new DoubleQuote(13), new AttributeValue(14, string.Empty), new DoubleQuote(14)) },
         new BlockEnd(16));
     var builder = new TemplateCompletionBuilder(13);
     builder.Visit(directive);
     Assert.Null(builder.Node);
 }
  public static void ValidateDoesNotReturnErrorWhenEncodingAttributeIsNotSpecified()
  {
      var directive = new OutputDirective(
          new DirectiveBlockStart(0),
          new DirectiveName(4, "output"),
          new[] { new Attribute(new AttributeName(14, "extension"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, ".ext"), new DoubleQuote(22)) },
          new BlockEnd(24));
      Assert.False(directive.Validate().Any());
 }
 public static void CompletionsReturnsAttributeNamesWithDescriptions()
 {
     var directive = new OutputDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "output"),
         new[] { new Attribute(new AttributeName(11, "e"), new Equals(12), new DoubleQuote(13), new AttributeValue(14, string.Empty), new DoubleQuote(14)) },
         new BlockEnd(16));
     var builder = new TemplateCompletionBuilder(12);
     builder.Visit(directive);
     foreach (Completion completion in builder.Completions)
     {
         Assert.False(string.IsNullOrEmpty(completion.Description), completion.DisplayText + " completion should have a description.");
     }
 }
Beispiel #25
0
 protected internal virtual void VisitOutputDirective(OutputDirective node)
 {
     this.VisitDirective(node);
 }