public void Execute_DoesNotImportNonFileScopedSinglyOccurringDirectives_Block()
        {
            // Arrange
            var codeBlockDirective  = DirectiveDescriptor.CreateCodeBlockDirective("code", b => b.AddStringToken());
            var razorBlockDirective = DirectiveDescriptor.CreateRazorBlockDirective("razor", b => b.AddStringToken());
            var phase  = new DefaultRazorIntermediateNodeLoweringPhase();
            var engine = RazorEngine.CreateEmpty(b =>
            {
                b.Phases.Add(phase);
                b.Features.Add(new DefaultRazorCodeGenerationOptionsFeature(designTime: false));
                b.AddDirective(codeBlockDirective);
                b.AddDirective(razorBlockDirective);
            });
            var options = RazorParserOptions.Create(builder =>
            {
                builder.Directives.Add(codeBlockDirective);
                builder.Directives.Add(razorBlockDirective);
            });
            var importSource = TestRazorSourceDocument.Create(
                @"@code ""code block"" { }
@razor ""razor block"" { }",
                filePath: "testImports.cshtml");
            var codeDocument = TestRazorCodeDocument.Create("<p>NonDirective</p>");

            codeDocument.SetSyntaxTree(RazorSyntaxTree.Parse(codeDocument.Source, options));
            codeDocument.SetImportSyntaxTrees(new[] { RazorSyntaxTree.Parse(importSource, options) });

            // Act
            phase.Execute(codeDocument);

            // Assert
            var documentNode = codeDocument.GetDocumentIntermediateNode();
            var directives   = documentNode.Children.OfType <DirectiveIntermediateNode>();

            Assert.Empty(directives);
        }
        public void Execute_CreatesClassStructure()
        {
            // Arrange
            var documentNode = new DocumentIntermediateNode()
            {
                Options = RazorCodeGenerationOptions.CreateDefault(),
            };

            var pass = new DefaultDocumentClassifierPass();

            pass.Engine = RazorEngine.CreateEmpty(b => { });

            // Act
            pass.Execute(TestRazorCodeDocument.CreateEmpty(), documentNode);

            // Assert
            Assert.Equal("default", documentNode.DocumentKind);

            var @namespace = SingleChild <NamespaceDeclarationIntermediateNode>(documentNode);
            var @class     = SingleChild <ClassDeclarationIntermediateNode>(@namespace);
            var method     = SingleChild <MethodDeclarationIntermediateNode>(@class);

            NoChildren(method);
        }