Пример #1
0
        public void then_should_raised_event_with_expected_channel_information()
        {
            var expectedChatHub = new SlackChatHub
            {
                Id   = "channel-id",
                Name = "@test-user",
                Type = SlackChatHubType.DM
            };

            _lastHub.ShouldLookLike(expectedChatHub);
        }
        public void given_hub_id_then_should_return_expected_slack_hub(string hubId, SlackChatHubType hubType)
        {
            // given

            // when
            var          interpreter = new ChatHubInterpreter();
            SlackChatHub chatHub     = interpreter.FromId(hubId);

            // then
            var expected = new SlackChatHub
            {
                Id   = hubId,
                Name = hubId,
                Type = hubType
            };

            chatHub.ShouldLookLike(expected);
        }
Пример #3
0
        private async Task should_raise_event(
            Mock <IWebSocketClient> webSocket,
            SlackConnection slackConnection)
        {
            // given
            var connectionInfo = new ConnectionInformation {
                WebSocket = webSocket.Object
            };
            await slackConnection.Initialise(connectionInfo);

            SlackChatHub lastHub = null;

            slackConnection.OnChatHubJoined += hub =>
            {
                lastHub = hub;
                return(Task.CompletedTask);
            };

            var inboundMessage = new DmChannelJoinedMessage
            {
                Channel = new Im
                {
                    User   = "******",
                    Id     = "channel-id",
                    IsIm   = true,
                    IsOpen = true
                }
            };

            // when
            webSocket.Raise(x => x.OnMessage += null, null, inboundMessage);

            // then
            slackConnection.ConnectedHubs.ContainsKey("channel-id").ShouldBeTrue();
            slackConnection.ConnectedHubs["channel-id"].ShouldBe(lastHub);
            lastHub.ShouldLookLike(new SlackChatHub
            {
                Id   = "channel-id",
                Name = "@test-user",
                Type = SlackChatHubType.DM
            });
        }