Exemplo n.º 1
0
        public void OnHandler_WithConcreteTypeRegisterd()
        {
            var evt = new AutoResetEvent(false);

            bot.On <TestMessage>(msg =>
            {
                evt.Set();
            });

            this.bus.Publish(new TestMessage());

            if (!evt.WaitOne(10))
            {
                Assert.True(false, "Callback for Message was not triggered");
            }
        }
Exemplo n.º 2
0
        public static void WaitForMessageToBeReceived <T>(this SlackBot bot, Predicate <T> matcher, Action action)
            where T : IRtmMessage
        {
            var evt = new AutoResetEvent(false);

            using (bot.On <T>(msg => { if (matcher(msg))
                                       {
                                           evt.Set();
                                       }
                              }))
            {
                action();

                if (!evt.WaitOne(100))
                {
                    Assert.True(false, $"{typeof(T).Name} message was not received");
                }
            }
        }