private RazorDirectiveAttributeCompletionSource CreateCompletionSource() { var source = new RazorDirectiveAttributeCompletionSource( Dispatcher, Mock.Of <VisualStudioRazorParser>(), Mock.Of <RazorCompletionFactsService>(), Mock.Of <ICompletionBroker>(), Mock.Of <VisualStudioDescriptionFactory>()); return(source); }
// Internal for testing internal IAsyncCompletionSource CreateCompletionSource(ITextBuffer razorBuffer) { if (!razorBuffer.Properties.TryGetProperty(typeof(VisualStudioRazorParser), out VisualStudioRazorParser parser)) { // Parser hasn't been associated with the text buffer yet. return(null); } var completionSource = new RazorDirectiveAttributeCompletionSource(_foregroundDispatcher, parser, _completionFactsService, _completionBroker, _descriptionFactory); return(completionSource); }
public async Task GetDescriptionAsync_DescriptionData_AsksFactoryForDescription() { // Arrange var expectedResult = new ContainerElement(ContainerElementStyle.Wrapped); var description = new AttributeCompletionDescription(Array.Empty <AttributeDescriptionInfo>()); var descriptionFactory = Mock.Of <VisualStudioDescriptionFactory>(factory => factory.CreateClassifiedDescription(description) == expectedResult); var source = new RazorDirectiveAttributeCompletionSource( Dispatcher, Mock.Of <VisualStudioRazorParser>(), Mock.Of <RazorCompletionFactsService>(), Mock.Of <ICompletionBroker>(), descriptionFactory); var completionSessionSource = Mock.Of <IAsyncCompletionSource>(); var completionItem = new CompletionItem("@random", completionSessionSource); completionItem.Properties.AddProperty(RazorDirectiveAttributeCompletionSource.DescriptionKey, description); // Act var result = await source.GetDescriptionAsync(session : null, completionItem, CancellationToken.None); // Assert Assert.Equal(expectedResult, result); }