コード例 #1
0
ファイル: enqueue_a_message.cs プロジェクト: skovsende/jasper
        public async Task enqueue_locally_lightweight()
        {
            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>().EnqueueLightweight(message);

                var received = await waiter;

                received.Message.As <Message1>().Id.ShouldBe(message.Id);
            }
        }
コード例 #2
0
        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());
        }