コード例 #1
0
ファイル: SlackBotTests.cs プロジェクト: x10an14/SlackNet
        public void GetChannelByName_FindsChannelWithMatchingName_AndCaches()
        {
            var expectedChannel = new Channel {
                Id = "C1", Name = "foo"
            };
            var otherChannel = new Channel {
                Id = "C2", Name = "bar"
            };

            _api.Channels.List().Returns(new[] { otherChannel, expectedChannel });

            _sut.GetChannelByName("#foo")
            .ShouldComplete()
            .And.ShouldBe(expectedChannel);
            _sut.GetChannelByName("foo")
            .ShouldComplete()
            .And.ShouldBe(expectedChannel);
            _api.Channels.Received(1).List();
        }
コード例 #2
0
ファイル: SlackBotTests.cs プロジェクト: soxtoby/SlackNet
        public async Task GetChannelByName_FindsChannelWithMatchingName_AndCaches()
        {
            var expectedChannel = new Conversation {
                Id = "C1", Name = "foo", IsChannel = true
            };
            var otherChannel = new Conversation {
                Id = "C2", Name = "bar", IsChannel = true
            };

            _api.Conversations.List(types: IsOfAllConversationTypes()).Returns(ConversationList(otherChannel, expectedChannel));

            var result = await _sut.GetChannelByName("#foo");

            result.ShouldBeA <Channel>()
            .And.Name.ShouldBe(expectedChannel.Name);
            _sut.GetChannelByName("foo")
            .ShouldComplete()
            .And.ShouldBe(result);
            await _api.Conversations.Received(1).List(types: IsOfAllConversationTypes());
        }