public void ThenAllSectionOfTypesShouldBeHighlightedAs(string[] keywordTypes, string expectedContent) { var expectedContentText = new TestText(expectedContent); var tags = GetDeveroomTags(_wpfTextView).Where(t => keywordTypes.Contains(t.Type)).ToArray(); var testTextSections = expectedContentText.Sections.Where(s => keywordTypes.Contains(s.Label)).ToArray(); testTextSections.Should().NotBeEmpty("there should be something to expect"); foreach (var section in testTextSections) { tags.Should().Contain(t => t.Type == section.Label && t.Span.Start == expectedContentText.GetSnapshotPoint(t.Span.Snapshot, section.Start.Line, section.Start.Column) && t.Span.End == expectedContentText.GetSnapshotPoint(t.Span.Snapshot, section.End.Line, section.End.Column), $"the section '{section}' should be highlighted" ); } tags.Should().HaveCount(testTextSections.Length); }
protected IWpfTextView CreateTextView(TestText inputText, int selectionStartLine, int selectionStartColumn, int?selectionEndLine, int?selectionEndColumn) { var textBuffer = VsxStubObjects.CreateTextBuffer(inputText.ToString()); IWpfTextView textView = new StubWpfTextView(textBuffer); if (selectionEndColumn != null && selectionEndLine != null) { textView.Selection.Select(new SnapshotSpan( inputText.GetSnapshotPoint(textView.TextSnapshot, selectionStartLine, selectionStartColumn), inputText.GetSnapshotPoint(textView.TextSnapshot, selectionEndLine.Value, selectionEndColumn.Value)), false); } int caretLine = selectionEndLine ?? selectionStartLine; int caretColumn = selectionEndColumn ?? selectionStartColumn; textView.Caret.MoveTo(inputText.GetSnapshotPoint(textView.TextSnapshot, caretLine, caretColumn)); return(textView); }
public void ThenAllSectionOfTypesShouldBeHighlightedAs(string[] keywordTypes, string expectedContent) { var expectedContentText = new TestText(expectedContent); var tags = GetDeveroomTags(_wpfTextView).Where(t => keywordTypes.Contains(t.Type)).ToArray(); var testTextSections = expectedContentText.Sections.Where(s => keywordTypes.Contains(s.Label)).ToArray(); testTextSections.Should().NotBeEmpty("there should be something to expect"); var matchedTags = tags.ToList(); foreach (var section in testTextSections) { var matchedTag = tags.FirstOrDefault( t => t.Type == section.Label && t.Span.Start == expectedContentText.GetSnapshotPoint(t.Span.Snapshot, section.Start.Line, section.Start.Column) && t.Span.End == expectedContentText.GetSnapshotPoint(t.Span.Snapshot, section.End.Line, section.End.Column) ); matchedTag.Should().NotBeNull($"the section '{section}' should be highlighted"); matchedTags.Remove(matchedTag); } matchedTags.Should().BeEmpty(); }