Exemple #1
0
        public void testMultipleChannelsWithSelector()
        {
            QueueChannel channel1 = new QueueChannel();
            QueueChannel channel2 = new QueueChannel();

            channel1.Send(new StringMessage("test1"));
            channel1.Send(new StringMessage("test2"));
            channel1.Send(new StringMessage("test3"));
            channel2.Send(new StringMessage("test1"));
            channel2.Send(new StringMessage("test2"));
            channel2.Send(new StringMessage("test3"));
            ChannelPurger purger = new ChannelPurger(delegate(IMessage msg) { return(msg.Payload.Equals("test2")); },
                                                     channel1, channel2);
            IList <IMessage> purgedMessages = purger.Purge();

            Assert.That(purgedMessages.Count, Is.EqualTo(4));
            IMessage message1 = channel1.Receive(TimeSpan.Zero);

            Assert.IsNotNull(message1);
            Assert.That(message1.Payload, Is.EqualTo("test2"));
            Assert.IsNull(channel1.Receive(TimeSpan.Zero));
            IMessage message2 = channel2.Receive(TimeSpan.Zero);

            Assert.IsNotNull(message2);
            Assert.That(message2.Payload, Is.EqualTo("test2"));
            Assert.IsNull(channel2.Receive(TimeSpan.Zero));
        }
Exemple #2
0
        public void testPurgeAllWithoutSelector()
        {
            QueueChannel channel = new QueueChannel();

            channel.Send(new StringMessage("test1"));
            channel.Send(new StringMessage("test2"));
            channel.Send(new StringMessage("test3"));
            ChannelPurger    purger         = new ChannelPurger(channel);
            IList <IMessage> purgedMessages = purger.Purge();

            Assert.That(purgedMessages.Count, Is.EqualTo(3));
            Assert.IsNull(channel.Receive(TimeSpan.Zero));
        }
Exemple #3
0
        public void testPurgeNoneWithSelector()
        {
            QueueChannel channel = new QueueChannel();

            channel.Send(new StringMessage("test1"));
            channel.Send(new StringMessage("test2"));
            channel.Send(new StringMessage("test3"));
            ChannelPurger    purger         = new ChannelPurger(delegate { return(true); }, channel);
            IList <IMessage> purgedMessages = purger.Purge();

            Assert.That(purgedMessages.Count, Is.EqualTo(0));
            Assert.IsNotNull(channel.Receive(TimeSpan.Zero));
            Assert.IsNotNull(channel.Receive(TimeSpan.Zero));
            Assert.IsNotNull(channel.Receive(TimeSpan.Zero));
        }
Exemple #4
0
        public void testMultipleChannelsWithNoSelector()
        {
            QueueChannel channel1 = new QueueChannel();
            QueueChannel channel2 = new QueueChannel();

            channel1.Send(new StringMessage("test1"));
            channel1.Send(new StringMessage("test2"));
            channel2.Send(new StringMessage("test1"));
            channel2.Send(new StringMessage("test2"));
            ChannelPurger    purger         = new ChannelPurger(channel1, channel2);
            IList <IMessage> purgedMessages = purger.Purge();

            Assert.That(purgedMessages.Count, Is.EqualTo(4));
            Assert.IsNull(channel1.Receive(TimeSpan.Zero));
            Assert.IsNull(channel2.Receive(TimeSpan.Zero));
        }
Exemple #5
0
        public void testPurgeSubsetWithSelector()
        {
            QueueChannel channel = new QueueChannel();

            channel.Send(new StringMessage("test1"));
            channel.Send(new StringMessage("test2"));
            channel.Send(new StringMessage("test3"));
            ChannelPurger purger = new ChannelPurger(delegate(IMessage msg) { return(msg.Payload.Equals("test2")); },
                                                     channel);
            IList <IMessage> purgedMessages = purger.Purge();

            Assert.That(purgedMessages.Count, Is.EqualTo(2));
            IMessage message = channel.Receive(TimeSpan.Zero);

            Assert.IsNotNull(message);
            Assert.That(message.Payload, Is.EqualTo("test2"));
            Assert.IsNull(channel.Receive(TimeSpan.Zero));
        }