Esempio n. 1
0
        public void TryGetWorkspaceFromHostProject_NoHostProject_ReturnsFalse()
        {
            // Arrange
            var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(Mock.Of <IBufferGraphFactoryService>(MockBehavior.Strict), Mock.Of <TextBufferProjectService>(s => s.GetHostProject(It.IsAny <ITextBuffer>()) == null, MockBehavior.Strict), TestWorkspace.Create());
            var textBuffer        = Mock.Of <ITextBuffer>(MockBehavior.Strict);

            // Act
            var result = workspaceAccessor.TryGetWorkspaceFromHostProject(textBuffer, out var workspace);

            // Assert
            Assert.False(result);
        }
        public void TryGetWorkspaceFromLiveShare_NoLiveShareProvider_ReturnsFalse()
        {
            // Arrange
            var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(Mock.Of <IBufferGraphFactoryService>(), Mock.Of <TextBufferProjectService>(), TestWorkspace.Create(), NoLiveShare);
            var textBuffer        = Mock.Of <ITextBuffer>();

            // Act
            var result = workspaceAccessor.TryGetWorkspaceFromLiveShare(textBuffer, out var workspace);

            // Assert
            Assert.False(result);
        }
Esempio n. 3
0
        public void TryGetWorkspaceFromHostProject_HasHostProject_ReturnsTrueWithDefaultWorkspace()
        {
            // Arrange
            var textBuffer        = Mock.Of <ITextBuffer>(MockBehavior.Strict);
            var projectService    = Mock.Of <TextBufferProjectService>(service => service.GetHostProject(textBuffer) == new object(), MockBehavior.Strict);
            var defaultWorkspace  = TestWorkspace.Create();
            var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(Mock.Of <IBufferGraphFactoryService>(MockBehavior.Strict), projectService, defaultWorkspace);

            // Act
            var result = workspaceAccessor.TryGetWorkspaceFromHostProject(textBuffer, out var workspace);

            // Assert
            Assert.True(result);
            Assert.Same(defaultWorkspace, workspace);
        }
        public void TryGetWorkspaceFromLiveShare_CanNotFindWorkspace_ReturnsFalse()
        {
            // Arrange
            Workspace nullWorkspace = null;
            var       liveShareWorkspaceProvider = new Mock <LiveShareWorkspaceProvider>();

            liveShareWorkspaceProvider.Setup(provider => provider.TryGetWorkspace(It.IsAny <ITextBuffer>(), out nullWorkspace))
            .Returns(false);
            var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(Mock.Of <IBufferGraphFactoryService>(), Mock.Of <TextBufferProjectService>(), TestWorkspace.Create(), liveShareWorkspaceProvider.Object);
            var textBuffer        = Mock.Of <ITextBuffer>();

            // Act
            var result = workspaceAccessor.TryGetWorkspaceFromLiveShare(textBuffer, out var workspace);

            // Assert
            Assert.False(result);
        }
        public void TryGetWorkspaceFromProjectionBuffer_NoProjectionBuffer_ReturnsFalse()
        {
            // Arrange
            var bufferGraph = new Mock <IBufferGraph>();

            bufferGraph.Setup(graph => graph.GetTextBuffers(It.IsAny <Predicate <ITextBuffer> >()))
            .Returns <Predicate <ITextBuffer> >(predicate => new Collection <ITextBuffer>());
            var bufferGraphService = new Mock <IBufferGraphFactoryService>();

            bufferGraphService.Setup(service => service.CreateBufferGraph(It.IsAny <ITextBuffer>()))
            .Returns(bufferGraph.Object);
            var workspaceAccessor = new DefaultVisualStudioWorkspaceAccessor(bufferGraphService.Object, Mock.Of <TextBufferProjectService>(), TestWorkspace.Create());
            var textBuffer        = Mock.Of <ITextBuffer>();

            // Act
            var result = workspaceAccessor.TryGetWorkspaceFromProjectionBuffer(textBuffer, out var workspace);

            // Assert
            Assert.False(result);
        }