public async Task WhenProcessingOfMessageSuccessful_ShouldConsumeMessage() { // arrange var queueName = "test-queue"; var recievedBytes = new byte[0]; Func <byte[], Task <bool> > action = (byte[] bytes) => { recievedBytes = bytes; return(Task.FromResult(true)); }; var rabbitMqContext = new RabbitMqTestContextBuilder() .With_Queue(queueName) .Build(); rabbitMqContext.PublishMessage(queueName, "hello_world"); // act await rabbitMqContext.ConsumeMessage(queueName, action); // assert var expectedLength = 13; // len of 'hello_world' recievedBytes.Length.Should().Be(expectedLength); }
public async Task WhenProcessingOfMessageErrors_ShouldNotAckMessage() { // arrange var queueName = "test-queue"; Func <byte[], Task <bool> > action = (byte[] bytes) => Task.FromResult(false); var rabbitMqContext = new RabbitMqTestContextBuilder() .With_Queue(queueName) .Build(); rabbitMqContext.PublishMessage(queueName, "hello_world"); // act await rabbitMqContext.ConsumeMessage(queueName, action); // assert rabbitMqContext.Assert_Queue_Message_Count_Is(1); }