public QueueHandlerAsyncTests() { _queue = Substitute.For <ILocaleQueue>(); _queue.Receive(Arg.Any <int>(), Arg.Any <CancellationToken>()).Returns(e => CreateMessage("Message1"), e => CreateMessage("Message2"), e => CreateMessage("Message3"), e => null); _queueFactory = Substitute.For <IQueueFactory>(); _queueFactory.CreateLocale(Arg.Any <string>(), Arg.Any <bool>(), Arg.Any <LocaleQueueMode>(), Arg.Any <bool>(), Arg.Any <AccessMode>()).Returns(_queue); _taskFactory = new TaskFactory(); _cancellationTokenSource = new CancellationTokenSource(); _cancellationToken = _cancellationTokenSource.Token; }
public void ReceiveAndHandleOneMessage() { var numberOfMessages = 0; _queue.Receive(Arg.Any <int>(), Arg.Any <CancellationToken>()).Returns(e => CreateMessage("MyMessage"), e => null); ExecuteHandler((m, c) => ++ numberOfMessages); numberOfMessages.Should().Be(1); }