public void Execute_Inherits_SetsClassDeclarationBaseType()
    {
        // Arrange
        var engine = CreateEngine();
        var pass   = new InheritsDirectivePass()
        {
            Engine = engine,
        };

        var content        = "@inherits Hello<World[]>";
        var sourceDocument = TestRazorSourceDocument.Create(content);
        var codeDocument   = RazorCodeDocument.Create(sourceDocument);

        var irDocument = Lower(codeDocument, engine);

        // Act
        pass.Execute(codeDocument, irDocument);

        // Assert
        Children(
            irDocument,
            node => Assert.IsType <NamespaceDeclarationIntermediateNode>(node));

        var @namespace = irDocument.Children[0];

        Children(
            @namespace,
            node => Assert.IsType <ClassDeclarationIntermediateNode>(node));

        var @class = (ClassDeclarationIntermediateNode)@namespace.Children[0];

        Assert.Equal("Hello<World[]>", @class.BaseType);
    }
    public void Execute_SkipsDocumentWithNoClassNode()
    {
        // Arrange
        var engine = CreateEngine();
        var pass   = new InheritsDirectivePass()
        {
            Engine = engine,
        };

        var sourceDocument = TestRazorSourceDocument.Create("@inherits Hello<World[]>");
        var codeDocument   = RazorCodeDocument.Create(sourceDocument);

        var irDocument = new DocumentIntermediateNode();

        irDocument.Children.Add(new DirectiveIntermediateNode()
        {
            Directive = FunctionsDirective.Directive,
        });

        // Act
        pass.Execute(codeDocument, irDocument);

        // Assert
        Children(
            irDocument,
            node => Assert.IsType <DirectiveIntermediateNode>(node));
    }
        private DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument)
        {
            for (var i = 0; i < engine.Phases.Count; i++)
            {
                var phase = engine.Phases[i];
                phase.Execute(codeDocument);

                if (phase is IRazorDocumentClassifierPhase)
                {
                    break;
                }
            }

            // InheritsDirectivePass needs to run before ModelDirective.
            var pass = new InheritsDirectivePass()
            {
                Engine = engine
            };

            pass.Execute(codeDocument, codeDocument.GetDocumentIntermediateNode());

            return(codeDocument.GetDocumentIntermediateNode());
        }