예제 #1
0
        public void WhenChannelsHaveNoIdsReturnsChannelWithHighestVersion()
        {
            var sut             = new BestChannelFinder(Substitute.For <IDebuggingInfoLogger>());
            var appcast         = RemoteAppcast.MakeFromJson(_twoChannelJson);
            var selectedChannel = sut.Find(4, appcast.Channels);

            Assert.IsNotNull(selectedChannel);
            Assert.AreEqual(appcast.Channels[1], selectedChannel);
        }
예제 #2
0
        public void ReturnsTheBestChannelBasedOnVersion()
        {
            var sut      = new BestChannelFinder(Substitute.For <IDebuggingInfoLogger>());
            var channels = new List <Channel> {
                new MockChannel(2, "1.1.1"), new MockChannel(3, "1.0.1")
            };
            var selectedChannel = sut.Find(3, channels);

            Assert.IsNotNull(selectedChannel);
            Assert.AreEqual(channels[0], selectedChannel);
        }
예제 #3
0
        public void ReturnsHighestVersionChannelIfNoChannelMatches()
        {
            var sut      = new BestChannelFinder(Substitute.For <IDebuggingInfoLogger>());
            var channels = new List <Channel> {
                new MockChannel(2, "2.1.1"), new MockChannel(3, "1.1.1")
            };
            var selectedChannel = sut.Find(1, channels);

            Assert.IsNotNull(selectedChannel);
            Assert.AreEqual(selectedChannel, channels[0]);
        }
예제 #4
0
        public void ReturnsOnlyChannelLessThanEqualId()
        {
            var sut      = new BestChannelFinder(Substitute.For <IDebuggingInfoLogger>());
            var channels = new List <Channel>
            {
                new MockChannel(2, "1.1.1"),
                new MockChannel(3, "1.2.1"),
                new MockChannel(4, "2.2.2")
            };
            var selectedChannel = sut.Find(3, channels);

            Assert.IsNotNull(selectedChannel);
            Assert.AreEqual(channels[1], selectedChannel);
        }
예제 #5
0
        public void ReturnsMoreStableVersionInCaseOfVersionMatch()
        {
            var sut      = new BestChannelFinder(Substitute.For <IDebuggingInfoLogger>());
            var channels = new List <Channel>
            {
                new MockChannel(2, "1.1.1"),
                new MockChannel(3, "2.2.2"),
                new MockChannel(4, "2.2.2")
            };
            var selectedChannel = sut.Find(4, channels);

            Assert.IsNotNull(selectedChannel);
            Assert.AreEqual(channels[1], selectedChannel);
        }
예제 #6
0
        public void WhenChannelsHaveMixIdsReturnsChannelWithHighestVersionLessThanSubscribedId()
        {
            var sut     = new BestChannelFinder(Substitute.For <IDebuggingInfoLogger>());
            var appcast = RemoteAppcast.MakeFromJson(_threeChannelJson);
            // subscribed to 3, and there is an id of 2 in the json
            var selectedChannel = sut.Find(3, appcast.Channels);

            Assert.IsNotNull(selectedChannel);
            Assert.AreEqual(appcast.Channels[1], selectedChannel);

            // subscribed to 1, but because there is id that matches it, it returns the highest version of all
            selectedChannel = sut.Find(1, appcast.Channels);
            Assert.IsNotNull(selectedChannel);
            Assert.AreEqual(appcast.Channels[2], selectedChannel);
        }
예제 #7
0
        public void ReturnsNullIfChannelListIsNull()
        {
            var sut = new BestChannelFinder(Substitute.For <IDebuggingInfoLogger>());

            Assert.IsNull(sut.Find(1, null));
        }