public void GetOrCreate_NoTextDocument_MemoizesGeneratedUri()
        {
            // Arrange
            var uriProvider = new DefaultFileUriProvider(Mock.Of <ITextDocumentFactoryService>());

            // Act
            var uri1 = uriProvider.GetOrCreate(TextBuffer);
            var uri2 = uriProvider.GetOrCreate(TextBuffer);

            // Assert
            Assert.NotNull(uri1);
            Assert.Same(uri1, uri2);
        }
        public void GetOrCreate_NoTextDocument_MemoizesGeneratedUri()
        {
            // Arrange
            var textDocumentFactoryService = new Mock <ITextDocumentFactoryService>(MockBehavior.Strict);

            textDocumentFactoryService.Setup(s => s.TryGetTextDocument(TextBuffer, out It.Ref <ITextDocument> .IsAny)).Returns(false);
            var uriProvider = new DefaultFileUriProvider(textDocumentFactoryService.Object);

            // Act
            var uri1 = uriProvider.GetOrCreate(TextBuffer);
            var uri2 = uriProvider.GetOrCreate(TextBuffer);

            // Assert
            Assert.NotNull(uri1);
            Assert.Same(uri1, uri2);
        }
        public void GetOrCreate_NoTextDocument_Creates()
        {
            // Arrange
            var uriProvider = new DefaultFileUriProvider(Mock.Of <ITextDocumentFactoryService>());

            // Act
            var uri = uriProvider.GetOrCreate(TextBuffer);

            // Assert
            Assert.NotNull(uri);
        }
        public void GetOrCreate_TurnsTextDocumentFilePathIntoUri()
        {
            // Arrange
            var factory          = new Mock <ITextDocumentFactoryService>();
            var expectedFilePath = "C:/path/to/file.razor";
            var textDocument     = Mock.Of <ITextDocument>(document => document.FilePath == expectedFilePath);

            factory.Setup(f => f.TryGetTextDocument(TextBuffer, out textDocument))
            .Returns(true);
            var uriProvider = new DefaultFileUriProvider(factory.Object);

            // Act
            var uri = uriProvider.GetOrCreate(TextBuffer);

            // Assert
            Assert.Equal(expectedFilePath, uri.OriginalString);
        }