Beispiel #1
0
        private HadoukenTorrent MapTorrent(object[] item)
        {
            HadoukenTorrent torrent = null;

            try
            {
                torrent = new HadoukenTorrent()
                {
                    InfoHash        = Convert.ToString(item[0]),
                    State           = ParseState(Convert.ToInt32(item[1])),
                    Name            = Convert.ToString(item[2]),
                    TotalSize       = Convert.ToInt64(item[3]),
                    Progress        = Convert.ToDouble(item[4]),
                    DownloadedBytes = Convert.ToInt64(item[5]),
                    UploadedBytes   = Convert.ToInt64(item[6]),
                    DownloadRate    = Convert.ToInt64(item[9]),
                    Label           = Convert.ToString(item[11]),
                    Error           = Convert.ToString(item[21]),
                    SavePath        = Convert.ToString(item[26])
                };
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Failed to map Hadouken torrent data.");
            }

            return(torrent);
        }
Beispiel #2
0
        public void GetItems_should_return_torrents_with_DownloadId_uppercase()
        {
            var torrent = new HadoukenTorrent
            {
                InfoHash        = "hash",
                IsFinished      = true,
                State           = HadoukenTorrentState.Paused,
                Name            = _title,
                TotalSize       = 1000,
                DownloadedBytes = 1000,
                Progress        = 100.0,
                SavePath        = "somepath",
                Label           = "radarr"
            };

            var torrents = new HadoukenTorrent[] { torrent };

            Mocker.GetMock <IHadoukenProxy>()
            .Setup(v => v.GetTorrents(It.IsAny <HadoukenSettings>()))
            .Returns(torrents);

            var result       = Subject.GetItems();
            var downloadItem = result.First();

            downloadItem.DownloadId.Should().Be("HASH");
        }
Beispiel #3
0
        public void GetItems_should_ignore_torrents_with_a_different_category()
        {
            var torrent = new HadoukenTorrent
            {
                InfoHash        = "hash",
                IsFinished      = true,
                State           = HadoukenTorrentState.Paused,
                Name            = _title,
                TotalSize       = 1000,
                DownloadedBytes = 1000,
                Progress        = 100.0,
                SavePath        = "somepath",
                Label           = "radarr-other"
            };

            var torrents = new HadoukenTorrent[] { torrent };

            Mocker.GetMock <IHadoukenProxy>()
            .Setup(v => v.GetTorrents(It.IsAny <HadoukenSettings>()))
            .Returns(torrents);

            Subject.GetItems().Should().BeEmpty();
        }
Beispiel #4
0
        public void Setup()
        {
            Subject.Definition          = new DownloadClientDefinition();
            Subject.Definition.Settings = new HadoukenSettings();

            _queued = new HadoukenTorrent
            {
                InfoHash        = "HASH",
                IsFinished      = false,
                State           = HadoukenTorrentState.QueuedForChecking,
                Name            = _title,
                TotalSize       = 1000,
                DownloadedBytes = 0,
                Progress        = 0.0,
                SavePath        = "somepath",
                Label           = "radarr"
            };

            _downloading = new HadoukenTorrent
            {
                InfoHash        = "HASH",
                IsFinished      = false,
                State           = HadoukenTorrentState.Downloading,
                Name            = _title,
                TotalSize       = 1000,
                DownloadedBytes = 100,
                Progress        = 10.0,
                SavePath        = "somepath",
                Label           = "radarr"
            };

            _failed = new HadoukenTorrent
            {
                InfoHash        = "HASH",
                IsFinished      = false,
                State           = HadoukenTorrentState.Downloading,
                Error           = "some error",
                Name            = _title,
                TotalSize       = 1000,
                DownloadedBytes = 100,
                Progress        = 10.0,
                SavePath        = "somepath",
                Label           = "radarr"
            };

            _completed = new HadoukenTorrent
            {
                InfoHash        = "HASH",
                IsFinished      = true,
                State           = HadoukenTorrentState.Paused,
                Name            = _title,
                TotalSize       = 1000,
                DownloadedBytes = 1000,
                Progress        = 100.0,
                SavePath        = "somepath",
                Label           = "radarr"
            };

            Mocker.GetMock <ITorrentFileInfoReader>()
            .Setup(s => s.GetHashFromTorrentFile(It.IsAny <Byte[]>()))
            .Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951");

            Mocker.GetMock <IHttpClient>()
            .Setup(s => s.Get(It.IsAny <HttpRequest>()))
            .Returns <HttpRequest>(r => new HttpResponse(r, new HttpHeader(), new byte[0]));
        }