private static async Task SendDummyMessage(IHost build) { var msgNThenHandler = build.Services.GetRequiredService <IMessageHandler>(); await Task.Delay(500); IHandledMessage message = new HandledMessageWrapper(new BasicDeliverEventArgs( "consumer", 1, false, "ex", "exampleroute", null, new byte[0])); await msgNThenHandler.HandleMessageTask(message); }
public async Task TestMessageProperties() { var serviceProvider = CreateServiceProvider(); var apdapterFactory = serviceProvider.GetRequiredService <IMsgNThenApdapterFactory>(); var httpApplication = Substitute.For <IHttpApplication <DummyType> >(); var cancellationTokenSource = new CancellationTokenSource(); var adapter = apdapterFactory.Start(httpApplication, cancellationTokenSource.Token); var body = new byte[0]; var rabbitMessagePublisher = serviceProvider.GetRequiredService <RabbitMessagePublisher>(); var basicProperties = rabbitMessagePublisher.CreateBasicProperties(); basicProperties.MessageId = Guid.NewGuid().ToString(); IHandledMessage message = new HandledMessageWrapper(new BasicDeliverEventArgs( "consumer", 1, false, "ex", "rout", basicProperties, body)); var res = await adapter.HandleMessageTask(message); res.Should().Be(AckResult.Ack); httpApplication.Received().CreateContext(Arg.Is <IFeatureCollection>(x => CheckRequest(x, message, body) )); }