public void GetChannels_FetchesChannelList_AndCaches() { var channel1 = new Channel { Id = "C1" }; var channel2 = new Channel { Id = "C2" }; _api.Channels.List().Returns(new[] { channel1, channel2 }); _sut.GetChannels() .ShouldComplete() .And.ShouldMatch(new[] { channel1, channel2 }); _sut.GetChannels() .ShouldComplete() .And.ShouldMatch(new[] { channel1, channel2 }); _api.Channels.Received(1).List(); }
public async Task GetChannels_FetchesChannelList_AndCaches() { var channel1 = new Conversation { Id = "C1", IsChannel = true }; var channel2 = new Conversation { Id = "C2", IsChannel = true }; var notAChannel = new Conversation { Id = "D1", IsIm = true }; _api.Conversations.List(types: IsOfAllConversationTypes()).Returns(ConversationList(channel1, channel2, notAChannel)); var results = await _sut.GetChannels(); results.ShouldAllBeA <Channel>() .And.ShouldOnlyContain(new[] { channel1, channel2 }, (ch, co) => ch.Id == co.Id); _sut.GetChannels() .ShouldComplete() .And.ShouldOnlyContain(results); await _api.Conversations.Received(1).List(types: IsOfAllConversationTypes()); }