Пример #1
0
        public void CreateMagnetLink_NonEmptyTracker_WithOptionIncludeTrackers_IsIncluded(string infoHash, string displayName, string tracker1)
        {
            var trackers = new List <string> {
                tracker1
            };

            var magnet = TorrentUtil.CreateMagnetLink(infoHash, displayName, trackers, MagnetLinkOptions.IncludeTrackers);

            magnet.Should().Be($"magnet:?xt=urn:btih:{infoHash}&dn={displayName}&tr={tracker1}");
        }
Пример #2
0
        public void CreateMagnetLink_Torrent_UsesInfoHashDisplayNameAndTrackersFromTorrent(string infoHash, string displayName, IList <IList <string> > trackers)
        {
            // Arrange
            var torrent = Substitute.For <Torrent>();

            torrent.GetInfoHash().Returns(infoHash);
            torrent.DisplayName.Returns(displayName);
            torrent.Trackers.Returns(trackers);

            // Act
            var expected = TorrentUtil.CreateMagnetLink(infoHash.ToLower(), displayName, trackers.SelectMany(x => x), MagnetLinkOptions.IncludeTrackers);
            var magnet   = TorrentUtil.CreateMagnetLink(torrent);

            // Assert
            magnet.Should().Be(expected);
        }
Пример #3
0
        public void CreateMagnetLink_NonEmptyDisplayName_IsIncluded(string infoHash, string displayName)
        {
            var magnet = TorrentUtil.CreateMagnetLink(infoHash, displayName, null, MagnetLinkOptions.None);

            magnet.Should().Be($"magnet:?xt=urn:btih:{infoHash}&dn={displayName}");
        }
Пример #4
0
        public void CreateMagnetLink_NonEmptyInfoHash_IsIncluded(string infoHash)
        {
            var magnet = TorrentUtil.CreateMagnetLink(infoHash, null, null, MagnetLinkOptions.None);

            magnet.Should().Be($"magnet:?xt=urn:btih:{infoHash}");
        }
Пример #5
0
        public void CreateMagnetLink_NullOrEmptyInfoHash_ThrowsArgumentException(string infoHash)
        {
            Action action = () => TorrentUtil.CreateMagnetLink(infoHash, null, null, MagnetLinkOptions.None);

            action.Should().Throw <ArgumentException>("because a Magnet link is invalid without an info hash.");
        }