示例#1
0
        private async Task should_send_ping(
            Mock <IWebSocketClient> webSocket,
            SlackConnection slackConnection)
        {
            // given
            const string slackKey = "key-yay";

            var connectionInfo = new ConnectionInformation {
                WebSocket = webSocket.Object, SlackKey = slackKey
            };
            await slackConnection.Initialise(connectionInfo);

            // when
            await slackConnection.Ping();

            // then
            webSocket.Verify(x => x.SendMessage(It.IsAny <PingMessage>()));
        }
示例#2
0
        public async Task should_pong_to_our_ping()
        {
            // given
            bool hasPonged = false;

            SlackConnection.OnPong += timestamp => { hasPonged = true; return(Task.CompletedTask); };

            // when
            await SlackConnection.Ping();

            // then
            for (int i = 0; i < 10; i++)
            {
                if (hasPonged)
                {
                    break;
                }

                Thread.Sleep(TimeSpan.FromSeconds(1));
            }

            hasPonged.ShouldBeTrue();
        }