示例#1
0
        public void Channel_PublishingEventClosedChannel_IsNotListened()
        {
            var channelName = "custom_closed_event";
            var channel     = new MsSqlMessageChannel(Configuration);

            var task = WarpSubscription <MyEvent>(channel, _event =>
            {
                Assert.Equal(Message, _event.Message);
                Assert.Equal(Timestamp, _event.Timestamp);
            }, channelName: channelName);

            Thread.Sleep(1000);
            channel.Close().Wait();

            channel.Publish(channelName, Event).Wait();
            Thread.Sleep(1000);

            Assert.False(task.Result);


            var purge = WarpSubscription <MyEvent>(channel, _event =>
            {
            }, channelName: channelName);

            Thread.Sleep(1000);
            Assert.True(purge.Result);
        }
示例#2
0
        public void Channel_PublishingEvent_IsListened()
        {
            var channel = new MsSqlMessageChannel(Configuration);

            var task = WarpSubscription <MyEvent>(channel, _event =>
            {
                Assert.Equal(Message, _event.Message);
                Assert.Equal(Timestamp, _event.Timestamp);
            });

            Thread.Sleep(1000);
            channel.Publish(Event).Wait();
            Thread.Sleep(1000);

            Assert.True(task.Result);
            channel.Close().Wait();
        }
示例#3
0
        public void Channel_PublishingEventToWrongChannel_IsNotListened()
        {
            var channelName1 = "custom_sb_event1";
            var channelName2 = "custom_sb_event2";
            var channel      = new MsSqlMessageChannel(Configuration);

            var task = WarpSubscription <MyEvent>(channel, _event =>
            {
                Assert.Equal(Message, _event.Message);
                Assert.Equal(Timestamp, _event.Timestamp);
            }, channelName: channelName1);

            Thread.Sleep(1000);
            channel.Publish(channelName2, Event).Wait();

            Thread.Sleep(1000);

            Assert.False(task.Result);
            channel.Close().Wait();
        }