Beispiel #1
0
        public void RMQCountTest()
        {
            subscribers = new SubscriberRMQ <TestEvent> [10];

            GenSubscribers(subscribers);

            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                PublisherRMQ <TestEvent> publisher = new PublisherRMQ <TestEvent>();
                publisher.HostName    = "localhost";
                publisher.Port        = 5672;
                publisher.VirtualHost = "/";
                publisher.Protocol    = "AMQP_0_8";
                publisher.Publish(new TestEvent()
                {
                    Data = DateTime.Now.ToString(), Processed = false
                });
            });

            if (countEvent.Wait(TimeSpan.FromSeconds(6)) == false)
            {
                Assert.Fail();
            }

            Unsubscribe(subscribers);
            subscribers = null;
        }
 public void PublishRMQTest()
 {
     PublisherRMQ<TestEvent> publisher = new PublisherRMQ<TestEvent>();
     publisher.HostName = "localhost";
     publisher.Port = 5672;
     publisher.VirtualHost = "/";
     publisher.Protocol = "AMQP_0_8";
     publisher.Publish(new TestEvent() { Data = DateTime.Now.ToString(), Processed = false });
 }
Beispiel #3
0
        public void PublishRMQTest()
        {
            PublisherRMQ <TestEvent> publisher = new PublisherRMQ <TestEvent>();

            publisher.HostName    = "localhost";
            publisher.Port        = 5672;
            publisher.VirtualHost = "/";
            publisher.Protocol    = "AMQP_0_8";
            publisher.Publish(new TestEvent()
            {
                Data = DateTime.Now.ToString(), Processed = false
            });
        }
Beispiel #4
0
        public void TestPublisherReceiverRMQTest()
        {
            SubscriberRMQ <TestEvent> subscriber = new SubscriberRMQ <TestEvent>();

            subscriber.HostName       = "localhost";
            subscriber.Port           = 5672;
            subscriber.VirtualHost    = "/";
            subscriber.Protocol       = "AMQP_0_8";
            subscriber.EventHandled  += subscriber_EventHandled;
            subscriber.EventReceived += subscriber_EventReceived;
            subscriber.Subscribe();

            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                PublisherRMQ <TestEvent> publisher = new PublisherRMQ <TestEvent>();
                publisher.HostName    = "localhost";
                publisher.Port        = 5672;
                publisher.VirtualHost = "/";
                publisher.Protocol    = "AMQP_0_8";
                publisher.Publish(new TestEvent()
                {
                    Data = DateTime.Now.ToString(), Processed = false
                });
            });

            if (!mre.WaitOne(TimeSpan.FromSeconds(13)))
            {
                Assert.Fail();
            }
            else
            {
                Assert.IsTrue(Received);
            }

            mre.Reset();

            if (!mre.WaitOne(TimeSpan.FromSeconds(10)))
            {
                Assert.Fail();
            }
            else
            {
                Assert.IsTrue(Handled);
            }

            subscriber.Unsubscribe();
        }
        public void RMQCountTest()
        {
            subscribers = new SubscriberRMQ<TestEvent>[10];

            GenSubscribers(subscribers);

            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                PublisherRMQ<TestEvent> publisher = new PublisherRMQ<TestEvent>();
                publisher.HostName = "localhost";
                publisher.Port = 5672;
                publisher.VirtualHost = "/";
                publisher.Protocol = "AMQP_0_8";
                publisher.Publish(new TestEvent() { Data = DateTime.Now.ToString(), Processed = false });
            });

            if (countEvent.Wait(TimeSpan.FromSeconds(6)) == false)
                Assert.Fail();

            Unsubscribe(subscribers);
            subscribers = null;
        }
        public void TestPublisherReceiverRMQTest()
        {
            SubscriberRMQ<TestEvent> subscriber = new SubscriberRMQ<TestEvent>();
            subscriber.HostName = "localhost";
            subscriber.Port = 5672;
            subscriber.VirtualHost = "/";
            subscriber.Protocol = "AMQP_0_8";
            subscriber.EventHandled += subscriber_EventHandled;
            subscriber.EventReceived += subscriber_EventReceived;
            subscriber.Subscribe();

            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                PublisherRMQ<TestEvent> publisher = new PublisherRMQ<TestEvent>();
                publisher.HostName = "localhost";
                publisher.Port = 5672;
                publisher.VirtualHost = "/";
                publisher.Protocol = "AMQP_0_8";
                publisher.Publish(new TestEvent() { Data = DateTime.Now.ToString(), Processed = false });
            });

            if (!mre.WaitOne(TimeSpan.FromSeconds(13)))
            {
                Assert.Fail();
            }
            else
                Assert.IsTrue(Received);

            mre.Reset();

            if (!mre.WaitOne(TimeSpan.FromSeconds(10)))
            {
                Assert.Fail();
            }
            else
                Assert.IsTrue(Handled);

            subscriber.Unsubscribe();
        }