-Added WriteRegex to BsonWriter

-Added RegexConverter
-Fixed BsonWriter writing empty string instead of null
This commit is contained in:
JamesNK
2010-03-27 06:18:40 +00:00
parent 6ce972156d
commit b0c6db675e
16 changed files with 615 additions and 135 deletions
@@ -979,5 +979,40 @@ namespace Newtonsoft.Json.Tests.Bson
string expected = sb.ToString();
Assert.AreEqual(expected, WriteAndReadStringPropertyName(expected));
}
[Test]
public void ReadRegexWithOptions()
{
string hexdoc = "1A-00-00-00-0B-72-65-67-65-78-00-61-62-63-00-69-00-0B-74-65-73-74-00-00-00-00";
byte[] data = MiscellaneousUtils.HexToBytes(hexdoc);
MemoryStream ms = new MemoryStream(data);
BsonReader reader = new BsonReader(ms);
Assert.IsTrue(reader.Read());
Assert.AreEqual(JsonToken.StartObject, reader.TokenType);
Assert.IsTrue(reader.Read());
Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
Assert.IsTrue(reader.Read());
Assert.AreEqual(JsonToken.String, reader.TokenType);
Assert.AreEqual("/abc/i", reader.Value);
Assert.AreEqual(typeof(string), reader.ValueType);
Assert.IsTrue(reader.Read());
Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
Assert.IsTrue(reader.Read());
Assert.AreEqual(JsonToken.String, reader.TokenType);
Assert.AreEqual("//", reader.Value);
Assert.AreEqual(typeof(string), reader.ValueType);
Assert.IsTrue(reader.Read());
Assert.AreEqual(JsonToken.EndObject, reader.TokenType);
Assert.IsFalse(reader.Read());
}
}
}