public void I_should_only_be_allowed_to_add_valid_message_types() { Assert.Throws <ArgumentException>(() => { SpecialGroup group = MessageGroup.Build <SpecialGroup>() .Add(new PingMessage()) .Add(new PongMessage()) .Add(new UpdateMessage()); }); }
public void I_should_be_able_to_retrieve_a_single_message_by_position() { PingMessage ping = new PingMessage(); PongMessage pong = new PongMessage(); MessageGroup group = MessageGroup.Build <MessageGroup>() .Add(ping) .Add(pong); PingMessage thePing = group.Get <PingMessage>(0); }
public void I_should_be_able_to_split_a_bunch_of_messages_from_a_group() { PingMessage ping = new PingMessage(); PongMessage pong = new PongMessage(); MessageGroup group = MessageGroup.Build <MessageGroup>() .Add(ping) .Add(pong); object[] items = group.ToArray(); Assert.That(items.Length, Is.EqualTo(2)); }
public void I_should_get_an_exception_when_I_try_to_get_an_unmatched_type() { PingMessage ping = new PingMessage(); PongMessage pong = new PongMessage(); MessageGroup group = MessageGroup.Build <MessageGroup>() .Add(ping) .Add(pong); Assert.Throws <ArgumentException>(() => { PingMessage thePing = group.Get <PingMessage>(1); }); }
public void I_Should_be_able_to_subscribe() { Consumer c = new Consumer(LocalBus); LocalBus.Subscribe(c); SpecialGroup group = MessageGroup.Build <SpecialGroup>() .Add(new PingMessage()) .Add(new PongMessage()); LocalBus.Publish(group); Assert.That(c.Received.WaitOne(TimeSpan.FromSeconds(5), true), Is.True, "No message received by consumer"); }
public void One() { PingMessage ping = new PingMessage(); PongMessage pong = new PongMessage(); MessageGroup group = MessageGroup.Build <MessageGroup>() .Add(ping) .Add(pong); Assert.That(group.Count, Is.EqualTo(2)); Assert.That(group[0], Is.TypeOf(typeof(PingMessage))); Assert.That(group[1], Is.TypeOf(typeof(PongMessage))); }
public void I_should_be_able_to_split_the_group_into_individual_messages_and_handle_each_one_on_its_own() { IServiceBus bus = MockRepository.GenerateMock <IServiceBus>(); PingMessage ping = new PingMessage(); PongMessage pong = new PongMessage(); MessageGroup group = MessageGroup.Build <MessageGroup>() .Add(ping) .Add(pong); bus.Expect(x => x.Publish(ping)); bus.Expect(x => x.Publish(pong)); group.Split(bus); bus.VerifyAllExpectations(); }
public void I_should_be_able_to_split_a_group_of_messages_into_parts() { Consumer c = new Consumer(LocalBus); LocalBus.Subscribe(c); SpecialGroup group = MessageGroup.Build <SpecialGroup>() .Add(new PingMessage()) .Add(new PongMessage()); group.SplitOnConsume = true; LocalBus.Publish(group); Assert.That(c.Received.WaitOne(TimeSpan.FromSeconds(300), true), Is.True, "No message received by consumer"); Assert.That(c.GotPing.WaitOne(TimeSpan.FromSeconds(300), true), Is.True, "No ping received by consumer"); Assert.That(c.GotPong.WaitOne(TimeSpan.FromSeconds(300), true), Is.True, "No pong received by consumer"); }