private static void TestScanner(string line, TestTokenInfo[] tokens)
        {
            var scanner = new HamlScanner();

            string testLine = "";
            foreach (TestTokenInfo token in tokens)
            {
                token.StartIndex = testLine.Length;
                token.EndIndex = token.StartIndex + token.Token.Length -1;
                testLine += token.Token;
            }
            Assert.AreEqual(line, testLine, "Test line doesn't match tokens");

            scanner.SetSource(line, 0);

            var tokenInfo = new TokenInfo();
            int state = 0;

            int tokenNum = 0;
            while (scanner.ScanTokenAndProvideInfoAboutIt(tokenInfo, ref state))
            {
                TestTokenInfo token = tokens[tokenNum];
                AssertAreEqual(token, tokenInfo, string.Format("Token {0}({1})", tokenNum, token.Token));
                tokenNum++;
            }

            Assert.AreEqual(tokens.Length, tokenNum, "Should have matched {0} tokens but actually matched {1}", tokens.Length, tokenNum);
        }
 private static void AssertAreEqual(TestTokenInfo infoExpected, TokenInfo infoActual, string message)
 {
     Assert.AreEqual(infoExpected.StartIndex, infoActual.StartIndex, message + " StartIndex");
     Assert.AreEqual(infoExpected.EndIndex, infoActual.EndIndex, message + " EndIndex");
     Assert.AreEqual((int)infoExpected.HamlTokenColor, (int)infoActual.Color, message + " Color");
 }