public async Task enqueue_locally() { var registry = new JasperRegistry(); registry.Handlers.DisableConventionalDiscovery(false); registry.Handlers.IncludeType <RecordCallHandler>(); registry.Services.ForSingletonOf <IFakeStore>().Use <FakeStore>(); registry.Services.AddTransient <IFakeService, FakeService>(); registry.Services.AddTransient <IWidget, Widget>(); var tracker = new MessageTracker(); registry.Services.AddSingleton(tracker); using (var runtime = JasperRuntime.For(registry)) { var waiter = tracker.WaitFor <Message1>(); var message = new Message1 { Id = Guid.NewGuid() }; await runtime.Get <IServiceBus>().Enqueue(message); var received = await waiter; received.Message.As <Message1>().Id.ShouldBe(message.Id); } }
public async Task enqueue_locally_lightweight() { var registry = new JasperRegistry(); registry.Handlers.IncludeType <RecordCallHandler>(); registry.Services.ForSingletonOf <IFakeStore>().Use <FakeStore>(); registry.Services.AddTransient <IFakeService, FakeService>(); registry.Services.AddTransient <IWidget, Widget>(); registry.Services.AddTransient <IMyService, MyService>(); registry.Services.AddTransient <IPongWriter, PongWriter>(); var tracker = new MessageTracker(); registry.Services.AddSingleton(tracker); using (var runtime = JasperRuntime.For(registry)) { var waiter = tracker.WaitFor <Message1>(); var message = new Message1 { Id = Guid.NewGuid() }; await runtime.Get <IServiceBus>().EnqueueLightweight(message); waiter.Wait(5.Seconds()); var received = waiter.Result; received.Message.As <Message1>().Id.ShouldBe(message.Id); } }
public async Task send_via_the_alias_and_messages_actually_get_there_2() { var tracker = new MessageTracker(); with(_ => { _.Services.AddSingleton(tracker); _.Services.For <IUriLookup>().Use <FakeUriLookup>(); _.Transports.ListenForMessagesFrom("fake://one"); }); var waiter = tracker.WaitFor <Message1>(); await Bus.Send("fake://one".ToUri(), new Message1()); var envelope = await waiter; envelope.Destination.ShouldBe("loopback://one".ToUri()); }