Skip to content

Commit 4441623

Browse files
authored
Fix SetSnapShot for duplicate items (#2806)
Fixes #2802
1 parent a3da9b1 commit 4441623

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/NHibernate.Test/UtilityTest/SetSnapShotFixture.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ public void TestInitialization()
4949
Assert.That(sn.TryGetValue(null, out _), Is.True);
5050
}
5151

52+
[Test]
53+
public void TestDuplicates()
54+
{
55+
var list = new List<string> { "test1", "test1", "test2" };
56+
var sn = new SetSnapShot<string>(list);
57+
Assert.That(sn, Has.Count.EqualTo(2));
58+
Assert.That(sn.TryGetValue("test1", out _), Is.True);
59+
Assert.That(sn.TryGetValue("test2", out _), Is.True);
60+
}
61+
5262
[Test]
5363
public void TestCopyTo()
5464
{

src/NHibernate/Collection/Generic/SetHelpers/SetSnapShot.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public SetSnapShot(IEnumerable<T> collection)
3333
}
3434
else
3535
{
36-
_values.Add(item, item);
36+
_values[item] = item;
3737
}
3838
}
3939
}
@@ -70,7 +70,7 @@ public void Add(T item)
7070
return;
7171
}
7272

73-
_values.Add(item, item);
73+
_values[item] = item;
7474
}
7575

7676
public void Clear()

0 commit comments

Comments
 (0)