public async Task Subscribe_WhenMessageIsPublishedBeforeSubscription_DoesNotExecuteHandler() { var mq = new RedqueueService(_fixture.Multiplexer, _serializer); var channel = _fixture.GetRandomKey(); int counter = 0; await mq.Publish(channel, 10); await mq.Subscribe <int>(channel, x => counter += x); Action assertion = () => counter.Should().Be(0); assertion.Should().NotThrowAfter(5.Seconds(), 100.Milliseconds()); }
public async Task Unsubscribe_StopsExecutingHandler() { var mq = new RedqueueService(_fixture.Multiplexer, _serializer); var channel = _fixture.GetRandomKey(); int counter = 0; await mq.Subscribe <int>(channel, x => counter += x); await mq.Unsubscribe(channel); await mq.Publish(channel, 10); await Task.Delay(1.Seconds()); counter.Should().Be(0); }