protected override async Task Given() { foreach (var e in _events) { await Client.AppendToStreamAsync(Stream, AnyStreamRevision.Any, new[] { e }); } await Client.PersistentSubscriptions.CreateAsync(Stream, Group, new PersistentSubscriptionSettings(startFrom : StreamRevision.Start, resolveLinkTos : true), TestCredentials.Root); _subscription = Client.PersistentSubscriptions.Subscribe(Stream, Group, (subscription, e, retryCount, ct) => { subscription.Ack(e); if (Interlocked.Increment(ref _eventReceivedCount) == _events.Length) { _eventsReceived.TrySetResult(true); } return(Task.CompletedTask); }, (s, r, e) => { if (e != null) { _eventsReceived.TrySetException(e); } }, autoAck: false, bufferSize: BufferCount, userCredentials: TestCredentials.Root); }
protected override Task When() { _subscription = Client.PersistentSubscriptions.Subscribe(Stream, Group, (subscription, e, r, ct) => { _firstEventSource.TrySetResult(e); return(Task.CompletedTask); }); return(Task.CompletedTask); }
protected override async Task Given() { await Client.PersistentSubscriptions.CreateAsync(Stream, Group, new PersistentSubscriptionSettings(), TestCredentials.Root); _subscription = Client.PersistentSubscriptions.Subscribe(Stream, Group, (subscription, e, r, ct) => { _firstEventSource.TrySetResult(e); return(Task.CompletedTask); }); }
protected override async Task Given() { await Client.AppendToStreamAsync(Stream, AnyStreamRevision.NoStream, Events.Take(11)); await Client.PersistentSubscriptions.CreateAsync(Stream, Group, new PersistentSubscriptionSettings(startFrom : new StreamRevision(11)), TestCredentials.Root); _subscription = Client.PersistentSubscriptions.Subscribe(Stream, Group, (subscription, e, r, ct) => { _firstEventSource.TrySetResult(e); return(Task.CompletedTask); }); }
protected override async Task Given() { await Client.AppendToStreamAsync(Stream, AnyStreamRevision.NoStream, Events); await Client.PersistentSubscriptions.CreateAsync(Stream, Group, new PersistentSubscriptionSettings(startFrom : StreamRevision.Start), TestCredentials.Root); _subscription = Client.PersistentSubscriptions.Subscribe(Stream, Group, async(subscription, e, r, ct) => { if (r > 4) { _retryCountSource.TrySetResult(r.Value); await subscription.Ack(e.Event.EventId); } else { await subscription.Nack(PersistentSubscriptionNakEventAction.Retry, "Not yet tried enough times", e); } }, autoAck: false); }