public async Task Assert() { var handler = new Subscriber <string>(); await handler.As <ISubscribe <string> >().Handle("input"); await handler.Assert(x => x.Should().Be("input"), TimeSpan.FromSeconds(1)); }
public async Task Test() { await using var sender = _bus.CreateSender("orders"); var publisher = new Publisher(sender); await _admin.Setup("orders", "ServiceA", "CreateOrder"); await _bus .CreateProcessor("orders", "ServiceA") .Hookup(new ServiceA(publisher)) .StartProcessingAsync(); await _admin.Setup("orders", "test", "OrderCreated"); var test = new Subscriber <OrderCreated>(); await _bus .CreateProcessor("orders", "test") .Hookup(test) .StartProcessingAsync(); var order = Generator.NewOrder(); await publisher.Publish("CreateOrder", order, DateTimeOffset.UtcNow); await test.Assert(x => x.Should().BeEquivalentTo(order), TimeSpan.FromSeconds(10)); }
public async Task Retry() { var handler = new Subscriber <string>(); await handler.As <ISubscribe <string> >().Handle("first"); await handler.As <ISubscribe <string> >().Handle("then"); await handler.Assert(y => y.Should().Be("then"), TimeSpan.FromSeconds(1)); }
public async Task Test1() { var test = new Subscriber <OrderCreated>(); var bus = Bus.Factory.CreateUsingAzureServiceBus(cfg => { cfg.Host(_config["Azure:ServiceBus:ConnectionString"]); cfg.ReceiveEndpoint("service-a", x => x.SubscriberFor <CreateOrder>(c => new ServiceA(new Publisher(c)))); cfg.ReceiveEndpoint("test", x => x.SubscriberFor <OrderCreated>(c => test)); }); await bus.StartAsync(); var order = Generator.NewOrder(); await bus.Publish(order); await test.Assert(x => x.Should().BeEquivalentTo(order)); }
public async Task ResetTimeoutOnMessageArrival() { var handler = new Subscriber <string>(); async Task Emit() { var subscriber = handler.As <ISubscribe <string> >(); for (var i = 0; i < 5; i++) { await subscriber.Handle($"a{i}"); await Task.Delay(TimeSpan.FromSeconds(1)); } await subscriber.Handle("input"); } await Task.WhenAll(Emit(), handler.Assert(y => y.Should().Be("input"), TimeSpan.FromSeconds(2))); }