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));
 }
 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));
 }
 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));
 }
 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));
 }
 public void testPurgeNoneWithSelectorAndMultipleChannels()
 {
     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(delegate { return true; }, channel1, channel2);
     IList<IMessage> purgedMessages = purger.Purge();
     Assert.That(purgedMessages.Count, Is.EqualTo(0));
     Assert.IsNotNull(channel1.Receive(TimeSpan.Zero));
     Assert.IsNotNull(channel1.Receive(TimeSpan.Zero));
     Assert.IsNotNull(channel2.Receive(TimeSpan.Zero));
     Assert.IsNotNull(channel2.Receive(TimeSpan.Zero));
 }