public void GetDirectiveCompletionItems_ComponentDocument_DoesNotReturnsDefaultDirectivesAsCompletionItems()
        {
            // Arrange
            var syntaxTree = CreateSyntaxTree("@addTag", FileKinds.Component);

            // Act
            var completionItems = DirectiveCompletionItemProvider.GetDirectiveCompletionItems(syntaxTree);

            // Assert
            Assert.Empty(completionItems);
        }
        public void GetDirectiveCompletionItems_ReturnsDefaultDirectivesAsCompletionItems()
        {
            // Arrange
            var syntaxTree = CreateSyntaxTree("@addTag");

            // Act
            var completionItems = DirectiveCompletionItemProvider.GetDirectiveCompletionItems(syntaxTree);

            // Assert
            Assert.Collection(
                completionItems,
                item => AssertRazorCompletionItem(DefaultDirectives[0], item),
                item => AssertRazorCompletionItem(DefaultDirectives[1], item),
                item => AssertRazorCompletionItem(DefaultDirectives[2], item));
        }
        public void GetDirectiveCompletionItems_ReturnsCustomDirectivesAsCompletionItems()
        {
            // Arrange
            var customDirective = DirectiveDescriptor.CreateSingleLineDirective("custom", builder => builder.Description = "My Custom Directive.");
            var syntaxTree      = CreateSyntaxTree("@addTag", customDirective);

            // Act
            var completionItems = DirectiveCompletionItemProvider.GetDirectiveCompletionItems(syntaxTree);

            // Assert
            Assert.Collection(
                completionItems,
                item => AssertRazorCompletionItem(customDirective, item),
                item => AssertRazorCompletionItem(DefaultDirectives[0], item),
                item => AssertRazorCompletionItem(DefaultDirectives[1], item),
                item => AssertRazorCompletionItem(DefaultDirectives[2], item));
        }
        public void GetDirectiveCompletionItems_CodeBlockCommitCharacters()
        {
            // Arrange
            var customDirective = DirectiveDescriptor.CreateCodeBlockDirective("custom", builder =>
            {
                builder.DisplayName = "code";
                builder.Description = "My Custom Code Block Directive.";
            });
            var syntaxTree = CreateSyntaxTree("@cod", customDirective);

            // Act
            var completionItems = DirectiveCompletionItemProvider.GetDirectiveCompletionItems(syntaxTree);

            // Assert
            Assert.Collection(
                completionItems,
                item => AssertRazorCompletionItem("code", customDirective, item, DirectiveCompletionItemProvider.BlockDirectiveCommitCharacters),
                item => AssertRazorCompletionItem(DefaultDirectives[0], item),
                item => AssertRazorCompletionItem(DefaultDirectives[1], item),
                item => AssertRazorCompletionItem(DefaultDirectives[2], item));
        }
        public void GetDirectiveCompletionItems_UsesDisplayNamesWhenNotNull()
        {
            // Arrange
            var customDirective = DirectiveDescriptor.CreateSingleLineDirective("custom", builder =>
            {
                builder.DisplayName = "different";
                builder.Description = "My Custom Directive.";
            });
            var syntaxTree = CreateSyntaxTree("@addTag", customDirective);

            // Act
            var completionItems = DirectiveCompletionItemProvider.GetDirectiveCompletionItems(syntaxTree);

            // Assert
            Assert.Collection(
                completionItems,
                item => AssertRazorCompletionItem("different", customDirective, item),
                item => AssertRazorCompletionItem(DefaultDirectives[0], item),
                item => AssertRazorCompletionItem(DefaultDirectives[1], item),
                item => AssertRazorCompletionItem(DefaultDirectives[2], item));
        }