Ejemplo n.º 1
0
        public void TestSendSyncNotBlockForever()
        {
            var connectionString       = ValidConnectionString();
            var pubsubManagerPublisher = new RedisFarmTransport(connectionString);

            pubsubManagerPublisher.PublishSync(new FarmMessage {
                AppName = "test", Time = DateTime.Now
            });
        }
Ejemplo n.º 2
0
        public void TestSendMessageDontArriveToMyself()
        {
            var connectionString = ValidConnectionString();
            var pubsubManager    = new RedisFarmTransport(connectionString);

            ManualResetEvent manual1 = new ManualResetEvent(false);

            pubsubManager.OnMessage += (a, b) => {
                throw new NullReferenceException();
            };

            pubsubManager.PublishSync(new FarmMessage {
                AppName = "test", Time = DateTime.Now
            });

            Assert.AreEqual(pubsubManager.MessageCount, 1);
            Assert.AreEqual(pubsubManager.ValidMessageCount, 0);
        }
Ejemplo n.º 3
0
        public void TestCanSendMessageAndGetItBackOnePublisherAndDifferentSubscriber()
        {
            var connectionString        = ValidConnectionString();
            var pubsubManagerPublisher  = new RedisFarmTransport(connectionString);
            var pubsubManagerSubscriber = new RedisFarmTransport(connectionString);

            ManualResetEvent manual1 = new ManualResetEvent(false);

            pubsubManagerSubscriber.OnMessage += (a, b) =>
            {
                Assert.AreEqual(b.Message.AppName, "test");
                manual1.Set();
            };

            pubsubManagerPublisher.PublishSync(new FarmMessage {
                AppName = "test", Time = DateTime.Now
            });
            var res = manual1.WaitOne(5 * 1000);

            Assert.IsTrue(res);
        }