MockSymbolNavigationServiceProvider.vb 3.5 KB
Newer Older
1 2 3
' Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

Imports System.Composition
4
Imports System.Threading
5 6 7 8
Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.Navigation

9
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Utilities
10 11 12 13 14 15
    ' Note: by default, TestWorkspace produces a composition from all assemblies except EditorServicesTest2.
    ' This type has to be defined here until we get that cleaned up. Otherwise, other tests may import it.
    <ExportWorkspaceServiceFactory(GetType(ISymbolNavigationService), ServiceLayer.Host), [Shared]>
    Public Class MockSymbolNavigationServiceProvider
        Implements IWorkspaceServiceFactory

B
beep boop 已提交
16
        Private _instance As MockSymbolNavigationService = New MockSymbolNavigationService()
17 18

        Public Function CreateService(workspaceServices As HostWorkspaceServices) As IWorkspaceService Implements IWorkspaceServiceFactory.CreateService
B
beep boop 已提交
19
            Return _instance
20 21 22 23 24
        End Function

        Friend Class MockSymbolNavigationService
            Implements ISymbolNavigationService

25 26 27
            Public TryNavigateToSymbolProvidedSymbol As ISymbol
            Public TryNavigateToSymbolProvidedProject As Project
            Public TryNavigateToSymbolProvidedUsePreviewTab As Boolean
28

29 30 31 32 33 34 35 36 37 38
            Public TrySymbolNavigationNotifyProvidedSymbol As ISymbol
            Public TrySymbolNavigationNotifyProvidedSolution As Solution
            Public TrySymbolNavigationNotifyReturnValue As Boolean = False

            Public WouldNavigateToSymbolProvidedSymbol As ISymbol
            Public WouldNavigateToSymbolProvidedSolution As Solution
            Public WouldNavigateToSymbolReturnValue As Boolean = False
            Public NavigationFilePathReturnValue As String = String.Empty
            Public NavigationLineNumberReturnValue As Integer = 0
            Public NavigationCharOffsetReturnValue As Integer = 0
39

R
Ravi Chande 已提交
40
            Public Function TryNavigateToSymbol(symbol As ISymbol, project As Project, cancellationToken As CancellationToken, Optional usePreviewTab As Boolean = False) As Boolean Implements ISymbolNavigationService.TryNavigateToSymbol
41 42 43
                Me.TryNavigateToSymbolProvidedSymbol = symbol
                Me.TryNavigateToSymbolProvidedProject = project
                Me.TryNavigateToSymbolProvidedUsePreviewTab = usePreviewTab
44 45 46 47
                Return True
            End Function

            Public Function TrySymbolNavigationNotify(symbol As ISymbol, solution As Solution) As Boolean Implements ISymbolNavigationService.TrySymbolNavigationNotify
48 49 50 51
                Me.TrySymbolNavigationNotifyProvidedSymbol = symbol
                Me.TrySymbolNavigationNotifyProvidedSolution = solution

                Return TrySymbolNavigationNotifyReturnValue
52 53 54
            End Function

            Public Function WouldNavigateToSymbol(symbol As ISymbol, solution As Solution, ByRef filePath As String, ByRef lineNumber As Integer, ByRef charOffset As Integer) As Boolean Implements ISymbolNavigationService.WouldNavigateToSymbol
55 56 57 58 59 60 61 62
                Me.WouldNavigateToSymbolProvidedSymbol = symbol
                Me.WouldNavigateToSymbolProvidedSolution = solution

                filePath = Me.NavigationFilePathReturnValue
                lineNumber = Me.NavigationLineNumberReturnValue
                charOffset = Me.NavigationCharOffsetReturnValue

                Return WouldNavigateToSymbolReturnValue
63 64 65 66
            End Function
        End Class
    End Class
End Namespace