Ejemplo n.º 1
0
        public void should_get_category_from_the_label_if_the_category_is_not_available()
        {
            const string category = "music-readarr";

            GivenGlobalSeedLimits(1.0f);

            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = _title,
                Size     = 1000,
                Progress = 1.0,
                Eta      = 8640000,
                State    = "pausedUP",
                Label    = category,
                SavePath = "",
                Ratio    = 1.0f
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            item.Category.Should().Be(category);
        }
Ejemplo n.º 2
0
        public void should_be_read_only_if_max_ratio_is_not_set()
        {
            GivenMaxRatio(1.0f, false);

            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = _title,
                Size     = 1000,
                Progress = 1.0,
                Eta      = 8640000,
                State    = "uploading",
                Label    = "",
                SavePath = "",
                Ratio    = 1.0f
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            item.IsReadOnly.Should().BeTrue();
        }
Ejemplo n.º 3
0
        public void api_261_should_use_content_path()
        {
            var torrent = new QBittorrentTorrent
            {
                Hash        = "HASH",
                Name        = @"Droned.S01.\1/2",
                Size        = 1000,
                Progress    = 0.7,
                Eta         = 8640000,
                State       = "stalledDL",
                Label       = "",
                SavePath    = @"C:\Torrents".AsOsAgnostic(),
                ContentPath = @"C:\Torrents\Droned.S01.12".AsOsAgnostic()
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            Mocker.GetMock <IQBittorrentProxy>()
            .Setup(v => v.GetApiVersion(It.IsAny <QBittorrentSettings>()))
            .Returns(new Version(2, 6, 1));

            var item = new DownloadClientItem
            {
                DownloadId = torrent.Hash,
                OutputPath = new OsPath(torrent.ContentPath)
            };

            var result = Subject.GetImportItem(item, null);

            result.OutputPath.FullPath.Should().Be(torrent.ContentPath);
        }
Ejemplo n.º 4
0
        public void should_not_be_removable_and_should_not_allow_move_files_if_max_ratio_not_reached()
        {
            GivenGlobalSeedLimits(1.0f);

            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = _title,
                Size     = 1000,
                Progress = 1.0,
                Eta      = 8640000,
                State    = "uploading",
                Label    = "",
                SavePath = "",
                Ratio    = 0.5f
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            item.CanBeRemoved.Should().BeFalse();
            item.CanMoveFiles.Should().BeFalse();
        }
Ejemplo n.º 5
0
        public void single_file_torrent_with_folder_should_only_have_first_subfolder()
        {
            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = @"Droned.S01E01.Test\'s.1080p.WEB-DL-DRONE",
                Size     = 1000,
                Progress = 0.7,
                Eta      = 8640000,
                State    = "stalledDL",
                Label    = "",
                SavePath = @"C:\Torrents".AsOsAgnostic()
            };

            var file = new QBittorrentTorrentFile
            {
                Name = "Folder/Droned.S01E01.Tests.1080p.WEB-DL-DRONE.mkv"
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });
            GivenTorrentFiles(torrent.Hash, new List <QBittorrentTorrentFile> {
                file
            });

            var item = new DownloadClientItem
            {
                DownloadId = torrent.Hash
            };

            var result = Subject.GetImportItem(item, null);

            result.OutputPath.FullPath.Should().Be(Path.Combine(torrent.SavePath, "Folder"));
        }
Ejemplo n.º 6
0
        public void should_get_category_from_the_category_if_set()
        {
            const string category = "tv-sonarr";

            GivenMaxRatio(1.0f);

            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = _title,
                Size     = 1000,
                Progress = 1.0,
                Eta      = 8640000,
                State    = "pausedUP",
                Category = category,
                SavePath = "",
                Ratio    = 1.0f
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            item.Category.Should().Be(category);
        }
Ejemplo n.º 7
0
        public void should_not_be_read_only_if_max_ratio_reached_and_paused()
        {
            GivenMaxRatio(1.0f);

            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = _title,
                Size     = 1000,
                Progress = 1.0,
                Eta      = 8640000,
                State    = "pausedUP",
                Label    = "",
                SavePath = "",
                Ratio    = 1.0f
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            item.IsReadOnly.Should().BeFalse();
        }
Ejemplo n.º 8
0
        public void should_not_be_removable_if_overridden_max_ratio_not_reached_and_paused()
        {
            GivenMaxRatio(0.2f);

            var torrent = new QBittorrentTorrent
            {
                Hash       = "HASH",
                Name       = _title,
                Size       = 1000,
                Progress   = 1.0,
                Eta        = 8640000,
                State      = "pausedUP",
                Label      = "",
                SavePath   = "",
                Ratio      = 0.5f,
                RatioLimit = 0.8f
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            item.CanBeRemoved.Should().BeFalse();
            item.CanMoveFiles.Should().BeFalse();
        }
Ejemplo n.º 9
0
        public void should_be_removable_and_should_allow_move_files_if_max_ratio_reached_and_paused()
        {
            GivenMaxRatio(1.0f);

            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = _title,
                Size     = 1000,
                Progress = 1.0,
                Eta      = 8640000,
                State    = "pausedUP",
                Label    = "",
                SavePath = "",
                Ratio    = 1.0f
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            item.CanBeRemoved.Should().BeTrue();
            item.CanMoveFiles.Should().BeTrue();
        }
Ejemplo n.º 10
0
        protected virtual QBittorrentTorrent GivenCompletedTorrent(
            string state    = "pausedUP",
            float ratio     = 0.1f, float ratioLimit  = -2,
            int seedingTime = 1, int seedingTimeLimit = -2)
        {
            var torrent = new QBittorrentTorrent
            {
                Hash             = "HASH",
                Name             = _title,
                Size             = 1000,
                Progress         = 1.0,
                Eta              = 8640000,
                State            = state,
                Label            = "",
                SavePath         = "",
                Ratio            = ratio,
                RatioLimit       = ratioLimit,
                SeedingTimeLimit = seedingTimeLimit
            };

            GivenTorrents(new List <QBittorrentTorrent>()
            {
                torrent
            });

            Mocker.GetMock <IQBittorrentProxy>()
            .Setup(s => s.GetTorrentProperties("HASH", It.IsAny <QBittorrentSettings>()))
            .Returns(new QBittorrentTorrentProperties
            {
                Hash        = "HASH",
                SeedingTime = seedingTime
            });

            return(torrent);
        }
Ejemplo n.º 11
0
        public void multi_file_torrent_outputpath_should_have_sanitised_name()
        {
            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = @"Droned.S01.\1/2",
                Size     = 1000,
                Progress = 0.7,
                Eta      = 8640000,
                State    = "stalledDL",
                Label    = "",
                SavePath = @"C:\Torrents".AsOsAgnostic()
            };

            var files = new List <QBittorrentTorrentFile>
            {
                new QBittorrentTorrentFile
                {
                    Name = @"Droned.S01.12\E01.mkv".AsOsAgnostic()
                },
                new QBittorrentTorrentFile
                {
                    Name = @"Droned.S01.12\E02.mkv".AsOsAgnostic()
                }
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });
            GivenTorrentFiles(torrent.Hash, files);

            var item = new DownloadClientItem
            {
                DownloadId = torrent.Hash
            };

            var result = Subject.GetImportItem(item, null);

            result.OutputPath.FullPath.Should().Be(Path.Combine(torrent.SavePath, "Droned.S01.12"));
        }
Ejemplo n.º 12
0
 protected void GivenSuccessfulDownload()
 {
     Mocker.GetMock <IQBittorrentProxy>()
     .Setup(s => s.AddTorrentFromUrl(It.IsAny <string>(), It.IsAny <QBittorrentSettings>()))
     .Callback(() =>
     {
         var torrent = new QBittorrentTorrent
         {
             Hash     = "HASH",
             Name     = _title,
             Size     = 1000,
             Progress = 1.0,
             Eta      = 8640000,
             State    = "queuedUP",
             Label    = "",
             SavePath = ""
         };
         GivenTorrents(new List <QBittorrentTorrent> {
             torrent
         });
     });
 }
Ejemplo n.º 13
0
        public void error_item_should_have_required_properties()
        {
            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = _title,
                Size     = 1000,
                Progress = 0.7,
                Eta      = 8640000,
                State    = "error",
                Label    = "",
                SavePath = ""
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            VerifyFailed(item);
        }
Ejemplo n.º 14
0
 protected void GivenSuccessfulDownload()
 {
     Mocker.GetMock <IQBittorrentProxy>()
     .Setup(s => s.AddTorrentFromFile(It.IsAny <string>(), It.IsAny <byte[]>(), It.IsAny <TorrentSeedConfiguration>(), It.IsAny <QBittorrentSettings>()))
     .Callback(() =>
     {
         var torrent = new QBittorrentTorrent
         {
             Hash     = "CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951",
             Name     = _title,
             Size     = 1000,
             Progress = 1.0,
             Eta      = 8640000,
             State    = "queuedUP",
             Label    = "",
             SavePath = ""
         };
         GivenTorrents(new List <QBittorrentTorrent> {
             torrent
         });
     });
 }
Ejemplo n.º 15
0
        public void completed_item_should_have_required_properties(string state)
        {
            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = _title,
                Size     = 1000,
                Progress = 1.0,
                Eta      = 8640000,
                State    = state,
                Label    = "",
                SavePath = ""
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            VerifyCompleted(item);
            item.RemainingTime.Should().Be(TimeSpan.Zero);
        }
Ejemplo n.º 16
0
        public void stalledDL_item_should_have_required_properties()
        {
            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = _title,
                Size     = 1000,
                Progress = 0.7,
                Eta      = 8640000,
                State    = "stalledDL",
                Label    = "",
                SavePath = ""
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            VerifyWarning(item);
            item.RemainingTime.Should().NotHaveValue();
        }
Ejemplo n.º 17
0
        public void downloading_item_should_have_required_properties()
        {
            var torrent = new QBittorrentTorrent
            {
                Hash     = "HASH",
                Name     = _title,
                Size     = 1000,
                Progress = 0.7,
                Eta      = 60,
                State    = "downloading",
                Label    = "",
                SavePath = ""
            };

            GivenTorrents(new List <QBittorrentTorrent> {
                torrent
            });

            var item = Subject.GetItems().Single();

            VerifyDownloading(item);
            item.RemainingTime.Should().NotBe(TimeSpan.Zero);
        }