Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 4e5322b08e252726c7facd630cf7dce0a98cdf19 1 parent 3dcaec7
rstam authored

Showing 1 changed file with 11 additions and 3 deletions. Show diff stats Hide diff stats

  1. +11 3 BsonUnitTests/ObjectModel/BsonDocumentTests.cs
14 BsonUnitTests/ObjectModel/BsonDocumentTests.cs
@@ -310,14 +310,22 @@ public void TestContainsValue()
310 310 }
311 311
312 312 [Test]
313   - public void TestCreate()
  313 + public void TestCreateFromDictionary()
314 314 {
315   - var dictionary = new Dictionary<string, object> { { "x", 1 } };
  315 + var dictionary = new Dictionary<string, object> { { "x", 1 }, { "n", null }, { "a", new object[] { 1, null } } }; // null will be mapped to BsonNull.Value
316 316 var document = BsonDocument.Create(dictionary);
317   - Assert.AreEqual(1, document.ElementCount);
  317 + Assert.AreEqual(3, document.ElementCount);
318 318 Assert.AreEqual(1, document["x"].AsInt32);
  319 + Assert.AreSame(BsonNull.Value, document["n"]);
  320 + Assert.IsTrue(document["a"].IsBsonArray);
  321 + Assert.AreEqual(2, document["a"].AsBsonArray.Count);
  322 + Assert.AreEqual(1, document["a"].AsBsonArray[0].AsInt32);
  323 + Assert.AreSame(BsonNull.Value, document["a"].AsBsonArray[1]);
319 324 Assert.AreEqual(true, document.Contains("x"));
  325 + Assert.AreEqual(true, document.Contains("n"));
  326 + Assert.AreEqual(true, document.Contains("a"));
320 327 Assert.AreEqual(true, document.ContainsValue(1));
  328 + Assert.AreEqual(true, document.ContainsValue(BsonNull.Value));
321 329 }
322 330
323 331 [Test]

0 comments on commit 4e5322b

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