public void GetGroups_FetchesGroupList_AndCaches() { var group1 = new Channel { Id = "G1" }; var group2 = new Channel { Id = "G2" }; _api.Groups.List().Returns(new[] { group1, group2 }); _sut.GetGroups() .ShouldComplete() .And.ShouldMatch(new[] { group1, group2 }); _sut.GetGroups() .ShouldComplete() .And.ShouldMatch(new[] { group1, group2 }); _api.Groups.Received(1).List(); }
public async Task GetGroups_FetchesGroupList_AndCaches() { var group1 = new Conversation { Id = "G1", IsGroup = true }; var group2 = new Conversation { Id = "G2", IsGroup = true }; var notAGroup = new Conversation { Id = "C1", IsChannel = true }; _api.Conversations.List(types: IsOfAllConversationTypes()).Returns(ConversationList(group1, group2, notAGroup)); var results = await _sut.GetGroups(); results.ShouldAllBeA <Channel>() .And.ShouldOnlyContain(new[] { group1, group2 }, (ch, co) => ch.Id == co.Id); _sut.GetGroups() .ShouldComplete() .And.ShouldOnlyContain(results); await _api.Conversations.Received(1).List(types: IsOfAllConversationTypes()); }