Skip to content

Commit

Permalink
Add tests to read an write nagative dates.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanwin committed Jun 14, 2010
1 parent 9565f34 commit b3c7e17
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions source/MongoDB.Tests/UnitTests/Bson/TestBsonReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,15 @@ public void TestReadUtcTimeToLocalTime(){
var dateTime = new DateTime(2010, 1, 1, 11, 0, 0, DateTimeKind.Local).AddHours(localtzoffset);
Assert.AreEqual(dateTime, document["time"]);
}

[Test]
public void TestCanReadNagativeDates()
{
const string bson = "EwAAAAlkYXRlAIBFaoO2////AA==";

var document = Deserialize(bson);

Assert.AreEqual(new DateTime(1960,1,1),document["date"]);
}
}
}
8 changes: 8 additions & 0 deletions source/MongoDB.Tests/UnitTests/Bson/TestBsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,13 @@ public void TestWriteNetRegex()

Assert.AreEqual("GwAAAAtyZWdleABleHByZXNzaW9uAGltZwAA", bson);
}

[Test]
public void TestCanWriteNagativeDates()
{
var bson = Serialize(new Document("date", new DateTime(1960, 1, 1)));

Assert.AreEqual("EwAAAAlkYXRlAIBFaoO2////AA==",bson);
}
}
}

0 comments on commit b3c7e17

Please sign in to comment.