Beispiel #1
0
        private async Task should_return_expected_slack_topic(
            [Frozen] Mock <IConnectionFactory> connectionFactory,
            Mock <IChannelClient> channelClient,
            Mock <IWebSocketClient> webSocket,
            SlackConnection slackConnection)
        {
            // given
            const string slackKey     = "key-yay";
            const string channelName  = "public-channel-name";
            const string channelTopic = "new topic";

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

            connectionFactory
            .Setup(x => x.CreateChannelClient())
            .Returns(channelClient.Object);

            channelClient
            .Setup(x => x.SetTopic(slackKey, channelName, channelTopic))
            .ReturnsAsync(channelTopic);

            // when
            var result = await slackConnection.SetChannelTopic(channelName, channelTopic);

            // then
            result.ShouldLookLike(new SlackTopic
            {
                ChannelName = channelName,
                Topic       = channelTopic
            });
        }
Beispiel #2
0
        private async Task should_throw_exception_given_empty_channel_name(Mock <IWebSocketClient> webSocket, SlackConnection slackConnection)
        {
            // given
            var connectionInfo = new ConnectionInformation {
                WebSocket = webSocket.Object
            };
            await slackConnection.Initialise(connectionInfo);

            // when
            var exception = await Assert.ThrowsAsync <ArgumentNullException>(() => slackConnection.SetChannelTopic(string.Empty, "topic"));

            // then
            exception.Message.ShouldBe("Value cannot be null.\r\nParameter name: channelName");
        }