public void ParseLiterals_count(string source, int expectedMatchCount)
 {
     var sb = new StringBuilder(source);
     var subject = new LiteralParser();
     var actual = subject.ParseLiterals(sb);
     Assert.Equal(expectedMatchCount, actual.Count());
 }
 public void ParseLiterals_source_line_and_column_number(string source, int lineNumber, int columnNumber)
 {
     var sb = new StringBuilder(source);
     var subject = new LiteralParser();
     var actual = subject.ParseLiterals(sb);
     var first = actual.First();
     Assert.Equal(lineNumber, first.SourceLineNumber);
     Assert.Equal(columnNumber, first.SourceColumnNumber);
 }
 public void ParseLiterals_bracket_mismatch(
     string source, 
     int expectedOpenBraceCount, 
     int expectedCloseBraceCount)
 {
     var sb = new StringBuilder(source);
     var subject = new LiteralParser();
     var ex = Assert.Throws<UnbalancedBracesException>(() => subject.ParseLiterals(sb));
     Assert.Equal(expectedOpenBraceCount, ex.OpenBraceCount);
     Assert.Equal(expectedCloseBraceCount, ex.CloseBraceCount);
 }
        public void ParseLiterals_position_and_inner_text(string source, int[] position, string expectedInnerText)
        {
            var sb = new StringBuilder(source);
            var subject = new LiteralParser();
            var actual = subject.ParseLiterals(sb);
            var first = actual.First();
            string innerText = first.InnerText.ToString();
            Assert.Equal(expectedInnerText, innerText);
            Assert.Equal(position[0], first.StartIndex);

            // Makes up for line-ending differences due to Git.
            var expectedEndIndex = position[1] + source.Count(c => c == '\r');
            var expectedSourceColumnNumber = first.StartIndex + 1;
            Assert.Equal(expectedEndIndex, first.EndIndex);
            
            Assert.Equal(expectedSourceColumnNumber, first.SourceColumnNumber);
        }