コード例 #1
0
 public static void AcceptCallsVisitIncludeDirectiveMethodOfSyntaxNodeVisitor()
 {
     var visitor = Substitute.For<SyntaxNodeVisitor>();
     var directive = new IncludeDirective(new DirectiveBlockStart(0), new DirectiveName(4, "include"), new Attribute[0], new BlockEnd(12));
     directive.Accept(visitor);
     visitor.Received().VisitIncludeDirective(directive);
 }
コード例 #2
0
        public static void ValidateReturnsErrorWhenFileAttributeIsNotSpecified()
        {
            var           directive = new IncludeDirective(new DirectiveBlockStart(0), new DirectiveName(4, "include"), new Attribute[0], new BlockEnd(12));
            TemplateError error     = directive.Validate().Single();

            Assert.Contains("File", error.Message, StringComparison.OrdinalIgnoreCase);
        }
コード例 #3
0
 public static void GetDescriptionReturnsDescriptionOfDirective()
 {
     var directive = new IncludeDirective(new DirectiveBlockStart(0), new DirectiveName(4, "include"), new Attribute[0], new BlockEnd(12));
     string description;
     Span applicableTo;
     Assert.True(directive.TryGetDescription(4, out description, out applicableTo));            
     Assert.Contains("text from another file", description, StringComparison.OrdinalIgnoreCase);
 }
コード例 #4
0
        public static void AcceptCallsVisitIncludeDirectiveMethodOfSyntaxNodeVisitor()
        {
            var visitor   = Substitute.For <SyntaxNodeVisitor>();
            var directive = new IncludeDirective(new DirectiveBlockStart(0), new DirectiveName(4, "include"), new Attribute[0], new BlockEnd(12));

            directive.Accept(visitor);
            visitor.Received().VisitIncludeDirective(directive);
        }
コード例 #5
0
 public static void FileReturnsValueOfFileAttribute()
 {
     var directive = new IncludeDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "include"),
         new[] { new Attribute(new AttributeName(12, "file"), new Equals(16), new DoubleQuote(17), new AttributeValue(18, "template.tt"), new DoubleQuote(29)) },
         new BlockEnd(30));
     Assert.Equal("template.tt", directive.File);
 }
コード例 #6
0
        public static void VisitIncludeDirectiveCallsVisitDirectiveToAllowProcessingAllDirectivesPolymorphically()
        {
            var visitor          = Substitute.ForPartsOf <SyntaxNodeVisitor>();
            var includeDirective = new IncludeDirective(new DirectiveBlockStart(0), new DirectiveName(0, "include"), Enumerable.Empty <Attribute>(), new BlockEnd(0));

            visitor.VisitIncludeDirective(includeDirective);
            visitor.Received().VisitDirective(includeDirective);
            Assert.Equal(typeof(Directive), typeof(IncludeDirective).BaseType);
        }
コード例 #7
0
        public static void GetDescriptionReturnsDescriptionOfDirective()
        {
            var    directive = new IncludeDirective(new DirectiveBlockStart(0), new DirectiveName(4, "include"), new Attribute[0], new BlockEnd(12));
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(4, out description, out applicableTo));
            Assert.Contains("text from another file", description, StringComparison.OrdinalIgnoreCase);
        }
コード例 #8
0
        public static void FileReturnsValueOfFileAttribute()
        {
            var directive = new IncludeDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "include"),
                new[] { new Attribute(new AttributeName(12, "file"), new Equals(16), new DoubleQuote(17), new AttributeValue(18, "template.tt"), new DoubleQuote(29)) },
                new BlockEnd(30));

            Assert.Equal("template.tt", directive.File);
        }
コード例 #9
0
 public static void GetDescriptionReturnsDescriptionOfNameAttribute()
 {
     var directive = new IncludeDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "include"),
         new[] { new Attribute(new AttributeName(12, "file"), new Equals(16), new DoubleQuote(17), new AttributeValue(18, "template.tt"), new DoubleQuote(29)) },
         new BlockEnd(30));
     string description;
     Span applicableTo;
     Assert.True(directive.TryGetDescription(12, out description, out applicableTo));
     Assert.Contains("path to the included file", description, StringComparison.OrdinalIgnoreCase);
 }
コード例 #10
0
        public static void GetDescriptionReturnsDescriptionOfNameAttribute()
        {
            var directive = new IncludeDirective(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "include"),
                new[] { new Attribute(new AttributeName(12, "file"), new Equals(16), new DoubleQuote(17), new AttributeValue(18, "template.tt"), new DoubleQuote(29)) },
                new BlockEnd(30));
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(12, out description, out applicableTo));
            Assert.Contains("path to the included file", description, StringComparison.OrdinalIgnoreCase);
        }
コード例 #11
0
 public static void VisitIncludeDirectiveCallsVisitDirectiveToAllowProcessingAllDirectivesPolymorphically()
 {
     var visitor = Substitute.ForPartsOf<SyntaxNodeVisitor>();
     var includeDirective = new IncludeDirective(new DirectiveBlockStart(0), new DirectiveName(0, "include"), Enumerable.Empty<Attribute>(), new BlockEnd(0));
     visitor.VisitIncludeDirective(includeDirective);
     visitor.Received().VisitDirective(includeDirective);
     Assert.Equal(typeof(Directive), typeof(IncludeDirective).BaseType);
 }
コード例 #12
0
 public static void ValidateReturnsErrorWhenFileAttributeIsNotSpecified()
 {
     var directive = new IncludeDirective(new DirectiveBlockStart(0), new DirectiveName(4, "include"), new Attribute[0], new BlockEnd(12));
     TemplateError error = directive.Validate().Single();
     Assert.Contains("File", error.Message, StringComparison.OrdinalIgnoreCase);
 }
コード例 #13
0
 public static void FileReturnsEmptyStringWhenFileAttributeIsNotSpecified()
 {
     var directive = new IncludeDirective(new DirectiveBlockStart(0), new DirectiveName(4, "include"), new Attribute[0], new BlockEnd(12));
     Assert.Equal(string.Empty, directive.File);
 }
コード例 #14
0
 protected internal virtual void VisitIncludeDirective(IncludeDirective node)
 {
     this.VisitDirective(node);
 }
コード例 #15
0
 protected internal virtual void VisitIncludeDirective(IncludeDirective node)
 {
     this.VisitDirective(node);
 }
コード例 #16
0
        public static void FileReturnsEmptyStringWhenFileAttributeIsNotSpecified()
        {
            var directive = new IncludeDirective(new DirectiveBlockStart(0), new DirectiveName(4, "include"), new Attribute[0], new BlockEnd(12));

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