void TestGuessSemicolonInsertionOffset(string fooBar) { StringBuilder sb = new StringBuilder(); int semicolonOffset = 0; int guessedOffset = 0; for (int i = 0; i < fooBar.Length; i++) { char ch = fooBar [i]; if (ch == '$') { semicolonOffset = sb.Length - 1; } else if (ch == '~') { guessedOffset = sb.Length - 1; } else { sb.Append(ch); } } var data = new TextEditorData(); data.Text = sb.ToString(); int guessed = CSharpTextEditorIndentation.GuessSemicolonInsertionOffset(data, data.GetLineByOffset(semicolonOffset), semicolonOffset); Assert.AreEqual(guessedOffset, guessed); }
void TestGuessSemicolonInsertionOffset(string fooBar, bool expected = true) { StringBuilder sb = new StringBuilder(); int semicolonOffset = 0; int guessedOffset = 0; for (int i = 0; i < fooBar.Length; i++) { char ch = fooBar [i]; if (ch == '$') { semicolonOffset = sb.Length - 1; } else if (ch == '~') { guessedOffset = sb.Length - 1; } else { sb.Append(ch); } } var data = TextEditorFactory.CreateNewEditor(); data.Text = sb.ToString(); int guessed; Assert.AreEqual(expected, CSharpTextEditorIndentation.GuessSemicolonInsertionOffset(data, data.GetLineByOffset(semicolonOffset), semicolonOffset, out guessed)); if (expected) { Assert.AreEqual(guessedOffset, guessed); } }