public void TryGetProjectPath_NoTextDocument_ReturnsFalse()
        {
            // Arrange
            var textBuffer          = Mock.Of <ITextBuffer>();
            var projectPathProvider = new GuestProjectPathProvider(
                JoinableTaskContext,
                Mock.Of <ITextDocumentFactoryService>(),
                Mock.Of <ProxyAccessor>(),
                SessionAccessor);

            // Act
            var result = projectPathProvider.TryGetProjectPath(textBuffer, out var filePath);

            // Assert
            Assert.False(result);
            Assert.Null(filePath);
        }
        public void TryGetProjectPath_NoTextDocument_ReturnsFalse()
        {
            // Arrange
            var textBuffer = Mock.Of <ITextBuffer>(MockBehavior.Strict);
            var textDocumentFactoryService = new Mock <ITextDocumentFactoryService>(MockBehavior.Strict);

            textDocumentFactoryService.Setup(s => s.TryGetTextDocument(It.IsAny <ITextBuffer>(), out It.Ref <ITextDocument> .IsAny)).Returns(false);
            var projectPathProvider = new GuestProjectPathProvider(
                JoinableTaskContext,
                textDocumentFactoryService.Object,
                Mock.Of <ProxyAccessor>(MockBehavior.Strict),
                SessionAccessor);

            // Act
            var result = projectPathProvider.TryGetProjectPath(textBuffer, out var filePath);

            // Assert
            Assert.False(result);
            Assert.Null(filePath);
        }
        public void GetHostProjectPath_AsksProxyForProjectPathAsync()
        {
            // Arrange
            var expectedGuestFilePath   = "/guest/path/index.cshtml";
            var expectedHostFilePath    = new Uri("vsls:/path/index.cshtml");
            var expectedHostProjectPath = new Uri("vsls:/path/project.csproj");
            var collabSession           = new TestCollaborationSession(isHost: true);
            var sessionAccessor         = Mock.Of <LiveShareSessionAccessor>(accessor => accessor.IsGuestSessionActive == true && accessor.Session == collabSession);

            var proxy               = Mock.Of <IProjectHierarchyProxy>(p => p.GetProjectPathAsync(expectedHostFilePath, CancellationToken.None) == Task.FromResult(expectedHostProjectPath));
            var proxyAccessor       = Mock.Of <ProxyAccessor>(accessor => accessor.GetProjectHierarchyProxy() == proxy);
            var textDocument        = Mock.Of <ITextDocument>(document => document.FilePath == expectedGuestFilePath);
            var projectPathProvider = new GuestProjectPathProvider(
                JoinableTaskContext,
                Mock.Of <ITextDocumentFactoryService>(),
                proxyAccessor,
                sessionAccessor);

            // Act
            var hostProjectPath = projectPathProvider.GetHostProjectPath(textDocument);

            // Assert
            Assert.Equal(expectedHostProjectPath, hostProjectPath);
        }