public void WriteDesignTimeDirective_ChildrenWithNoSource_WritesEmptyMethod_WithPragma()
    {
        // Arrange
        var extension = new DesignTimeDirectiveTargetExtension();
        var context   = TestCodeRenderingContext.CreateDesignTime();

        var node  = new DesignTimeDirectiveIntermediateNode();
        var token = new DirectiveTokenIntermediateNode()
        {
            Content        = "Value",
            DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String),
        };

        node.Children.Add(token);

        // Act
        extension.WriteDesignTimeDirective(context, node);

        // Assert
        var csharp = context.CodeWriter.GenerateCode();

        Assert.Equal(
            @"#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
",
            csharp,
            ignoreLineEndingDifferences: true);
    }
    public void WriteDesignTimeDirective_WithStringToken_WritesLambda()
    {
        // Arrange
        var extension = new DesignTimeDirectiveTargetExtension();
        var context   = TestCodeRenderingContext.CreateDesignTime();

        var node  = new DesignTimeDirectiveIntermediateNode();
        var token = new DirectiveTokenIntermediateNode()
        {
            Source         = new SourceSpan("test.cshtml", 0, 0, 0, 5),
            Content        = "Value",
            DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String),
        };
        var tokenWithQuotedContent = new DirectiveTokenIntermediateNode()
        {
            Source         = new SourceSpan("test.cshtml", 0, 0, 0, 5),
            Content        = "\"Value\"",
            DirectiveToken = DirectiveTokenDescriptor.CreateToken(DirectiveTokenKind.String),
        };

        node.Children.Add(token);
        node.Children.Add(tokenWithQuotedContent);

        // Act
        extension.WriteDesignTimeDirective(context, node);

        // Assert
        var csharp = context.CodeWriter.GenerateCode();

        Assert.Equal(
            @"#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
#nullable restore
#line 1 ""test.cshtml""
global::System.Object __typeHelper = ""Value"";

#line default
#line hidden
#nullable disable
}
))();
((System.Action)(() => {
#nullable restore
#line 1 ""test.cshtml""
global::System.Object __typeHelper = ""Value"";

#line default
#line hidden
#nullable disable
}
))();
}
#pragma warning restore 219
",
            csharp,
            ignoreLineEndingDifferences: true);
    }
    public void WriteDesignTimeDirective_NoChildren_WritesEmptyMethod_WithPragma()
    {
        // Arrange
        var extension = new DesignTimeDirectiveTargetExtension();
        var context   = TestCodeRenderingContext.CreateDesignTime();

        var node = new DesignTimeDirectiveIntermediateNode();

        // Act
        extension.WriteDesignTimeDirective(context, node);

        // Assert
        var csharp = context.CodeWriter.GenerateCode();

        Assert.Equal(
            @"#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
}
#pragma warning restore 219
",
            csharp,
            ignoreLineEndingDifferences: true);
    }