예제 #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;
        }
예제 #2
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 });
 }
예제 #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
            });
        }
예제 #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();
        }
예제 #5
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;
        }
예제 #6
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();
        }