async Task CheckRename(string input) { var sb = StringBuilderCache.Allocate(); try { bool inLink = false; int linkStart = 0; var expectedLinks = new List <TextSegment> (); foreach (var ch in input) { if (ch == '$') { if (inLink) { expectedLinks.Add(new TextSegment(linkStart, sb.Length - linkStart)); } else { linkStart = sb.Length; } inLink = !inLink; continue; } sb.Append(ch); } using (var testCase = await SetupTestCase(sb.ToString())) { var model = await testCase.Document.DocumentContext.AnalysisDocument.GetSemanticModelAsync(); ISymbol symbol = null; var root = await model.SyntaxTree.GetRootAsync(); foreach (var l in expectedLinks) { var node = root.FindToken(l.Offset).Parent; if (node == null) { continue; } var symbolInfo = model.GetSymbolInfo(node); if (symbolInfo.Symbol == null) { continue; } symbol = symbolInfo.Symbol; break; } Assert.NotNull(symbol, "No symbol found."); var links = await RenameRefactoring.GetTextLinksAsync(testCase.Document, 0, symbol); Assert.AreEqual(expectedLinks.Count, links [0].Links.Count); foreach (var l in links[0].Links) { var expected = expectedLinks.FirstOrDefault(el => l.Offset == el.Offset); Assert.NotNull(expected, "No expected link found at : " + l.Offset); Assert.AreEqual(expected.Length, l.Length); } } } finally { StringBuilderCache.Free(sb); } }