Skip to content

Commit 934b076

Browse files
author
rstam
committed
CSHARP-767: Added additional unit test that matches scenario described in the JIRA ticket.
1 parent 391093a commit 934b076

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

MongoDB.Bson/Serialization/BsonMemberMap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public BsonMemberMap Reset()
334334
/// <summary>
335335
/// Sets the default value creator.
336336
/// </summary>
337-
/// <param name="defaultValueCreator">The default value creator.</param>
337+
/// <param name="defaultValueCreator">The default value creator (note: the supplied delegate must be thread safe).</param>
338338
/// <returns>The member map.</returns>
339339
public BsonMemberMap SetDefaultValue(Func<object> defaultValueCreator)
340340
{

MongoDB.BsonUnitTests/Serialization/BsonMemberMapDefaultValueCreatorTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ public void TestEachDefaultValueIsNewInstance()
4848
Assert.AreNotSame(c.L, d.L);
4949
}
5050

51+
[Test]
52+
public void TestModifyingEmptyListDoesNotCorruptDefaultValue()
53+
{
54+
var json = "{ _id : 1 }";
55+
var c1 = BsonSerializer.Deserialize<C>(json);
56+
c1.L.Add(1);
57+
var c2 = BsonSerializer.Deserialize<C>(json);
58+
Assert.AreEqual(1, c1.L.Count);
59+
Assert.AreEqual(0, c2.L.Count);
60+
}
61+
5162
[Test]
5263
public void TestValueMissing()
5364
{

0 commit comments

Comments
 (0)