-Added support for reading GUID strings as bytes in JsonTextReader

-Changed reading GUIDs as bytes to only support 00000000-0000-0000-0000-000000000000 format
This commit is contained in:
James Newton-King
2015-06-10 17:10:16 +12:00
parent 652d18746a
commit 9e29489e5a
5 changed files with 41 additions and 6 deletions
@@ -92,6 +92,21 @@ namespace Newtonsoft.Json.Tests
Assert.AreEqual(JsonToken.EndObject, jsonTextReader.TokenType);
}
[Test]
public void ReadAsBytes_Base64AndGuid()
{
JsonTextReader jsonTextReader = new JsonTextReader(new StringReader("'AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAA'"));
byte[] data = jsonTextReader.ReadAsBytes();
byte[] expected = Convert.FromBase64String("AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAA");
CollectionAssert.AreEqual(expected, data);
jsonTextReader = new JsonTextReader(new StringReader("'AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAABAAAA'"));
data = jsonTextReader.ReadAsBytes();
expected = Guid.Parse("AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAABAAAA").ToByteArray();
CollectionAssert.AreEqual(expected, data);
}
[Test]
public void ReadSingleQuoteInsideDoubleQuoteString()