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()); }
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)); }
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()); }
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)); }