Example #1
0
        public void Should_consume_ordered_messages()
        {
            var consumer = new GenericMultipleArrivalsConsumer<MyMessage>(Sequence.Length);
            Bus.AddInstanceSubscription(consumer);

            foreach (var u in Sequence)
                Bus.Publish(new MyMessage {Value = (int) u});

            Assert.IsTrue(consumer.WaitForDelivery());
            Assert.AreEqual(Sequence.OrderBy(s => s).ToArray(), consumer.Received.Select(r => (uint)r.Value).ToArray());
        }
Example #2
0
        public void Should_not_consume_duplicate_messages()
        {
            var consumer = new GenericMultipleArrivalsConsumer<MyMessage>(10);
            Bus.AddInstanceSubscription(consumer);

            for (int i = 0; i < 10; i++)
                Bus.Publish(new MyMessage {Value = i});

            Assert.IsFalse(consumer.WaitForDelivery());
            Assert.AreEqual(5, consumer.Received.Count);
            Assert.AreElementsEqual(Enumerable.Range(0, 5), consumer.Received.Select(r => r.Value));
        }
Example #3
0
        public void Should_consume_ordered_messages()
        {
            var consumer = new GenericMultipleArrivalsConsumer <MyMessage>(Sequence.Length);

            Bus.AddInstanceSubscription(consumer);

            foreach (var u in Sequence)
            {
                Bus.Publish(new MyMessage {
                    Value = (int)u
                });
            }

            Assert.IsTrue(consumer.WaitForDelivery());
            Assert.AreEqual(Sequence.OrderBy(s => s).ToArray(), consumer.Received.Select(r => (uint)r.Value).ToArray());
        }
Example #4
0
        public void Should_not_consume_duplicate_messages()
        {
            var consumer = new GenericMultipleArrivalsConsumer <MyMessage>(10);

            Bus.AddInstanceSubscription(consumer);

            for (int i = 0; i < 10; i++)
            {
                Bus.Publish(new MyMessage {
                    Value = i
                });
            }

            Assert.IsFalse(consumer.WaitForDelivery());
            Assert.AreEqual(5, consumer.Received.Count);
            Assert.AreElementsEqual(Enumerable.Range(0, 5), consumer.Received.Select(r => r.Value));
        }