public async Task GetDescriptionAsync_DoesNotAddDescriptionWhenPropertyAbsent() { // Arrange var document = CreateDocument(); var item = CompletionItem.Create("TestDirective"); var codeDocumentProvider = new Mock <RazorCodeDocumentProvider>(); var completionProvider = new RazorDirectiveCompletionProvider(new Lazy <RazorCodeDocumentProvider>(() => codeDocumentProvider.Object)); // Act var description = await completionProvider.GetDescriptionAsync(document, item, CancellationToken.None); // Assert Assert.Empty(description.TaggedParts); Assert.Equal(string.Empty, description.Text); }
public async Task GetDescriptionAsync_AddsDirectiveDescriptionIfPropertyExists() { // Arrange var document = CreateDocument(); var expectedDescription = "The expected description"; var item = CompletionItem.Create("TestDirective") .WithProperties((new Dictionary <string, string>() { [RazorDirectiveCompletionProvider.DescriptionKey] = expectedDescription, }).ToImmutableDictionary()); var codeDocumentProvider = new Mock <RazorCodeDocumentProvider>(); var completionProvider = new RazorDirectiveCompletionProvider(new Lazy <RazorCodeDocumentProvider>(() => codeDocumentProvider.Object)); // Act var description = await completionProvider.GetDescriptionAsync(document, item, CancellationToken.None); // Assert var part = Assert.Single(description.TaggedParts); Assert.Equal(TextTags.Text, part.Tag); Assert.Equal(expectedDescription, part.Text); Assert.Equal(expectedDescription, description.Text); }