public void Create_FiltersFactoriesByContentType()
        {
            // Arrange
            var contentType = Mock.Of <IContentType>(ct =>
                                                     ct.TypeName == "text" &&
                                                     ct.IsOfType("NotText") == false,
                                                     MockBehavior.Strict
                                                     );
            var metadata = Mock.Of <IContentTypeMetadata>(md =>
                                                          md.ContentTypes == new[] { "NotText" },
                                                          MockBehavior.Strict);
            var textBuffer = Mock.Of <ITextBuffer>(b =>
                                                   b.ContentType == contentType,
                                                   MockBehavior.Strict);
            var uri          = new Uri("C:/path/to/file.razor");
            var uriProvider  = Mock.Of <FileUriProvider>(p => p.GetOrCreate(textBuffer) == uri, MockBehavior.Strict);
            var factory1     = Mock.Of <VirtualDocumentFactory>(MockBehavior.Strict);
            var factory1Lazy = new Lazy <VirtualDocumentFactory, IContentTypeMetadata>(() => factory1, metadata);
            var factory      = new DefaultLSPDocumentFactory(uriProvider, new[] { factory1Lazy, });

            // Act
            var lspDocument = factory.Create(textBuffer);

            // Assert
            Assert.Equal(0, lspDocument.VirtualDocuments.Count);
        }
        public void Create_MultipleFactories_CreatesLSPDocumentWithVirtualDocuments()
        {
            // Arrange
            var contentType = Mock.Of <IContentType>(ct =>
                                                     ct.TypeName == "text" &&
                                                     ct.IsOfType("text"),
                                                     MockBehavior.Strict
                                                     );
            var metadata = Mock.Of <IContentTypeMetadata>(md =>
                                                          md.ContentTypes == new[] { contentType.TypeName },
                                                          MockBehavior.Strict);
            var textBuffer = Mock.Of <ITextBuffer>(b =>
                                                   b.ContentType == contentType,
                                                   MockBehavior.Strict);
            var uri              = new Uri("C:/path/to/file.razor");
            var uriProvider      = Mock.Of <FileUriProvider>(p => p.GetOrCreate(textBuffer) == uri, MockBehavior.Strict);
            var virtualDocument1 = Mock.Of <VirtualDocument>(MockBehavior.Strict);
            var factory1         = Mock.Of <VirtualDocumentFactory>(f => f.TryCreateFor(textBuffer, out virtualDocument1) == true, MockBehavior.Strict);
            var factory1Lazy     = new Lazy <VirtualDocumentFactory, IContentTypeMetadata>(() => factory1, metadata);
            var virtualDocument2 = Mock.Of <VirtualDocument>(MockBehavior.Strict);
            var factory2         = Mock.Of <VirtualDocumentFactory>(f => f.TryCreateFor(textBuffer, out virtualDocument2) == true, MockBehavior.Strict);
            var factory2Lazy     = new Lazy <VirtualDocumentFactory, IContentTypeMetadata>(() => factory2, metadata);
            var factory          = new DefaultLSPDocumentFactory(uriProvider, new[] { factory1Lazy, factory2Lazy });

            // Act
            var lspDocument = factory.Create(textBuffer);

            // Assert
            Assert.Collection(
                lspDocument.VirtualDocuments,
                virtualDocument => Assert.Same(virtualDocument1, virtualDocument),
                virtualDocument => Assert.Same(virtualDocument2, virtualDocument));
        }
        public void Create_BuildsLSPDocumentWithTextBufferURI()
        {
            // Arrange
            var textBuffer  = Mock.Of <ITextBuffer>();
            var uri         = new Uri("C:/path/to/file.razor");
            var uriProvider = Mock.Of <FileUriProvider>(p => p.GetOrCreate(textBuffer) == uri);
            var factory     = new DefaultLSPDocumentFactory(uriProvider, Enumerable.Empty <VirtualDocumentFactory>());

            // Act
            var lspDocument = factory.Create(textBuffer);

            // Assert
            Assert.Same(uri, lspDocument.Uri);
        }
        public void Create_MultipleFactories_CreatesLSPDocumentWithVirtualDocuments()
        {
            // Arrange
            var textBuffer       = Mock.Of <ITextBuffer>();
            var uri              = new Uri("C:/path/to/file.razor");
            var uriProvider      = Mock.Of <FileUriProvider>(p => p.GetOrCreate(textBuffer) == uri);
            var virtualDocument1 = Mock.Of <VirtualDocument>();
            var factory1         = Mock.Of <VirtualDocumentFactory>(f => f.TryCreateFor(textBuffer, out virtualDocument1) == true);
            var virtualDocument2 = Mock.Of <VirtualDocument>();
            var factory2         = Mock.Of <VirtualDocumentFactory>(f => f.TryCreateFor(textBuffer, out virtualDocument2) == true);
            var factory          = new DefaultLSPDocumentFactory(uriProvider, new[] { factory1, factory2 });

            // Act
            var lspDocument = factory.Create(textBuffer);

            // Assert
            Assert.Collection(
                lspDocument.VirtualDocuments,
                virtualDocument => Assert.Same(virtualDocument1, virtualDocument),
                virtualDocument => Assert.Same(virtualDocument2, virtualDocument));
        }