private RazorBreakpointResolver CreateResolverWith(
            FileUriProvider uriProvider                        = null,
            LSPDocumentManager documentManager                 = null,
            LSPProjectionProvider projectionProvider           = null,
            LSPDocumentMappingProvider documentMappingProvider = null)
        {
            var documentUri = DocumentUri;

            uriProvider ??= Mock.Of <FileUriProvider>(provider => provider.TryGet(HostTextbuffer, out documentUri) == true && provider.TryGet(It.IsNotIn(HostTextbuffer), out It.Ref <Uri> .IsAny) == false, MockBehavior.Strict);
            var csharpVirtualDocumentSnapshot    = new CSharpVirtualDocumentSnapshot(CSharpDocumentUri, CSharpTextBuffer.CurrentSnapshot, hostDocumentSyncVersion: 0);
            LSPDocumentSnapshot documentSnapshot = new TestLSPDocumentSnapshot(DocumentUri, 0, csharpVirtualDocumentSnapshot);

            documentManager ??= Mock.Of <LSPDocumentManager>(manager => manager.TryGetDocument(DocumentUri, out documentSnapshot) == true, MockBehavior.Strict);
            if (projectionProvider is null)
            {
                projectionProvider = new Mock <LSPProjectionProvider>(MockBehavior.Strict).Object;
                Mock.Get(projectionProvider).Setup(projectionProvider => projectionProvider.GetProjectionAsync(It.IsAny <LSPDocumentSnapshot>(), It.IsAny <Position>(), CancellationToken.None))
                .Returns(Task.FromResult <ProjectionResult>(null));
            }

            if (documentMappingProvider is null)
            {
                documentMappingProvider = new Mock <LSPDocumentMappingProvider>(MockBehavior.Strict).Object;
                Mock.Get(documentMappingProvider).Setup(p => p.MapToDocumentRangesAsync(It.IsAny <RazorLanguageKind>(), It.IsAny <Uri>(), It.IsAny <Range[]>(), CancellationToken.None))
                .Returns(Task.FromResult <RazorMapToDocumentRangesResponse>(null));
            }

            var razorBreakpointResolver = DefaultRazorBreakpointResolver.CreateTestInstance(
                uriProvider,
                documentManager,
                projectionProvider,
                documentMappingProvider);

            return(razorBreakpointResolver);
        }
示例#2
0
        private RazorBreakpointResolver CreateResolverWith(
            FileUriProvider uriProvider                        = null,
            LSPDocumentManager documentManager                 = null,
            LSPProjectionProvider projectionProvider           = null,
            LSPDocumentMappingProvider documentMappingProvider = null)
        {
            var documentUri = DocumentUri;

            uriProvider ??= Mock.Of <FileUriProvider>(provider => provider.TryGet(HostTextbuffer, out documentUri) == true);
            var csharpDocumentUri                = new Uri(DocumentUri.OriginalString + ".g.cs", UriKind.Absolute);
            var csharpVirtualDocumentSnapshot    = new CSharpVirtualDocumentSnapshot(csharpDocumentUri, CSharpTextBuffer.CurrentSnapshot, hostDocumentSyncVersion: 0);
            LSPDocumentSnapshot documentSnapshot = new TestLSPDocumentSnapshot(DocumentUri, 0, csharpVirtualDocumentSnapshot);

            documentManager ??= Mock.Of <LSPDocumentManager>(manager => manager.TryGetDocument(DocumentUri, out documentSnapshot) == true);
            projectionProvider ??= Mock.Of <LSPProjectionProvider>();
            documentMappingProvider ??= Mock.Of <LSPDocumentMappingProvider>();
            var csharpBreakpointResolver = new DefaultCSharpBreakpointResolver();
            var razorBreakpointResolver  = new DefaultRazorBreakpointResolver(
                uriProvider,
                documentManager,
                projectionProvider,
                documentMappingProvider,
                csharpBreakpointResolver);

            return(razorBreakpointResolver);
        }
示例#3
0
        private RazorBreakpointResolver CreateResolverWith(
            FileUriProvider uriProvider                        = null,
            LSPDocumentManager documentManager                 = null,
            LSPProjectionProvider projectionProvider           = null,
            LSPDocumentMappingProvider documentMappingProvider = null)
        {
            var documentUri = DocumentUri;

            uriProvider ??= Mock.Of <FileUriProvider>(provider => provider.TryGet(HostTextbuffer, out documentUri) == true && provider.TryGet(It.IsNotIn(HostTextbuffer), out It.Ref <Uri> .IsAny) == false, MockBehavior.Strict);
            var csharpDocumentUri                = new Uri(DocumentUri.OriginalString + ".g.cs", UriKind.Absolute);
            var csharpVirtualDocumentSnapshot    = new CSharpVirtualDocumentSnapshot(csharpDocumentUri, CSharpTextBuffer.CurrentSnapshot, hostDocumentSyncVersion: 0);
            LSPDocumentSnapshot documentSnapshot = new TestLSPDocumentSnapshot(DocumentUri, 0, csharpVirtualDocumentSnapshot);

            documentManager ??= Mock.Of <LSPDocumentManager>(manager => manager.TryGetDocument(DocumentUri, out documentSnapshot) == true, MockBehavior.Strict);
            if (projectionProvider is null)
            {
                projectionProvider = new Mock <LSPProjectionProvider>(MockBehavior.Strict).Object;
                Mock.Get(projectionProvider).Setup(projectionProvider => projectionProvider.GetProjectionAsync(It.IsAny <LSPDocumentSnapshot>(), It.IsAny <Position>(), CancellationToken.None))
                .Returns(Task.FromResult <ProjectionResult>(null));
            }

            if (documentMappingProvider is null)
            {
                documentMappingProvider = new Mock <LSPDocumentMappingProvider>(MockBehavior.Strict).Object;
                Mock.Get(documentMappingProvider).Setup(p => p.MapToDocumentRangesAsync(It.IsAny <RazorLanguageKind>(), It.IsAny <Uri>(), It.IsAny <Range[]>(), CancellationToken.None))
                .Returns(Task.FromResult <RazorMapToDocumentRangesResponse>(null));
            }

            CodeAnalysis.Workspace workspace = null;
            var workspaceAccessor            = Mock.Of <VisualStudioWorkspaceAccessor>(accessor => accessor.TryGetWorkspace(It.IsAny <ITextBuffer>(), out workspace) == false, MockBehavior.Strict);
            var razorBreakpointResolver      = new DefaultRazorBreakpointResolver(
                uriProvider,
                documentManager,
                projectionProvider,
                documentMappingProvider,
                workspaceAccessor);

            return(razorBreakpointResolver);
        }