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(); }
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 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(); }
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(); }