Ejemplo n.º 1
0
        public void TryCreateFor_NonRazorLSPBuffer_ReturnsFalse()
        {
            // Arrange
            var uri         = new Uri("C:/path/to/file.razor");
            var uriProvider = Mock.Of <FileUriProvider>(provider => provider.GetOrCreate(It.IsAny <ITextBuffer>()) == uri);
            var factory     = new HtmlVirtualDocumentFactory(ContentTypeRegistry, TextBufferFactory, TextDocumentFactoryService, uriProvider);

            // Act
            var result = factory.TryCreateFor(NonRazorLSPBuffer, out var virtualDocument);

            // Assert
            Assert.False(result);
            Assert.Null(virtualDocument);
        }
Ejemplo n.º 2
0
        public void TryCreateFor_RazorLSPBuffer_ReturnsHtmlVirtualDocumentAndTrue()
        {
            // Arrange
            var uri         = new Uri("C:/path/to/file.razor");
            var uriProvider = Mock.Of <FileUriProvider>(provider => provider.GetOrCreate(RazorLSPBuffer) == uri);
            var factory     = new HtmlVirtualDocumentFactory(ContentTypeRegistry, TextBufferFactory, TextDocumentFactoryService, uriProvider);

            // Act
            var result = factory.TryCreateFor(RazorLSPBuffer, out var virtualDocument);

            // Assert
            Assert.True(result);
            Assert.NotNull(virtualDocument);
            Assert.EndsWith(RazorLSPConstants.VirtualHtmlFileNameSuffix, virtualDocument.Uri.OriginalString, StringComparison.Ordinal);
        }
        public void TryCreateFor_RazorLSPBuffer_ReturnsHtmlVirtualDocumentAndTrue()
        {
            // Arrange
            var uri         = new Uri("C:/path/to/file.razor");
            var uriProvider = Mock.Of <FileUriProvider>(provider => provider.GetOrCreate(RazorLSPBuffer) == uri, MockBehavior.Strict);

            Mock.Get(uriProvider).Setup(p => p.AddOrUpdate(It.IsAny <ITextBuffer>(), It.IsAny <Uri>())).Verifiable();
            var factory = new HtmlVirtualDocumentFactory(ContentTypeRegistry, TextBufferFactory, TextDocumentFactoryService, uriProvider);

            // Act
            var result = factory.TryCreateFor(RazorLSPBuffer, out var virtualDocument);

            using (virtualDocument)
            {
                // Assert
                Assert.True(result);
                Assert.NotNull(virtualDocument);
                Assert.EndsWith(RazorLSPConstants.VirtualHtmlFileNameSuffix, virtualDocument.Uri.OriginalString, StringComparison.Ordinal);
            }
        }