public void ParseHexNumber()
    {
      string json = @"0x20";

      JsonTextReader reader = new JsonTextReader(new StringReader(json));

      reader.ReadAsDecimal();
      Assert.AreEqual(JsonToken.Float, reader.TokenType);
      Assert.AreEqual(32m, reader.Value);
    }
    public void ReadAsDecimalFrench()
    {
      string json = @"{""decimal"":""9,99""}";

      JsonTextReader reader = new JsonTextReader(new StringReader(json));
      reader.Culture = new CultureInfo("fr-FR");

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.StartObject, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);

      decimal? d = reader.ReadAsDecimal();
      Assert.AreEqual(JsonToken.Float, reader.TokenType);
      Assert.AreEqual(typeof(decimal), reader.ValueType);
      Assert.AreEqual(9.99m, d);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.EndObject, reader.TokenType);
    }
    public void ReadAsDecimal()
    {
      string json = @"{""decimal"":-7.92281625142643E+28}";

      JsonTextReader reader = new JsonTextReader(new StringReader(json));

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.StartObject, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);

      decimal? d = reader.ReadAsDecimal();
      Assert.AreEqual(JsonToken.Float, reader.TokenType);
      Assert.AreEqual(typeof(decimal), reader.ValueType);
      Assert.AreEqual(-79228162514264300000000000000m, d);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.EndObject, reader.TokenType);
    }
    public void ReadAsDecimalInt()
    {
      string json = @"{""Name"":1}";

      JsonTextReader reader = new JsonTextReader(new StringReader(json));

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.StartObject, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);

      reader.ReadAsDecimal();
      Assert.AreEqual(JsonToken.Float, reader.TokenType);
      Assert.AreEqual(typeof(decimal), reader.ValueType);
      Assert.AreEqual(1, reader.Value);
    }
    public void ReadAsDecimalBadContent()
    {
      JsonTextReader reader = new JsonTextReader(new StringReader(@"new Date()"));

      reader.ReadAsDecimal();
    }
    public void ReadAsDecimalNoContent()
    {
      JsonTextReader reader = new JsonTextReader(new StringReader(@""));

      reader.ReadAsDecimal();
    }