Skip to content

Commit d6c0391

Browse files
authored
Merge branch 'main' into maint/list_ext_breakup
2 parents 60e8310 + 87edfa9 commit d6c0391

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/DynamicData.Tests/Cache/SizeLimitFixture.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ public void AddMoreThanLimit()
7272
[Fact]
7373
public void AddMoreThanLimitInBatched()
7474
{
75-
_source.AddOrUpdate(_generator.Take(10).ToArray());
76-
_source.AddOrUpdate(_generator.Take(10).ToArray());
75+
// _generator.Take(N) draws random Person rows from a finite name pool; a second
76+
// Take(10) call can produce keys that collide with the first batch, turning an
77+
// Add into an Update and breaking the per-message Adds count. Draw a larger pool
78+
// up front, dedupe by Key, then split into two non-overlapping batches of 10.
79+
var people = _generator.Take(60).DistinctBy(p => p.Key).Take(20).ToArray();
80+
_source.AddOrUpdate(people.Take(10).ToArray());
81+
_source.AddOrUpdate(people.Skip(10).Take(10).ToArray());
7782

7883
_scheduler.Start();
7984

@@ -96,12 +101,17 @@ public void InvokeLimitSizeToWhenOverLimit()
96101
var removesTriggered = false;
97102
var subscriber = _source.LimitSizeTo(10, _scheduler).Subscribe(removes => { removesTriggered = true; });
98103

99-
_source.AddOrUpdate(_generator.Take(10).ToArray());
104+
// _generator.Take(N) draws random Person rows from a finite name pool; a second
105+
// Take(10) call can produce keys that collide with the first batch, turning an
106+
// Add into an Update and breaking the per-message Adds count. Draw a larger pool
107+
// up front, dedupe by Key, then split into two non-overlapping batches of 10.
108+
var people = _generator.Take(60).DistinctBy(p => p.Key).Take(20).ToArray();
109+
_source.AddOrUpdate(people.Take(10).ToArray());
100110
_scheduler.AdvanceBy(TimeSpan.FromMilliseconds(150).Ticks);
101111

102112
removesTriggered.Should().BeFalse();
103113

104-
_source.AddOrUpdate(_generator.Take(10).ToArray());
114+
_source.AddOrUpdate(people.Skip(10).Take(10).ToArray());
105115

106116
_scheduler.AdvanceBy(TimeSpan.FromMilliseconds(150).Ticks);
107117

0 commit comments

Comments
 (0)