Correct ParamName in exception for invalid JsonToken on WriteToken
Fixes #755 Also consolidates WriteTokenInternal into matching WriteToken (slightly reduce assembly size). Also extend ExceptionAssert.Throws to return exception for further examination.
This commit is contained in:
@@ -897,6 +897,19 @@ Parameter name: value");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TokenTypeOutOfRange()
|
||||
{
|
||||
using (JsonWriter jsonWriter = new JsonTextWriter(new StringWriter()))
|
||||
{
|
||||
ArgumentOutOfRangeException ex = ExceptionAssert.Throws<ArgumentOutOfRangeException>(() => jsonWriter.WriteToken((JsonToken)int.MinValue));
|
||||
Assert.AreEqual("token", ex.ParamName);
|
||||
|
||||
ex = ExceptionAssert.Throws<ArgumentOutOfRangeException>(() => jsonWriter.WriteToken((JsonToken)int.MinValue, "test"));
|
||||
Assert.AreEqual("token", ex.ParamName);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BadWriteEndArray()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user