public void testSingleSelectorAccepts() { AtomicInteger counter = new AtomicInteger(); IMessageSelector selector = new TestMessageSelector(true, counter); MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector); QueueChannel channel = new QueueChannel(); channel.AddInterceptor(interceptor); Assert.That(channel.Send(new StringMessage("test1")), Is.True); }
public void testSingleSelectorRejects() { AtomicInteger counter = new AtomicInteger(); IMessageSelector selector = new TestMessageSelector(false, counter); MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector); QueueChannel channel = new QueueChannel(); channel.AddInterceptor(interceptor); channel.Send(new StringMessage("test1")); }
public void testMultipleSelectorsAccept() { AtomicInteger counter = new AtomicInteger(); IMessageSelector selector1 = new TestMessageSelector(true, counter); IMessageSelector selector2 = new TestMessageSelector(true, counter); MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector1, selector2); QueueChannel channel = new QueueChannel(); channel.AddInterceptor(interceptor); Assert.That(channel.Send(new StringMessage("test1")), Is.True); Assert.That(counter.Value, Is.EqualTo(2)); }
public void testMultipleSelectorsReject() { bool exceptionThrown = false; AtomicInteger counter = new AtomicInteger(); IMessageSelector selector1 = new TestMessageSelector(true, counter); IMessageSelector selector2 = new TestMessageSelector(false, counter); IMessageSelector selector3 = new TestMessageSelector(false, counter); IMessageSelector selector4 = new TestMessageSelector(true, counter); MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector1, selector2, selector3, selector4); QueueChannel channel = new QueueChannel(); channel.AddInterceptor(interceptor); try { channel.Send(new StringMessage("test1")); } catch (MessageDeliveryException) { exceptionThrown = true; } Assert.That(exceptionThrown, Is.True); Assert.That(counter.Value, Is.EqualTo(2)); }