static void TestDecodeNumericEntity(string text, string expected)
        {
            var decoder = new HtmlEntityDecoder();

            for (int i = 0; i < text.Length; i++)
            {
                Assert.IsTrue(decoder.Push(text[i]), "Failed to push char #{0} of \"{1}\".", i, text);
            }

            Assert.AreEqual(expected, decoder.GetValue(), "Decoded entity did not match for \"{0}\".", text);
        }
        public void TestDecodeNamedEntities()
        {
            var path    = Path.Combine("..", "..", "TestData", "html", "HtmlEntities.json");
            var decoder = new HtmlEntityDecoder();

            using (var json = new JsonTextReader(new StreamReader(path))) {
                while (json.Read())
                {
                    string name, value;

                    if (json.TokenType == JsonToken.StartObject)
                    {
                        continue;
                    }

                    if (json.TokenType != JsonToken.PropertyName)
                    {
                        break;
                    }

                    name = (string)json.Value;

                    if (!json.Read() || json.TokenType != JsonToken.StartObject)
                    {
                        break;
                    }

                    // read to the "codepoints" property
                    if (!json.Read() || json.TokenType != JsonToken.PropertyName)
                    {
                        break;
                    }

                    // skip the array of integers...
                    if (!json.Read() || json.TokenType != JsonToken.StartArray)
                    {
                        break;
                    }

                    while (json.Read())
                    {
                        if (json.TokenType == JsonToken.EndArray)
                        {
                            break;
                        }
                    }

                    // the property should be "characters" - this is what we want
                    if (!json.Read() || json.TokenType != JsonToken.PropertyName)
                    {
                        break;
                    }

                    value = json.ReadAsString();

                    if (!json.Read() || json.TokenType != JsonToken.EndObject)
                    {
                        break;
                    }

                    for (int i = 0; i < name.Length && name[i] != ';'; i++)
                    {
                        Assert.IsTrue(decoder.Push(name[i]), "Failed to push char #{0} of \"{1}\".", i, name);
                    }

                    Assert.AreEqual(value, decoder.GetValue(), "Decoded entity did not match for \"{0}\".", name);

                    decoder.Reset();
                }
            }
        }