Skip to content
Browse files

Fixed CSHARP-415 and CSHARP-417. Fix is actually in earlier commits. …

…In this commit I'm just making sure there are adequate unit tests to verify the fix.
  • Loading branch information...
1 parent 3dcaec7 commit 4e5322b08e252726c7facd630cf7dce0a98cdf19 rstam committed Apr 10, 2012
Showing with 11 additions and 3 deletions.
  1. +11 −3 BsonUnitTests/ObjectModel/BsonDocumentTests.cs
View
14 BsonUnitTests/ObjectModel/BsonDocumentTests.cs
@@ -310,14 +310,22 @@ public void TestContainsValue()
}
[Test]
- public void TestCreate()
+ public void TestCreateFromDictionary()
{
- var dictionary = new Dictionary<string, object> { { "x", 1 } };
+ var dictionary = new Dictionary<string, object> { { "x", 1 }, { "n", null }, { "a", new object[] { 1, null } } }; // null will be mapped to BsonNull.Value
var document = BsonDocument.Create(dictionary);
- Assert.AreEqual(1, document.ElementCount);
+ Assert.AreEqual(3, document.ElementCount);
Assert.AreEqual(1, document["x"].AsInt32);
+ Assert.AreSame(BsonNull.Value, document["n"]);
+ Assert.IsTrue(document["a"].IsBsonArray);
+ Assert.AreEqual(2, document["a"].AsBsonArray.Count);
+ Assert.AreEqual(1, document["a"].AsBsonArray[0].AsInt32);
+ Assert.AreSame(BsonNull.Value, document["a"].AsBsonArray[1]);
Assert.AreEqual(true, document.Contains("x"));
+ Assert.AreEqual(true, document.Contains("n"));
+ Assert.AreEqual(true, document.Contains("a"));
Assert.AreEqual(true, document.ContainsValue(1));
+ Assert.AreEqual(true, document.ContainsValue(BsonNull.Value));
}
[Test]

0 comments on commit 4e5322b

Please sign in to comment.
Something went wrong with that request. Please try again.