Пример #1
0
 public static void AcceptCallsVisitTemplateDirectiveMethodOfSyntaxNodeVisitor()
 {
     var visitor = Substitute.For<SyntaxNodeVisitor>();
     var directive = new TemplateDirective(new DirectiveBlockStart(0), new DirectiveName(4, "template"), new Attribute[0], new BlockEnd(24));
     directive.Accept(visitor);
     visitor.Received().VisitTemplateDirective(directive);
 }
Пример #2
0
        public static void AcceptCallsVisitTemplateDirectiveMethodOfSyntaxNodeVisitor()
        {
            var visitor   = Substitute.For <SyntaxNodeVisitor>();
            var directive = new TemplateDirective(new DirectiveBlockStart(0), new DirectiveName(4, "template"), new Attribute[0], new BlockEnd(24));

            directive.Accept(visitor);
            visitor.Received().VisitTemplateDirective(directive);
        }
Пример #3
0
 public static void CultureReturnsValueOfCultureAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(14, "culture"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "en-US"), new DoubleQuote(22)) },
         new BlockEnd(24));
     Assert.Equal("en-US", directive.Culture);
 }
Пример #4
0
 public static void CompilerOptionsReturnsValueOfCompilerOptionsAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(14, "compilerOptions"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "optimizer+"), new DoubleQuote(22)) },
         new BlockEnd(24));
     Assert.Equal("optimizer+", directive.CompilerOptions);
 }
Пример #5
0
        public static void VisitTemplateDirectiveCallsVisitDirectiveToAllowProcessingAllDirectivesPolymorphically()
        {
            var visitor           = Substitute.ForPartsOf <SyntaxNodeVisitor>();
            var templateDirective = new TemplateDirective(new DirectiveBlockStart(0), new DirectiveName(0, "template"), Enumerable.Empty <Attribute>(), new BlockEnd(0));

            visitor.VisitTemplateDirective(templateDirective);
            visitor.Received().VisitDirective(templateDirective);
            Assert.Equal(typeof(Directive), typeof(TemplateDirective).BaseType);
        }
Пример #6
0
        public static void GetDescriptionReturnsDescriptionOfDirective()
        {
            var    directive = new TemplateDirective(new DirectiveBlockStart(0), new DirectiveName(4, "template"), new Attribute[0], new BlockEnd(24));
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(4, out description, out applicableTo));
            Assert.Contains("Specifies how the template should be processed", description, StringComparison.OrdinalIgnoreCase);
        }
Пример #7
0
        public static void InheritsAttributeReturnsValueOfInheritsAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(14, "inherits"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "TextTransformation"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal("TextTransformation", directive.Inherits);
        }
Пример #8
0
        public static void HostSpecificReturnsValueOfHostSpecificAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(14, "hostspecific"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "true"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal("true", directive.HostSpecific);
        }
Пример #9
0
        public static void LanguageReturnsValueOfLanguageAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(13, "language"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "C#"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal("C#", directive.Language);
        }
Пример #10
0
        public static void LinePragmasReturnsValueOfLinePragmasAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(13, "linePragmas"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "true"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal("true", directive.LinePragmas);
        }
Пример #11
0
        public static void VisibilityReturnsValueOfVisibilityAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(13, "visibility"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "internal"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal("internal", directive.Visibility);
        }
Пример #12
0
        public static void CompilerOptionsReturnsValueOfCompilerOptionsAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(14, "compilerOptions"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "optimizer+"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal("optimizer+", directive.CompilerOptions);
        }
Пример #13
0
        public static void CultureReturnsValueOfCultureAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(14, "culture"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "en-US"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal("en-US", directive.Culture);
        }
Пример #14
0
        public static void DebugReturnsValueOfDebugAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(14, "debug"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "true"), new DoubleQuote(22)) },
                new BlockEnd(24));

            Assert.Equal("true", directive.Debug);
        }
Пример #15
0
        public static void GetDescriptionReturnsDescriptionOfHostSpecificAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(14, "hostspecific"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "true"), new DoubleQuote(22)) },
                new BlockEnd(24));
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(14, out description, out applicableTo));
            Assert.Contains("host", description, StringComparison.OrdinalIgnoreCase);
        }
Пример #16
0
        public static void GetDescriptionReturnsDescriptionOfInheritsAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(14, "inherits"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "TextTransformation"), new DoubleQuote(22)) },
                new BlockEnd(24));
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(14, out description, out applicableTo));
            Assert.Contains("base class", description, StringComparison.OrdinalIgnoreCase);
        }
Пример #17
0
        public static void GetDescriptionReturnsDescriptionOfVisibilityAttribute()
        {
            var directive = new TemplateDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "template"),
                new[] { new Attribute(new AttributeName(13, "visibility"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "internal"), new DoubleQuote(22)) },
                new BlockEnd(24));
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(14, out description, out applicableTo));
            Assert.Contains("visibility", description, StringComparison.OrdinalIgnoreCase);
        }
Пример #18
0
        public static void ValidateDoesNotReturnErrorsWhenNoAttributesAreSpecified()
        {
            var directive = new TemplateDirective(new DirectiveBlockStart(0), new DirectiveName(4, "template"), new Attribute[0], new BlockEnd(24));

            Assert.False(directive.Validate().Any());
        }
Пример #19
0
 public static void InheritsAttributeReturnsValueOfInheritsAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(14, "inherits"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "TextTransformation"), new DoubleQuote(22)) },
         new BlockEnd(24));
     Assert.Equal("TextTransformation", directive.Inherits);
 }
Пример #20
0
 public static void HostSpecificReturnsValueOfHostSpecificAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(14, "hostspecific"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "true"), new DoubleQuote(22)) },
         new BlockEnd(24));
     Assert.Equal("true", directive.HostSpecific);
 }
Пример #21
0
 public static void LanguageReturnsValueOfLanguageAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(13, "language"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "C#"), new DoubleQuote(22)) },
         new BlockEnd(24));
     Assert.Equal("C#", directive.Language);
 }
Пример #22
0
 public static void DebugReturnsEmptyStringWhenDebugAttributeIsNotSpecified()
 {
     var directive = new TemplateDirective(new DirectiveBlockStart(0), new DirectiveName(4, "template"), new Attribute[0], new BlockEnd(24));
     Assert.Equal(string.Empty, directive.Debug);
 }
 public static void CompletionsReturnsWellKnownValuesWhenPositionIsWithinAttributeValue()
 {
     // <#@ template debug="" #>
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(13, "debug"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, string.Empty), new DoubleQuote(20)) },
         new BlockEnd(22));
     var builder = new TemplateCompletionBuilder(20);
     builder.Visit(directive);
     Assert.NotNull(builder.Completions);
     Assert.Equal("false", builder.Completions[0].DisplayText, StringComparer.OrdinalIgnoreCase);
     Assert.Equal("true", builder.Completions[1].DisplayText, StringComparer.OrdinalIgnoreCase);
 }
Пример #24
0
 public static void GetDescriptionReturnsDescriptionOfInheritsAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(14, "inherits"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "TextTransformation"), new DoubleQuote(22)) },
         new BlockEnd(24));
     string description;
     Span applicableTo;
     Assert.True(directive.TryGetDescription(14, out description, out applicableTo));
     Assert.Contains("base class", description, StringComparison.OrdinalIgnoreCase);
 }
Пример #25
0
 public static void DebugReturnsValueOfDebugAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(14, "debug"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "true"), new DoubleQuote(22)) },
         new BlockEnd(24));
     Assert.Equal("true", directive.Debug);            
 }
Пример #26
0
 public static void GetDescriptionReturnsDescriptionOfHostSpecificAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(14, "hostspecific"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, "true"), new DoubleQuote(22)) },
         new BlockEnd(24));
     string description;
     Span applicableTo;
     Assert.True(directive.TryGetDescription(14, out description, out applicableTo));
     Assert.Contains("host", description, StringComparison.OrdinalIgnoreCase);   
 }
 public static void CompletionReturnsNullWhenPositionIsInsideValueOfUnrecognizedAttribute()
 {
     // <#@ template debug="" #>
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(13, "foo"), new Equals(16), new DoubleQuote(17), new AttributeValue(18, string.Empty), new DoubleQuote(18)) },
         new BlockEnd(20));
     var builder = new TemplateCompletionBuilder(18);
     builder.Visit(directive);
     Assert.Null(builder.Completions);
 }
Пример #28
0
 protected internal virtual void VisitTemplateDirective(TemplateDirective node)
 {
     this.VisitDirective(node);
 }
Пример #29
0
 public static void GetDescriptionReturnsDescriptionOfVisibilityAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(13, "visibility"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "internal"), new DoubleQuote(22)) },
         new BlockEnd(24));
     string description;
     Span applicableTo;
     Assert.True(directive.TryGetDescription(14, out description, out applicableTo));
     Assert.Contains("visibility", description, StringComparison.OrdinalIgnoreCase);
 }
Пример #30
0
 public static void ValidateDoesNotReturnErrorsWhenNoAttributesAreSpecified()
 {
     var directive = new TemplateDirective(new DirectiveBlockStart(0), new DirectiveName(4, "template"), new Attribute[0], new BlockEnd(24));
     Assert.False(directive.Validate().Any());
 }
Пример #31
0
        public static void CultureReturnsEmptyStringWhenCultureAttributeIsNotSpecified()
        {
            var directive = new TemplateDirective(new DirectiveBlockStart(0), new DirectiveName(4, "template"), new Attribute[0], new BlockEnd(24));

            Assert.Equal(string.Empty, directive.Culture);
        }
Пример #32
0
 public static void VisibilityReturnsValueOfVisibilityAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(13, "visibility"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "internal"), new DoubleQuote(22)) },
         new BlockEnd(24));
     Assert.Equal("internal", directive.Visibility);
 }
Пример #33
0
 public static void VisitTemplateDirectiveCallsVisitDirectiveToAllowProcessingAllDirectivesPolymorphically()
 {
     var visitor = Substitute.ForPartsOf<SyntaxNodeVisitor>();
     var templateDirective = new TemplateDirective(new DirectiveBlockStart(0), new DirectiveName(0, "template"), Enumerable.Empty<Attribute>(), new BlockEnd(0));
     visitor.VisitTemplateDirective(templateDirective);
     visitor.Received().VisitDirective(templateDirective);
     Assert.Equal(typeof(Directive), typeof(TemplateDirective).BaseType);
 }
Пример #34
0
 public static void LinePragmasReturnsValueOfLinePragmasAttribute()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(13, "linePragmas"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "true"), new DoubleQuote(22)) },
         new BlockEnd(24));
     Assert.Equal("true", directive.LinePragmas);
 }
 public static void CompletionsReturnsAttributeValuesWithDescriptions()
 {
     // <#@ template debug="" #>
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(13, "debug"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, string.Empty), new DoubleQuote(20)) },
         new BlockEnd(22));
     var builder = new TemplateCompletionBuilder(20);
     builder.Visit(directive);
     foreach (Completion completion in builder.Completions)
     {
         Assert.False(string.IsNullOrEmpty(completion.Description), completion.DisplayText + " completion should have a description.");
     }
 }
Пример #36
0
 protected internal virtual void VisitTemplateDirective(TemplateDirective node)
 {            
     this.VisitDirective(node);
 }
 public static void NodeReturnsNullWhenPositionIsOutsideOfAttributeValue()
 {
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(13, "debug"), new Equals(18), new DoubleQuote(19), new AttributeValue(20, string.Empty), new DoubleQuote(20)) },
         new BlockEnd(22));
     var builder = new TemplateCompletionBuilder(19);
     builder.Visit(directive);
     Assert.Null(builder.Node);
 }
Пример #38
0
 public static void GetDescriptionReturnsDescriptionOfDirective()
 {
     var directive = new TemplateDirective(new DirectiveBlockStart(0), new DirectiveName(4, "template"), new Attribute[0], new BlockEnd(24));
     string description;
     Span applicableTo;
     Assert.True(directive.TryGetDescription(4, out description, out applicableTo));
     Assert.Contains("Specifies how the template should be processed", description, StringComparison.OrdinalIgnoreCase);
 }