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