Exemplo n.º 1
0
        private async Task TestAsync(string markup, string expectedName, int expectedLineOffset, CSharpParseOptions parseOptions = null)
        {
            using var workspace = TestWorkspace.CreateCSharp(markup, parseOptions);

            var testDocument = workspace.Documents.Single();
            var position     = testDocument.CursorPosition.Value;
            var locationInfo = await LocationInfoGetter.GetInfoAsync(
                workspace.CurrentSolution.Projects.Single().Documents.Single(),
                position,
                CancellationToken.None);

            Assert.Equal(expectedName, locationInfo.Name);
            Assert.Equal(expectedLineOffset, locationInfo.LineOffset);
        }
        private void Test(string markup, string expectedName, int expectedLineOffset)
        {
            using (var workspace = CSharpWorkspaceFactory.CreateWorkspaceFromLines(markup))
            {
                var testDocument = workspace.Documents.Single();
                var position     = testDocument.CursorPosition.Value;
                var locationInfo = LocationInfoGetter.GetInfoAsync(
                    workspace.CurrentSolution.Projects.Single().Documents.Single(),
                    position,
                    CancellationToken.None).WaitAndGetResult(CancellationToken.None);

                Assert.Equal(expectedName, locationInfo.Name);
                Assert.Equal(expectedLineOffset, locationInfo.LineOffset);
            }
        }