public void will_publish_one_of_each_message_to_double_handler() { //Arrange var ping_pong_logger = new MessageLogger(); var ping_pong_handler = new PingPongHandler(ping_pong_logger.add, ping_pong_logger.add); Bus.Instance.Register(ping_pong_handler); //Act Bus.Instance.SendMessage(new Ping()); Bus.Instance.SendMessage(new Pong()); //Assert Assert.AreEqual(2, ping_pong_logger.messages.Count()); Assert.AreEqual(1, ping_pong_logger.get_messages_of_type <Ping>().Count()); Assert.AreEqual(1, ping_pong_logger.get_messages_of_type <Pong>().Count()); }
public void will_publish_manytimes_to_double_handler() { //Arrange var ping_pong_logger = new MessageLogger(); var ping_pong_handler = new PingPongHandler(ping_pong_logger.add, ping_pong_logger.add); Bus.Instance.Register(ping_pong_handler); //Act Enumerable .Range(0, 5) .ToList() .ForEach(i => { Bus.Instance.SendMessage(new Ping()); Bus.Instance.SendMessage(new Pong()); }); //Assert Assert.AreEqual(5, ping_pong_logger.get_messages_of_type <Ping>().Count()); Assert.AreEqual(5, ping_pong_logger.get_messages_of_type <Pong>().Count()); }