예제 #1
0
        public void SubscribeAndUnsubscribeTest()
        {
            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();

            subscriber.Unsubscribe();
        }
예제 #2
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();
        }
예제 #3
0
        public void SubscribeAndUnsubscribeTest()
        {
            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();

            subscriber.Unsubscribe();
        }
예제 #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();
        }