protected override async Task When()
            {
                var result = (await _conn.AppendToStreamAsync(_streamName, ExpectedVersion.NoStream, CreateEvents(1))
                              .ConfigureAwait(false)).LogPosition;

                _position = new Position((ulong)result.CommitPosition, (ulong)result.PreparePosition);

                var skippedEventCount = (await _conn.ReadAllEventsForwardAsync(EventStore.ClientAPI.Position.Start,
                                                                               4096, false, new UserCredentials("admin", "changeit")).ConfigureAwait(false))
                                        .Events.Count(e => new Position((ulong)e.OriginalPosition.Value.CommitPosition,
                                                                        (ulong)e.OriginalPosition.Value.PreparePosition) <= _position &&
                                                      e.OriginalEvent.EventStreamId != _streamName);

                _expected = skippedEventCount / _checkpointInterval;

                await using var enumerator = new Enumerators.AllSubscriptionFiltered(_node.Node.MainQueue,
                                                                                     Position.Start, false, EventFilter.StreamName.Prefixes(_streamName), TestUser, false,
                                                                                     _node.Node.ReadIndex, _maxSearchWindow, _checkpointIntervalMultiplier, p => {
                    _positions.Add(p);

                    if (p >= _position)
                    {
                        _complete.TrySetResult(true);
                    }

                    return(Task.CompletedTask);
                }, CancellationToken.None);

                Assert.True(await enumerator.MoveNextAsync().ConfigureAwait(false));
                Assert.AreEqual(_streamName, enumerator.Current.OriginalStreamId);
            }
 public when_subscribing_to_all_with_a_filter(uint checkpointIntervalMultiplier, uint maxSearchWindow,
                                              int filteredEventCount)
 {
     _maxSearchWindow = maxSearchWindow;
     _checkpointIntervalMultiplier = checkpointIntervalMultiplier;
     _checkpointInterval           = checkpointIntervalMultiplier * maxSearchWindow;
     _filteredEventCount           = filteredEventCount;
     _positions = new List <Position>();
     _position  = Position.End;
 }