public TorrentCreatorTests()
        {
            HashAlgoFactory.Register<SHA1, SHA1Fake>();

            creator = new TestTorrentCreator();
            announces = new RawTrackerTiers();
            announces.Add(new RawTrackerTier(new[] {"http://tier1.com/announce1", "http://tier1.com/announce2"}));
            announces.Add(new RawTrackerTier(new[] {"http://tier2.com/announce1", "http://tier2.com/announce2"}));

            creator.Comment = Comment;
            creator.CreatedBy = CreatedBy;
            creator.PieceLength = PieceLength;
            creator.Publisher = Publisher;
            creator.PublisherUrl = PublisherUrl;
            creator.SetCustom(CustomKey, CustomValue);
            files = new List<TorrentFile>(new[]
            {
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir1"), "File1"), (int) (PieceLength*2.30), 0, 1),
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir1"), "File2"), (int) (PieceLength*36.5), 1, 3),
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir2"), "File3"), (int) (PieceLength*3.17), 3, 12),
                new TorrentFile(Path.Combine(Path.Combine("Dir2", "SDir1"), "File4"), (int) (PieceLength*1.22), 12, 15),
                new TorrentFile(Path.Combine(Path.Combine("Dir2", "SDir2"), "File5"), (int) (PieceLength*6.94), 15, 15)
            });

            writer = new TestWriter();
            writer.DontWrite = true;
        }
Example #2
0
        public TorrentManager(MagnetLink magnetLink, string savePath, TorrentSettings settings, string torrentSave)
        {
            Check.MagnetLink(magnetLink);
            Check.InfoHash(magnetLink.InfoHash);
            Check.SavePath(savePath);
            Check.Settings(settings);
            Check.TorrentSave(torrentSave);

            this.infohash    = magnetLink.InfoHash;
            this.settings    = settings;
            this.torrentSave = torrentSave;
            IList <RawTrackerTier> announces = new RawTrackerTiers();

            if (magnetLink.AnnounceUrls != null)
            {
                announces.Add(magnetLink.AnnounceUrls);
            }
            Initialise(savePath, "", announces);
        }
Example #3
0
        public TorrentManager(MagnetLink magnetLink, StorageFolder savePath, TorrentSettings settings,
                              StorageFolder torrentSaveFolder)
        {
            Check.MagnetLink(magnetLink);
            Check.InfoHash(magnetLink.InfoHash);
            Check.SaveFolder(savePath);
            Check.Settings(settings);
            Check.TorrentSave(torrentSaveFolder);

            InfoHash           = magnetLink.InfoHash;
            Settings           = settings;
            _torrentSaveFolder = torrentSaveFolder;
            IList <RawTrackerTier> announces = new RawTrackerTiers();

            if (magnetLink.AnnounceUrls != null)
            {
                announces.Add(magnetLink.AnnounceUrls);
            }
            Initialise(savePath, "", announces);
        }
        public TorrentManager(MagnetLink magnetLink, string savePath, TorrentSettings settings, string torrentSave)
        {
            Torrent torrent;

            Check.MagnetLink(magnetLink);
            Check.InfoHash(magnetLink.InfoHash);
            Check.SavePath(savePath);
            Check.Settings(settings);
            Check.TorrentSave(torrentSave);

            this.infohash    = magnetLink.InfoHash;
            this.settings    = settings;
            this.torrentSave = torrentSave;
            IList <RawTrackerTier> announces = new RawTrackerTiers();

            if (magnetLink.AnnounceUrls != null)
            {
                announces.Add(magnetLink.AnnounceUrls);
            }
            this.webseeds = new List <String>();
            if (magnetLink.Webseeds != null)
            {
                foreach (string webseed in magnetLink.Webseeds)
                {
                    this.webseeds.Add(webseed);
                }
            }

            if (Torrent.TryLoad(torrentSave, out torrent) && torrent.InfoHash == magnetLink.InfoHash)
            {
                this.torrent = torrent;
                Initialise(savePath, "", announces);
                ChangePicker(CreateStandardPicker());
                return;
            }

            Initialise(savePath, "", announces);
        }
Example #5
0
        public TorrentCreatorTests()
        {
            creator   = new TestTorrentCreator();
            announces = new RawTrackerTiers();
            announces.Add(new RawTrackerTier(new string[] { "http://tier1.com/announce1", "http://tier1.com/announce2" }));
            announces.Add(new RawTrackerTier(new string[] { "http://tier2.com/announce1", "http://tier2.com/announce2" }));

            creator.Comment      = Comment;
            creator.CreatedBy    = CreatedBy;
            creator.PieceLength  = PieceLength;
            creator.Publisher    = Publisher;
            creator.PublisherUrl = PublisherUrl;
            creator.SetCustom(CustomKey, CustomValue);
            files = new List <TorrentFile>(new TorrentFile[] {
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir1"), "File1"), (int)(PieceLength * 2.30), 0, 1),
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir1"), "File2"), (int)(PieceLength * 36.5), 1, 3),
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir2"), "File3"), (int)(PieceLength * 3.17), 3, 12),
                new TorrentFile(Path.Combine(Path.Combine("Dir2", "SDir1"), "File4"), (int)(PieceLength * 1.22), 12, 15),
                new TorrentFile(Path.Combine(Path.Combine("Dir2", "SDir2"), "File5"), (int)(PieceLength * 6.94), 15, 15),
            });

            writer           = new TestWriter();
            writer.DontWrite = true;
        }
        public void Setup()
        {
            _creator   = new TestTorrentCreator();
            _announces = new RawTrackerTiers
            {
                new RawTrackerTier(new[]
                {
                    "http://tier1.com/announce1",
                    "http://tier1.com/announce2"
                }),
                new RawTrackerTier(new[]
                {
                    "http://tier2.com/announce1",
                    "http://tier2.com/announce2"
                })
            };

            _creator.Comment      = Comment;
            _creator.CreatedBy    = CreatedBy;
            _creator.PieceLength  = PieceLength;
            _creator.Publisher    = Publisher;
            _creator.PublisherUrl = PublisherUrl;
            _creator.SetCustom(_customKey, _customValue);

            _files = new List <TorrentFile>(new[] {
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir1"), "File1"), (int)(PieceLength * 2.30), 0, 1),
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir1"), "File2"), (int)(PieceLength * 36.5), 1, 3),
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir2"), "File3"), (int)(PieceLength * 3.17), 3, 12),
                new TorrentFile(Path.Combine(Path.Combine("Dir2", "SDir1"), "File4"), (int)(PieceLength * 1.22), 12, 15),
                new TorrentFile(Path.Combine(Path.Combine("Dir2", "SDir2"), "File5"), (int)(PieceLength * 6.94), 15, 15)
            });

            new TestWriter {
                DontWrite = true
            };
        }
        public void Setup()
        {
            _creator = new TestTorrentCreator();
            _announces = new RawTrackerTiers
                             {
                                 new RawTrackerTier(new[]
                                                        {
                                                            "http://tier1.com/announce1",
                                                            "http://tier1.com/announce2"
                                                        }),
                                 new RawTrackerTier(new[]
                                                        {
                                                            "http://tier2.com/announce1",
                                                            "http://tier2.com/announce2"
                                                        })
                             };

            _creator.Comment = Comment;
            _creator.CreatedBy = CreatedBy;
            _creator.PieceLength = PieceLength;
            _creator.Publisher = Publisher;
            _creator.PublisherUrl = PublisherUrl;
            _creator.SetCustom(_customKey, _customValue);

            _files = new List<TorrentFile>(new[] {
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir1"), "File1"), (int)(PieceLength * 2.30), 0, 1),
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir1"), "File2"), (int)(PieceLength * 36.5), 1, 3),
                new TorrentFile(Path.Combine(Path.Combine("Dir1", "SDir2"), "File3"), (int)(PieceLength * 3.17), 3, 12),
                new TorrentFile(Path.Combine(Path.Combine("Dir2", "SDir1"), "File4"), (int)(PieceLength * 1.22), 12, 15),
                new TorrentFile(Path.Combine(Path.Combine("Dir2", "SDir2"), "File5"), (int)(PieceLength * 6.94), 15, 15)
                                                 });

            new TestWriter {DontWrite = true};
        }
        private void Initialise(BEncodedDictionary metadata)
        {
            Metadata = metadata;

            BEncodedValue value;
            if (!Metadata.TryGetValue(AnnounceListKey, out value))
            {
                value = new BEncodedList();
                Metadata.Add(AnnounceListKey, value);
            }
            Announces = new RawTrackerTiers((BEncodedList) value);

            if (string.IsNullOrEmpty(Encoding))
                Encoding = "UTF-8";

            if (InfoDict == null)
                InfoDict = new BEncodedDictionary();
        }