Modified:
/src/Jayrock.Json/Json/Conversion/Converters/NumberImporter.cs
/tests/Jayrock/Json/Conversion/Converters/TestNumberImporter.cs
=======================================
--- /src/Jayrock.Json/Json/Conversion/Converters/NumberImporter.cs Tue Apr
19 14:01:08 2011
+++ /src/Jayrock.Json/Json/Conversion/Converters/NumberImporter.cs Sun Apr
24 07:34:49 2011
@@ -33,6 +33,11 @@
{
protected NumberImporterBase(Type type) :
base(type) {}
+
+ protected override object ImportNull(ImportContext context,
JsonReader reader)
+ {
+ throw new JsonException(string.Format("JSON null cannot be
imported as {0}.", OutputType.FullName));
+ }
protected override object ImportFromString(ImportContext context,
JsonReader reader)
{
=======================================
--- /tests/Jayrock/Json/Conversion/Converters/TestNumberImporter.cs Fri Apr
15 16:09:54 2011
+++ /tests/Jayrock/Json/Conversion/Converters/TestNumberImporter.cs Sun Apr
24 07:34:49 2011
@@ -84,7 +84,7 @@
#if !NET_1_0 && !NET_1_1 && !NET_2_0
- [Test]
+ [ Test ]
public void ImportBigInteger()
{
AssertImport(System.Numerics.BigInteger.Pow(long.MaxValue,
3), "784637716923335095224261902710254454442933591094742482943");
@@ -92,7 +92,7 @@
#endif // !NET_1_0 && !NET_1_1 && !NET_2_0
- [Test]
+ [ Test ]
public void ImportDecimalUsingExponentialNotation()
{
//
@@ -102,6 +102,14 @@
AssertImport(7.25e-5m, "7.25e-005");
}
+
+ [ Test, ExpectedException(typeof(JsonException)) ]
+ public void CannotImportNull()
+ {
+ ImportContext importContext = new ImportContext();
+ JsonTextReader reader = new JsonTextReader(new
StringReader("null"));
+ new Int32Importer().Import(importContext, reader);
+ }
private static void AssertImport(object expected, string input)
{