Ejemplo n.º 1
0
 public void Should_not_throw_exception_because_of_messageDelay()
 {
     var invitation = new PartyInvitation
     {
         Text = "Please come to my party",
         Date = new DateTime(2011, 5, 24)
     };
     bus.FuturePublish(TimeSpan.FromMilliseconds(int.MaxValue - 1), invitation);
 }
Ejemplo n.º 2
0
        public void Should_not_throw_exception_because_of_messageDelay()
        {
            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            bus.FuturePublish(TimeSpan.FromMilliseconds(int.MaxValue - 1), invitation);
        }
Ejemplo n.º 3
0
        public void High_volume_scheduling_test()
        {
            logger.Debug = false;

            bus.Subscribe<PartyInvitation>("schedulingTest1", message =>
                Console.WriteLine("Got scheduled message: {0}", message.Text));

            var count = 0;
            while (true)
            {
                var invitation = new PartyInvitation
                {
                    Text = string.Format("Invitation {0}", count++),
                    Date = new DateTime(2011, 5, 24)
                };

                bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), invitation);
                Thread.Sleep(1);
            }
        }
Ejemplo n.º 4
0
        public void Should_be_able_to_schedule_a_message()
        {
            var autoResetEvent = new AutoResetEvent(false);

            bus.Subscribe <PartyInvitation>("schedulingTest1", message =>
            {
                Console.WriteLine("Got scheduled message: {0}", message.Text);
                autoResetEvent.Set();
            });

            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), invitation);

            autoResetEvent.WaitOne(10000);
        }
Ejemplo n.º 5
0
        public void Should_be_able_to_schedule_a_message_2()
        {
            var autoResetEvent = new AutoResetEvent(false);

            bus.Subscribe<PartyInvitation>("schedulingTest1", message =>
            {
                Console.WriteLine("Got scheduled message: {0}", message.Text);
                autoResetEvent.Set();
            });
            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            bus.FuturePublish(TimeSpan.FromSeconds(3), invitation);

            if(! autoResetEvent.WaitOne(100000))
                Assert.Fail();
        }
Ejemplo n.º 6
0
        public void High_volume_scheduling_test_2()
        {
            logger.Debug = false;

            bus.Subscribe <PartyInvitation>("schedulingTest1", message =>
                                            Console.WriteLine("Got scheduled message: {0}", message.Text));

            var count = 0;

            while (true)
            {
                var invitation = new PartyInvitation
                {
                    Text = string.Format("Invitation {0}", count++),
                    Date = new DateTime(2011, 5, 24)
                };

                bus.FuturePublish(TimeSpan.FromSeconds(3), invitation);
                Thread.Sleep(1);
            }
        }
        public void Should_be_able_to_get_a_message()
        {
            var autoResetEvent = new AutoResetEvent(false);

            bus.Subscribe<PartyInvitation>("Should_be_able_to_get_a_message", message =>
                {
                    Console.WriteLine("Got message: {0}", message.Text);
                    autoResetEvent.Set();
                });

            var invitation = new PartyInvitation
                {
                    Text = "Please come to my party",
                    Date = new DateTime(2011, 5, 24)
                };

            bus.Publish(invitation);

            if (! autoResetEvent.WaitOne(100000))
                Assert.Fail();
        }
        public void Should_be_able_to_get_a_message()
        {
            var autoResetEvent = new AutoResetEvent(false);

            bus.Subscribe <PartyInvitation>("Should_be_able_to_get_a_message", message =>
            {
                Console.WriteLine("Got message: {0}", message.Text);
                autoResetEvent.Set();
            });

            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            bus.Publish(invitation);

            if (!autoResetEvent.WaitOne(100000))
            {
                Assert.True(false);
            }
        }
Ejemplo n.º 9
0
        public void High_volume_scheduling_test()
        {
            logger.Debug = false;

            bus.Subscribe <PartyInvitation>("schedulingTest1", message =>
                                            Console.WriteLine("Got scheduled message: {0}", message.Text));

            var count = 0;

            while (true)
            {
                var invitation = new PartyInvitation
                {
                    Text = string.Format("Invitation {0}", count++),
                    Date = new DateTime(2011, 5, 24)
                };

                using (var publishChannel = bus.OpenPublishChannel())
                {
                    publishChannel.FuturePublish(DateTime.UtcNow.AddSeconds(3), invitation);
                }
                Thread.Sleep(1);
            }
        }
Ejemplo n.º 10
0
        public void Should_be_able_to_cancel_a_message()
        {
            var messagesReceived = 0;

            bus.Subscribe <PartyInvitation>("schedulingTest1", message =>
            {
                Console.WriteLine("Got scheduled message: {0}", message.Text);
                messagesReceived++;
            });

            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), "my_cancellation_key", invitation);
            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), invitation);
            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), "my_cancellation_key", invitation);
            bus.CancelFuturePublish("my_cancellation_key");

            Thread.Sleep(10000);
            Assert.AreEqual(1, messagesReceived);
        }
Ejemplo n.º 11
0
        public void Should_be_able_to_cancel_a_message()
        {
            var messagesReceived = 0;

            bus.Subscribe<PartyInvitation>("schedulingTest1", message =>
            {
                Console.WriteLine("Got scheduled message: {0}", message.Text);
                messagesReceived++;
            });

            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), "my_cancellation_key", invitation);
            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), invitation);
            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), "my_cancellation_key", invitation);
            bus.CancelFuturePublish("my_cancellation_key");

            Thread.Sleep(10000);
            Assert.AreEqual(1, messagesReceived);
        }
Ejemplo n.º 12
0
        public void Should_be_able_to_schedule_a_message()
        {
            var autoResetEvent = new AutoResetEvent(false);

            bus.Subscribe<PartyInvitation>("schedulingTest1", message =>
            {
                Console.WriteLine("Got scheduled message: {0}", message.Text);
                autoResetEvent.Set();
            });

            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            using (var publishChannel = bus.OpenPublishChannel())
            {
                publishChannel.FuturePublish(DateTime.UtcNow.AddSeconds(3), invitation);
            }

            autoResetEvent.WaitOne(10000);
        }