当前位置: 首页>>代码示例>>C#>>正文


C# Bus.PublishAsync方法代码示例

本文整理汇总了C#中Bus.PublishAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Bus.PublishAsync方法的具体用法?C# Bus.PublishAsync怎么用?C# Bus.PublishAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bus的用法示例。


在下文中一共展示了Bus.PublishAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: When_publishing_an_event_should_invoke_all_registered_event_handlers

        public void When_publishing_an_event_should_invoke_all_registered_event_handlers()
        {
            var serviceContainer = new ServiceContainer();
            serviceContainer.RegisterAssembly(typeof (BusTests).Assembly, (serviceType, implementingType) => serviceType.IsGenericType && serviceType.GetGenericTypeDefinition() == typeof (IHandleMessages<>));
            var bus = new Bus(serviceContainer.GetAllInstances);
            var message = new Event();

            bus.PublishAsync(message);

            message.NumberOfTimesHandled.ShouldEqual(2);
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:11,代码来源:BusTests.cs

示例2: PublishAsync_Null_Message_Results_In_An_Exception

		public void PublishAsync_Null_Message_Results_In_An_Exception()
		{
			var _busConfigurationBuilder = new BusConfigurationBuilder();
			_busConfigurationBuilder.ConnectionUris.Add(TestingConfiguration.LocalConnectionUri);
			var _busConfirguration = _busConfigurationBuilder.Build();

			var _SUT = new Bus(_busConfirguration);
			_SUT.Connect();

			_SUT.PublishAsync<MyEvent>(null);
		}
开发者ID:pmcgrath,项目名称:PMCG.Messaging,代码行数:11,代码来源:BusSpec.cs

示例3: When_publishing_an_event_should_polymorphic_dispatch_to_all_handlers

        public void When_publishing_an_event_should_polymorphic_dispatch_to_all_handlers()
        {
            var serviceContainer = new ServiceContainer();
            serviceContainer.Register<IHandleMessages<Event>, EventHandler>();
            serviceContainer.Register<IHandleMessages<Event>, AnotherEventHandler>("Another");
            var messageHandler = new MessageHandler();
            serviceContainer.RegisterInstance<IHandleMessages<IMessage>>(messageHandler);
            var bus = new Bus(serviceContainer.GetAllInstances);
            var message = new Event();

            bus.PublishAsync(message);

            message.NumberOfTimesHandled.ShouldEqual(2);
            messageHandler.IsHandled.ShouldBeTrue();
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:15,代码来源:BusTests.cs

示例4: When_event_handler_throws_exception_should_propagate_exception

        public void When_event_handler_throws_exception_should_propagate_exception()
        {
            var serviceContainer = new ServiceContainer();
            serviceContainer.Register<IHandleMessages<EventWithException>, EventWithExceptionHandler>();
            var bus = new Bus(serviceContainer.GetAllInstances);

            Assert.Throws<InvalidOperationException>(() => bus.PublishAsync(new EventWithException()).Wait());
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:8,代码来源:BusTests.cs

示例5: When_sending_the_same_event_multiple_times_should_get_handlers_from_cahce

        public void When_sending_the_same_event_multiple_times_should_get_handlers_from_cahce()
        {
            var serviceContainer = new ServiceContainer();
            serviceContainer.RegisterAssembly(typeof (BusTests).Assembly, (serviceType, implementingType) => serviceType.IsGenericType && serviceType.GetGenericTypeDefinition() == typeof (IHandleMessages<>));
            IBus bus = new Bus(serviceContainer.GetAllInstances);
            var message = new Event();

            Assert.DoesNotThrow(() =>
            {
                bus.PublishAsync(message);
                bus.PublishAsync(message);
                bus.PublishAsync(message);
            });
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:14,代码来源:BusTests.cs


注:本文中的Bus.PublishAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。