protected override async Task Given() { foreach (var e in _events) { await StreamsClient.AppendToStreamAsync("test-" + Guid.NewGuid(), StreamState.Any, new[] { e }); } await Client.CreateToAllAsync(Group, StreamFilter.Prefix("test"), new PersistentSubscriptionSettings( minCheckPointCount : 5, checkPointAfter : TimeSpan.FromSeconds(1), startFrom : Position.Start), TestCredentials.Root); _checkPointSubscription = await StreamsClient.SubscribeToStreamAsync(_checkPointStream, (s, e, ct) => { if (_checkPoints.Count == 0) { _firstCheckPointSource.TrySetResult(e); } else { _secondCheckPointSource.TrySetResult(e); } _checkPoints.Add(e); return(Task.CompletedTask); }, userCredentials : TestCredentials.Root); _subscription = await Client.SubscribeToAllAsync(Group, eventAppeared : (s, e, r, ct) => { _appearedEvents.Add(e); if (_appearedEvents.Count == _events.Length) { _appeared.TrySetResult(true); } return(Task.CompletedTask); }, userCredentials : TestCredentials.Root); await Task.WhenAll(_appeared.Task, _firstCheckPointSource.Task).WithTimeout(); FirstCheckPoint = _firstCheckPointSource.Task.Result.Event.Data.ParsePosition(); }
protected override async Task Given() { foreach (var e in _events) { await StreamsClient.AppendToStreamAsync("test-" + Guid.NewGuid(), StreamState.Any, new[] { e }); } await Client.CreateToAllAsync(Group, new PersistentSubscriptionSettings( minCheckPointCount : 5, checkPointAfter : TimeSpan.FromSeconds(1), startFrom : Position.Start), TestCredentials.Root); var checkPointStream = $"$persistentsubscription-$all::{Group}-checkpoint"; _checkPointSubscription = await StreamsClient.SubscribeToStreamAsync(checkPointStream, (s, e, ct) => { _checkPointSource.TrySetResult(e); return(Task.CompletedTask); }, userCredentials : TestCredentials.Root); _firstSubscription = await Client.SubscribeToAllAsync(Group, eventAppeared : (s, e, r, ct) => { _appearedEvents.Add(e); if (_appearedEvents.Count == _events.Length) { _appeared.TrySetResult(true); } return(Task.CompletedTask); }, (subscription, reason, ex) => _droppedSource.TrySetResult((reason, ex)), TestCredentials.Root); await Task.WhenAll(_appeared.Task, _checkPointSource.Task).WithTimeout(); CheckPoint = _checkPointSource.Task.Result.Event.Data.ParsePosition(); }