Browse Source

Merged in Ken Egozi's fix to CSHARP-86. Fixed line endings.

pull/16/head
rstam 15 years ago
parent
commit
3c02bed824
  1. 2
      Bson/IO/BsonJsonWriter.cs
  2. 6
      BsonUnitTests/IO/BsonJsonWriterTests.cs

2
Bson/IO/BsonJsonWriter.cs

@ -153,7 +153,7 @@ namespace MongoDB.Bson.IO {
if ((context.WriteState & BsonWriteState.Document) == 0) {
throw new InvalidOperationException("WriteDouble can only be called when WriteState is one of the document states");
}
WriteName(name);
WriteName(name);
textWriter.Write(value.ToString(CultureInfo.InvariantCulture));
}

6
BsonUnitTests/IO/BsonJsonWriterTests.cs

@ -101,17 +101,17 @@ namespace MongoDB.BsonUnitTests.IO {
[Test]
public void TestDateTime() {
DateTime jan_1_2010 = new DateTime(2010, 1, 1);
DateTime jan_1_2010 = new DateTime(2010, 1, 1);
double expectedValue = (jan_1_2010.ToUniversalTime() - BsonConstants.UnixEpoch).TotalMilliseconds;
BsonDocument document = new BsonDocument() {
{ "date", jan_1_2010 }
};
var settings = new BsonJsonWriterSettings { OutputMode = BsonJsonOutputMode.Strict };
string json = document.ToJson(settings);
string json = document.ToJson(settings);
string expected = "{ \"date\" : { \"$date\" : # } }".Replace("#", expectedValue.ToString());
Assert.AreEqual(expected, json);
settings = new BsonJsonWriterSettings { OutputMode = BsonJsonOutputMode.JavaScript };
json = document.ToJson(settings);
json = document.ToJson(settings);
expected = "{ \"date\" : Date(#) }".Replace("#", expectedValue.ToString());
Assert.AreEqual(expected, json);
}

Loading…
Cancel
Save