예제 #1
0
    public async Task ConsumerStartAsync_WithQueueName_QueueExists()
    {
        var builder = RabbitMQTestBuilder
                      .CreateWithoutQueueDeclare(_fixture)
                      .WithConsumerCallback((_, _) => Task.FromResult(ProcessedMessageStatus.Success))
                      .Build();
        var consumer = builder.GetConsumer <string>();

        await consumer.StartAsync();

        Assert.True(builder.IsConsumerQueueDeclared());
    }
예제 #2
0
    public async Task ConsumerStartAsync_OneMessageInQueueAndConsumeCallbackSuccess_QueueEmptyAfterAck()
    {
        var builder = RabbitMQTestBuilder
                      .CreateWithoutQueueDeclare(_fixture)
                      .WithSingleRandomPublishedMessage()
                      .WithConsumerCallback((_, _) => Task.FromResult(ProcessedMessageStatus.Success))
                      .Build();
        var consumer = builder.GetConsumer <string>();

        await consumer.StartAsync();

        await Task.Delay(TimeSpan.FromSeconds(2));

        Assert.Equal((uint)0, builder.MessageInConsumerQueue());
    }