public void GetChannels_GetsChannelsFromRestAndCreateChannelObjects()
        {
            var baseUri     = new Uri("http://localhost/");
            var channelList = new ChannelList
            {
                Channels = new List <Channel>
                {
                    new Channel
                    {
                        ChannelId   = CHANNEL1_ID,
                        ChannelName = CHANNEL1_NAME
                    },
                    new Channel
                    {
                        ChannelId   = CHANNEL2_ID,
                        ChannelName = CHANNEL2_NAME
                    }
                }
            };
            var list = new List <IChatChannel> {
                Mock.Of <IChatChannel>(), Mock.Of <IChatChannel>()
            };
            var restService = new Mock <IRestService>();

            restService.Setup(x => x.GetChannelList(baseUri, TOKEN, TEAM_GUID)).Returns(channelList);
            var channelFactory = new Mock <IChatChannelFactory>();

            channelFactory.Setup(
                x => x.NewInstance(restService.Object, baseUri, TOKEN, USER_ID, TEAM_GUID, channelList.Channels[0]))
            .Returns(list[0]);
            channelFactory.Setup(
                x => x.NewInstance(restService.Object, baseUri, TOKEN, USER_ID, TEAM_GUID, channelList.Channels[1]))
            .Returns(list[1]);
            var sut = new SessionImpl(restService.Object, baseUri,
                                      TOKEN, USER_ID, TEAM_GUID, channelFactory.Object, Mock.Of <IChatPostFactory>());

            var result = sut.GetChannels();

            Assert.True(result.SequenceEqual(list));
        }
Ejemplo n.º 2
0
        public void GetChannels_GetsChannelsFromRestAndCreateChannelObjects()
        {
            var baseUri     = new Uri("http://localhost/");
            var channelList = new List <Channel>
            {
                new Channel
                {
                    Id   = CHANNEL_ID,
                    Name = CHANNEL_NAME
                },
                new Channel
                {
                    Id   = CHANNEL_ID_2,
                    Name = CHANNEL_NAME_2
                }
            };
            var list = new List <IChatChannel> {
                Mock.Of <IChatChannel>(), Mock.Of <IChatChannel>()
            };
            var restService = new Mock <IRestService>();

            restService.Setup(x => x.GetChannels(baseUri, TOKEN, TEAM_ID)).Returns(channelList);
            var channelFactory = new Mock <IChatChannelFactory>();

            channelFactory.Setup(
                x => x.NewInstance(restService.Object, baseUri, TOKEN, TEAM_ID, channelList[0]))
            .Returns(list[0]);
            channelFactory.Setup(
                x => x.NewInstance(restService.Object, baseUri, TOKEN, TEAM_ID, channelList[1]))
            .Returns(list[1]);
            var sut = new SessionImpl(restService.Object, baseUri,
                                      TOKEN, TEAM_ID, channelFactory.Object, Mock.Of <IChatPostFactory>());

            var result = sut.GetChannels();

            result.ShouldBeEquivalentTo(channelList);
        }