private static void AssertTokenizationTypes(TokenizationResult result, params Type[] types) { Assert.IsNull(result.Exception); Assert.IsTrue(result.UnmatchedCharactersLeft == 0); Assert.IsNotNull(result.Tokens); var tokens = result.Tokens.ToArray(); Assert.AreEqual(tokens.Length, types.Length); for(var i = 0; i < tokens.Length; ++i) { Assert.AreSame(tokens[i].GetType(), types[i]); } }
private static void AssertTokenizationValues(TokenizationResult result, params object[] values) { var tokens = result.Tokens.ToArray(); Assert.AreEqual(tokens.Length, values.Length); CollectionAssert.AreEqual(values, tokens.Select(x => x.GetObjectValue())); }
private static void AssertTokenizationResult(TokenizationResult result, int unmatchedCharacters, Type exception = null, params Type[] types) { if(exception != null) { Assert.AreEqual(result.Exception.GetType(), exception); } else { Assert.IsNull(result.Exception); } Assert.IsTrue(result.UnmatchedCharactersLeft == unmatchedCharacters); Assert.IsNotNull(result.Tokens); var tokens = result.Tokens.ToArray(); Assert.AreEqual(tokens.Length, types.Length); for(var i = 0; i < tokens.Length; ++i) { Assert.AreSame(tokens[i].GetType(), types[i]); } }